Skip to content

Commit 82279cf

Browse files
authored
Merge branch 'main' into task/llvm-reduce
2 parents 054f69d + 14d2561 commit 82279cf

File tree

59 files changed

+1491
-1308
lines changed

Some content is hidden

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

59 files changed

+1491
-1308
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/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/ASTMatchers/ASTMatchFinder.cpp

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include <deque>
2929
#include <memory>
3030
#include <set>
31-
#include <vector>
3231

3332
namespace clang {
3433
namespace ast_matchers {
@@ -423,7 +422,7 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>,
423422
public ASTMatchFinder {
424423
public:
425424
MatchASTVisitor(const MatchFinder::MatchersByType *Matchers,
426-
const MatchFinderOptions &Options)
425+
const MatchFinder::MatchFinderOptions &Options)
427426
: Matchers(Matchers), Options(Options), ActiveASTContext(nullptr) {}
428427

429428
~MatchASTVisitor() override {
@@ -1351,7 +1350,7 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>,
13511350
/// We precalculate a list of matchers that pass the toplevel restrict check.
13521351
llvm::DenseMap<ASTNodeKind, std::vector<unsigned short>> MatcherFiltersMap;
13531352

1354-
const MatchFinderOptions &Options;
1353+
const MatchFinder::MatchFinderOptions &Options;
13551354
ASTContext *ActiveASTContext;
13561355

13571356
// Maps a canonical type to its TypedefDecls.
@@ -1574,41 +1573,19 @@ bool MatchASTVisitor::TraverseAttr(Attr *AttrNode) {
15741573
class MatchASTConsumer : public ASTConsumer {
15751574
public:
15761575
MatchASTConsumer(MatchFinder *Finder,
1577-
MatchFinder::ParsingDoneTestCallback *ParsingDone,
1578-
const MatchFinderOptions &Options)
1579-
: Finder(Finder), ParsingDone(ParsingDone), Options(Options) {}
1576+
MatchFinder::ParsingDoneTestCallback *ParsingDone)
1577+
: Finder(Finder), ParsingDone(ParsingDone) {}
15801578

15811579
private:
1582-
bool HandleTopLevelDecl(DeclGroupRef DG) override {
1583-
if (Options.SkipSystemHeaders) {
1584-
for (Decl *D : DG) {
1585-
if (!isInSystemHeader(D))
1586-
TraversalScope.push_back(D);
1587-
}
1588-
}
1589-
return true;
1590-
}
1591-
15921580
void HandleTranslationUnit(ASTContext &Context) override {
1593-
if (!TraversalScope.empty())
1594-
Context.setTraversalScope(TraversalScope);
1595-
15961581
if (ParsingDone != nullptr) {
15971582
ParsingDone->run();
15981583
}
15991584
Finder->matchAST(Context);
16001585
}
16011586

1602-
bool isInSystemHeader(Decl *D) {
1603-
const SourceManager &SM = D->getASTContext().getSourceManager();
1604-
const SourceLocation Loc = SM.getExpansionLoc(D->getBeginLoc());
1605-
return SM.isInSystemHeader(Loc);
1606-
}
1607-
16081587
MatchFinder *Finder;
16091588
MatchFinder::ParsingDoneTestCallback *ParsingDone;
1610-
const MatchFinderOptions &Options;
1611-
std::vector<Decl *> TraversalScope;
16121589
};
16131590

16141591
} // end namespace
@@ -1727,8 +1704,7 @@ bool MatchFinder::addDynamicMatcher(const internal::DynTypedMatcher &NodeMatch,
17271704
}
17281705

17291706
std::unique_ptr<ASTConsumer> MatchFinder::newASTConsumer() {
1730-
return std::make_unique<internal::MatchASTConsumer>(this, ParsingDone,
1731-
Options);
1707+
return std::make_unique<internal::MatchASTConsumer>(this, ParsingDone);
17321708
}
17331709

17341710
void MatchFinder::match(const clang::DynTypedNode &Node, ASTContext &Context) {

0 commit comments

Comments
 (0)