Skip to content

Commit 704bbe8

Browse files
committed
merge main into amd-staging
2 parents 0f936d4 + 9a82f74 commit 704bbe8

File tree

973 files changed

+15851
-5514
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

973 files changed

+15851
-5514
lines changed

clang-tools-extra/clang-query/Query.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
114114
Profiler.emplace();
115115

116116
for (auto &AST : QS.ASTs) {
117-
ast_matchers::MatchFinderOptions FinderOptions;
117+
ast_matchers::MatchFinder::MatchFinderOptions FinderOptions;
118118
std::optional<llvm::StringMap<llvm::TimeRecord>> Records;
119119
if (QS.EnableProfile) {
120120
Records.emplace();

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ ClangTidyASTConsumerFactory::createASTConsumer(
420420
std::vector<std::unique_ptr<ClangTidyCheck>> Checks =
421421
CheckFactories->createChecksForLanguage(&Context);
422422

423-
ast_matchers::MatchFinderOptions FinderOptions;
423+
ast_matchers::MatchFinder::MatchFinderOptions FinderOptions;
424424

425425
std::unique_ptr<ClangTidyProfiling> Profiling;
426426
if (Context.getEnableProfiling()) {
@@ -429,10 +429,6 @@ ClangTidyASTConsumerFactory::createASTConsumer(
429429
FinderOptions.CheckProfiling.emplace(Profiling->Records);
430430
}
431431

432-
// Avoid processing system headers, unless the user explicitly requests it
433-
if (!Context.getOptions().SystemHeaders.value_or(false))
434-
FinderOptions.SkipSystemHeaders = true;
435-
436432
std::unique_ptr<ast_matchers::MatchFinder> Finder(
437433
new ast_matchers::MatchFinder(std::move(FinderOptions)));
438434

clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,41 +35,19 @@ AST_POLYMORPHIC_MATCHER_P(
3535
Builder) != Args.end();
3636
}
3737

38-
bool isStdOrPosixImpl(const DeclContext *Ctx) {
39-
if (!Ctx->isNamespace())
40-
return false;
41-
42-
const auto *ND = cast<NamespaceDecl>(Ctx);
43-
if (ND->isInline()) {
44-
return isStdOrPosixImpl(ND->getParent());
45-
}
46-
47-
if (!ND->getParent()->getRedeclContext()->isTranslationUnit())
48-
return false;
49-
50-
const IdentifierInfo *II = ND->getIdentifier();
51-
return II && (II->isStr("std") || II->isStr("posix"));
52-
}
53-
54-
AST_MATCHER(Decl, isInStdOrPosixNS) {
55-
for (const auto *Ctx = Node.getDeclContext(); Ctx; Ctx = Ctx->getParent()) {
56-
if (isStdOrPosixImpl(Ctx))
57-
return true;
58-
}
59-
return false;
60-
}
61-
6238
} // namespace
6339

6440
namespace clang::tidy::cert {
6541

6642
void DontModifyStdNamespaceCheck::registerMatchers(MatchFinder *Finder) {
6743
auto HasStdParent =
6844
hasDeclContext(namespaceDecl(hasAnyName("std", "posix"),
69-
unless(hasDeclContext(namespaceDecl())))
45+
unless(hasParent(namespaceDecl())))
7046
.bind("nmspc"));
71-
auto UserDefinedType = qualType(hasUnqualifiedDesugaredType(
72-
tagType(unless(hasDeclaration(tagDecl(isInStdOrPosixNS()))))));
47+
auto UserDefinedType = qualType(
48+
hasUnqualifiedDesugaredType(tagType(unless(hasDeclaration(tagDecl(
49+
hasAncestor(namespaceDecl(hasAnyName("std", "posix"),
50+
unless(hasParent(namespaceDecl()))))))))));
7351
auto HasNoProgramDefinedTemplateArgument = unless(
7452
hasAnyTemplateArgumentIncludingPack(refersToType(UserDefinedType)));
7553
auto InsideStdClassOrClassTemplateSpecialization = hasDeclContext(

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,6 @@ Improvements to clang-query
9191
Improvements to clang-tidy
9292
--------------------------
9393

94-
- :program:`clang-tidy` no longer processes declarations from system headers
95-
by default, greatly improving performance. This behavior is disabled if the
96-
`SystemHeaders` option is enabled.
97-
Note: this may lead to false negatives; downstream users may need to adjust
98-
their checks to preserve existing behavior.
99-
10094
- Improved :program:`clang-tidy-diff.py` script. Add the `-warnings-as-errors`
10195
argument to treat warnings as errors.
10296

clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-anon-record-fields.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,23 @@
3333
// RUN: readability-identifier-naming.LocalConstantPointerPrefix: 'lc_', \
3434
// RUN: }}'
3535

36-
// FIXME: make this test case pass.
37-
// Currently not working because the CXXRecordDecl for the global anonymous
38-
// union is *not* collected as a top-level declaration.
39-
// https://github.com/llvm/llvm-project/issues/130618
40-
#if 0
4136
static union {
4237
int global;
43-
// FIXME-CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'global'
44-
// FIXME-CHECK-FIXES: {{^}} int g_global;{{$}}
38+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'global'
39+
// CHECK-FIXES: {{^}} int g_global;{{$}}
4540

4641
const int global_const;
47-
// FIXME-CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global constant 'global_const'
48-
// FIXME-CHECK-FIXES: {{^}} const int GLOBAL_CONST;{{$}}
42+
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global constant 'global_const'
43+
// CHECK-FIXES: {{^}} const int GLOBAL_CONST;{{$}}
4944

5045
int *global_ptr;
51-
// FIXME-CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global pointer 'global_ptr'
52-
// FIXME-CHECK-FIXES: {{^}} int *GlobalPtr_Ptr;{{$}}
46+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for global pointer 'global_ptr'
47+
// CHECK-FIXES: {{^}} int *GlobalPtr_Ptr;{{$}}
5348

5449
int *const global_const_ptr;
55-
// FIXME-CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for global constant pointer 'global_const_ptr'
56-
// FIXME-CHECK-FIXES: {{^}} int *const GLOBAL_CONST_PTR_Ptr;{{$}}
50+
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for global constant pointer 'global_const_ptr'
51+
// CHECK-FIXES: {{^}} int *const GLOBAL_CONST_PTR_Ptr;{{$}}
5752
};
58-
#endif
5953

6054
namespace ns {
6155

clang-tools-extra/test/clang-tidy/infrastructure/file-filter.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,19 @@ class A { A(int); };
6666
// CHECK4-NOT: warning:
6767
// CHECK4-QUIET-NOT: warning:
6868

69+
// CHECK: Suppressed 3 warnings (3 in non-user code)
6970
// CHECK: Use -header-filter=.* to display errors from all non-system headers.
7071
// CHECK-QUIET-NOT: Suppressed
72+
// CHECK2: Suppressed 1 warnings (1 in non-user code)
73+
// CHECK2: Use -header-filter=.* {{.*}}
7174
// CHECK2-QUIET-NOT: Suppressed
75+
// CHECK3: Suppressed 2 warnings (2 in non-user code)
76+
// CHECK3: Use -header-filter=.* {{.*}}
7277
// CHECK3-QUIET-NOT: Suppressed
7378
// CHECK4-NOT: Suppressed {{.*}} warnings
79+
// CHECK4-NOT: Use -header-filter=.* {{.*}}
7480
// CHECK4-QUIET-NOT: Suppressed
81+
// CHECK6: Suppressed 2 warnings (2 in non-user code)
7582
// CHECK6: Use -header-filter=.* {{.*}}
7683

7784
int x = 123;

clang-tools-extra/test/clang-tidy/infrastructure/system-headers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
// RUN: clang-tidy -help | FileCheck -check-prefix=CHECK-OPT-PRESENT %s
1212

1313
// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers=true %s -- -isystem %S/Inputs/system-headers 2>&1 | FileCheck -check-prefix=CHECK-SYSTEM-HEADERS %s
14-
// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers=false %s -- -isystem %S/Inputs/system-headers 2>&1 | FileCheck -check-prefix=CHECK-NO-SYSTEM-HEADERS --allow-empty %s
14+
// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers=false %s -- -isystem %S/Inputs/system-headers 2>&1 | FileCheck -check-prefix=CHECK-NO-SYSTEM-HEADERS %s
1515
// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -config='SystemHeaders: true' %s -- -isystem %S/Inputs/system-headers 2>&1 | FileCheck -check-prefix=CHECK-SYSTEM-HEADERS %s
16-
// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -config='SystemHeaders: false' %s -- -isystem %S/Inputs/system-headers 2>&1 | FileCheck -check-prefix=CHECK-NO-SYSTEM-HEADERS --allow-empty %s
16+
// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -config='SystemHeaders: false' %s -- -isystem %S/Inputs/system-headers 2>&1 | FileCheck -check-prefix=CHECK-NO-SYSTEM-HEADERS %s
1717

1818
#include <system_header.h>
1919
// CHECK-SYSTEM-HEADERS: system_header.h:1:13: warning: single-argument constructors must be marked explicit

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,11 @@ RISC-V Support
425425

426426
- Add support for `-mtune=generic-ooo` (a generic out-of-order model).
427427

428+
- Adds support for `__attribute__((interrupt("qci-nest")))` and
429+
`__attribute__((interrupt("qci-nonest")))`. These use instructions from
430+
Qualcomm's `Xqciint` extension to save and restore some GPRs in interrupt
431+
service routines.
432+
428433
CUDA/HIP Language Changes
429434
^^^^^^^^^^^^^^^^^^^^^^^^^
430435

@@ -458,11 +463,6 @@ AST Matchers
458463
- Ensure ``isDerivedFrom`` matches the correct base in case more than one alias exists.
459464
- Extend ``templateArgumentCountIs`` to support function and variable template
460465
specialization.
461-
- Move ``ast_matchers::MatchFinder::MatchFinderOptions`` to
462-
``ast_matchers::MatchFinderOptions``.
463-
- Add a boolean member ``SkipSystemHeaders`` to ``MatchFinderOptions``, and make
464-
``MatchASTConsumer`` receive a reference to ``MatchFinderOptions`` in the
465-
constructor. This allows it to skip system headers when traversing the AST.
466466

467467
clang-format
468468
------------

clang/include/clang/ASTMatchers/ASTMatchFinder.h

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,6 @@ namespace clang {
5050

5151
namespace ast_matchers {
5252

53-
/// A struct defining options for configuring the MatchFinder.
54-
struct MatchFinderOptions {
55-
struct Profiling {
56-
Profiling(llvm::StringMap<llvm::TimeRecord> &Records) : Records(Records) {}
57-
58-
/// Per bucket timing information.
59-
llvm::StringMap<llvm::TimeRecord> &Records;
60-
};
61-
62-
/// Enables per-check timers.
63-
///
64-
/// It prints a report after match.
65-
std::optional<Profiling> CheckProfiling;
66-
67-
/// Avoids matching declarations in system headers.
68-
bool SkipSystemHeaders = false;
69-
};
70-
7153
/// A class to allow finding matches over the Clang AST.
7254
///
7355
/// After creation, you can add multiple matchers to the MatchFinder via
@@ -144,6 +126,21 @@ class MatchFinder {
144126
virtual void run() = 0;
145127
};
146128

129+
struct MatchFinderOptions {
130+
struct Profiling {
131+
Profiling(llvm::StringMap<llvm::TimeRecord> &Records)
132+
: Records(Records) {}
133+
134+
/// Per bucket timing information.
135+
llvm::StringMap<llvm::TimeRecord> &Records;
136+
};
137+
138+
/// Enables per-check timers.
139+
///
140+
/// It prints a report after match.
141+
std::optional<Profiling> CheckProfiling;
142+
};
143+
147144
MatchFinder(MatchFinderOptions Options = MatchFinderOptions());
148145
~MatchFinder();
149146

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,8 @@ def fhip_emit_relocatable : Flag<["-"], "fhip-emit-relocatable">,
13971397
HelpText<"Compile HIP source to relocatable">;
13981398
def fno_hip_emit_relocatable : Flag<["-"], "fno-hip-emit-relocatable">,
13991399
HelpText<"Do not override toolchain to compile HIP source to relocatable">;
1400+
def flto_partitions_EQ : Joined<["--"], "flto-partitions=">, Group<hip_Group>,
1401+
HelpText<"Number of partitions to use for parallel full LTO codegen. Use 1 to disable partitioning.">;
14001402
}
14011403

14021404
// Clang specific/exclusive options for OpenACC.

clang/include/clang/Sema/HLSLExternalSemaSource.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
#ifndef CLANG_SEMA_HLSLEXTERNALSEMASOURCE_H
1313
#define CLANG_SEMA_HLSLEXTERNALSEMASOURCE_H
1414

15-
#include "llvm/ADT/DenseMap.h"
16-
1715
#include "clang/Sema/ExternalSemaSource.h"
16+
#include "llvm/ADT/DenseMap.h"
1817

1918
namespace clang {
2019
class NamespaceDecl;
@@ -27,14 +26,8 @@ class HLSLExternalSemaSource : public ExternalSemaSource {
2726
using CompletionFunction = std::function<void(CXXRecordDecl *)>;
2827
llvm::DenseMap<CXXRecordDecl *, CompletionFunction> Completions;
2928

30-
void defineHLSLVectorAlias();
31-
void defineTrivialHLSLTypes();
32-
void defineHLSLTypesWithForwardDeclarations();
33-
34-
void onCompletion(CXXRecordDecl *Record, CompletionFunction Fn);
35-
3629
public:
37-
~HLSLExternalSemaSource() override;
30+
~HLSLExternalSemaSource() override {}
3831

3932
/// Initialize the semantic source with the Sema instance
4033
/// being used to perform semantic analysis on the abstract syntax
@@ -47,6 +40,12 @@ class HLSLExternalSemaSource : public ExternalSemaSource {
4740
using ExternalASTSource::CompleteType;
4841
/// Complete an incomplete HLSL builtin type
4942
void CompleteType(TagDecl *Tag) override;
43+
44+
private:
45+
void defineTrivialHLSLTypes();
46+
void defineHLSLVectorAlias();
47+
void defineHLSLTypesWithForwardDeclarations();
48+
void onCompletion(CXXRecordDecl *Record, CompletionFunction Fn);
5049
};
5150

5251
} // namespace clang

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,13 @@ static bool interp__builtin_strcmp(InterpState &S, CodePtr OpPC,
212212
const Pointer &A = getParam<Pointer>(Frame, 0);
213213
const Pointer &B = getParam<Pointer>(Frame, 1);
214214

215-
if (ID == Builtin::BIstrcmp || ID == Builtin::BIstrncmp)
215+
if (ID == Builtin::BIstrcmp || ID == Builtin::BIstrncmp ||
216+
ID == Builtin::BIwcscmp || ID == Builtin::BIwcsncmp)
216217
diagnoseNonConstexprBuiltin(S, OpPC, ID);
217218

218219
uint64_t Limit = ~static_cast<uint64_t>(0);
219-
if (ID == Builtin::BIstrncmp || ID == Builtin::BI__builtin_strncmp)
220+
if (ID == Builtin::BIstrncmp || ID == Builtin::BI__builtin_strncmp ||
221+
ID == Builtin::BIwcsncmp || ID == Builtin::BI__builtin_wcsncmp)
220222
Limit = peekToAPSInt(S.Stk, *S.getContext().classify(Call->getArg(2)))
221223
.getZExtValue();
222224

@@ -231,6 +233,9 @@ static bool interp__builtin_strcmp(InterpState &S, CodePtr OpPC,
231233
if (A.isDummy() || B.isDummy())
232234
return false;
233235

236+
bool IsWide = ID == Builtin::BIwcscmp || ID == Builtin::BIwcsncmp ||
237+
ID == Builtin::BI__builtin_wcscmp ||
238+
ID == Builtin::BI__builtin_wcsncmp;
234239
assert(A.getFieldDesc()->isPrimitiveArray());
235240
assert(B.getFieldDesc()->isPrimitiveArray());
236241

@@ -248,6 +253,21 @@ static bool interp__builtin_strcmp(InterpState &S, CodePtr OpPC,
248253
!CheckRange(S, OpPC, PB, AK_Read)) {
249254
return false;
250255
}
256+
257+
if (IsWide)
258+
INT_TYPE_SWITCH(
259+
*S.getContext().classify(S.getASTContext().getWCharType()), {
260+
T A = PA.deref<T>();
261+
T B = PB.deref<T>();
262+
if (A < B) {
263+
pushInteger(S, -1, Call->getType());
264+
return true;
265+
} else if (A > B) {
266+
pushInteger(S, 1, Call->getType());
267+
return true;
268+
}
269+
});
270+
251271
uint8_t CA = PA.deref<uint8_t>();
252272
uint8_t CB = PB.deref<uint8_t>();
253273

@@ -1792,6 +1812,17 @@ static bool interp__builtin_memcpy(InterpState &S, CodePtr OpPC,
17921812
return false;
17931813
}
17941814

1815+
// Diagnose integral src/dest pointers specially.
1816+
if (SrcPtr.isIntegralPointer() || DestPtr.isIntegralPointer()) {
1817+
std::string DiagVal = "(void *)";
1818+
DiagVal += SrcPtr.isIntegralPointer()
1819+
? std::to_string(SrcPtr.getIntegerRepresentation())
1820+
: std::to_string(DestPtr.getIntegerRepresentation());
1821+
S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_memcpy_null)
1822+
<< Move << false << DestPtr.isIntegralPointer() << DiagVal;
1823+
return false;
1824+
}
1825+
17951826
// Can't read from dummy pointers.
17961827
if (DestPtr.isDummy() || SrcPtr.isDummy())
17971828
return false;
@@ -2052,7 +2083,8 @@ static bool interp__builtin_memchr(InterpState &S, CodePtr OpPC,
20522083
}
20532084

20542085
bool StopAtZero =
2055-
(ID == Builtin::BIstrchr || ID == Builtin::BI__builtin_strchr);
2086+
(ID == Builtin::BIstrchr || ID == Builtin::BI__builtin_strchr ||
2087+
ID == Builtin::BIwcschr || ID == Builtin::BI__builtin_wcschr);
20562088

20572089
PrimType ElemT =
20582090
IsRawByte ? PT_Sint8 : *S.getContext().classify(getElemType(Ptr));
@@ -2108,6 +2140,10 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F,
21082140
case Builtin::BIstrcmp:
21092141
case Builtin::BI__builtin_strncmp:
21102142
case Builtin::BIstrncmp:
2143+
case Builtin::BI__builtin_wcsncmp:
2144+
case Builtin::BIwcsncmp:
2145+
case Builtin::BI__builtin_wcscmp:
2146+
case Builtin::BIwcscmp:
21112147
if (!interp__builtin_strcmp(S, OpPC, Frame, F, Call))
21122148
return false;
21132149
break;
@@ -2574,10 +2610,8 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F,
25742610
case Builtin::BI__builtin_strchr:
25752611
case Builtin::BIwmemchr:
25762612
case Builtin::BI__builtin_wmemchr:
2577-
#if 0
25782613
case Builtin::BIwcschr:
25792614
case Builtin::BI__builtin_wcschr:
2580-
#endif
25812615
case Builtin::BI__builtin_char_memchr:
25822616
if (!interp__builtin_memchr(S, OpPC, Frame, F, Call))
25832617
return false;

0 commit comments

Comments
 (0)