Skip to content

Commit 6434b9c

Browse files
author
Erich Keane
committed
Merge from 'master' to 'sycl-web' (#1)
CONFLICT (content): Merge conflict in clang/test/SemaOpenCLCXX/address-space-lambda.cl
2 parents e4295e6 + a72f11e commit 6434b9c

File tree

220 files changed

+11974
-3975
lines changed

Some content is hidden

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

220 files changed

+11974
-3975
lines changed

clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ static int getPriority(StringRef Filename, bool IsAngled, bool IsMainModule) {
6767
return 2;
6868

6969
// System headers are sorted to the end.
70-
if (IsAngled || Filename.startswith("gtest/"))
70+
if (IsAngled || Filename.startswith("gtest/") ||
71+
Filename.startswith("gmock/"))
7172
return 3;
7273

7374
// Other headers are inserted between the main module header and LLVM headers.

clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/gmock/foo.h

Whitespace-only changes.

clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: #includes are not sorted properly
44
#include "j.h"
55
#include "gtest/foo.h"
6+
#include "gmock/foo.h"
67
#include "i.h"
78
#include <s.h>
89
#include "llvm/a.h"
@@ -16,6 +17,7 @@
1617
// CHECK-FIXES-NEXT: #include "clang/b.h"
1718
// CHECK-FIXES-NEXT: #include "llvm-c/d.h" // -c
1819
// CHECK-FIXES-NEXT: #include "llvm/a.h"
20+
// CHECK-FIXES-NEXT: #include "gmock/foo.h"
1921
// CHECK-FIXES-NEXT: #include "gtest/foo.h"
2022
// CHECK-FIXES-NEXT: #include <s.h>
2123

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ release of Clang. Users of the build system should adjust accordingly.
230230
AST Matchers
231231
------------
232232

233-
- ...
233+
- The behavior of TK_IgnoreUnlessSpelledInSource with the traverse() matcher
234+
has been changed to no longer match on template instantiations or on
235+
implicit nodes which are not spelled in the source.
234236

235237
clang-format
236238
------------

clang/include/clang/AST/ASTContext.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,6 +2093,10 @@ class ASTContext : public RefCountedBase<ASTContext> {
20932093
/// vector-length.
20942094
bool areCompatibleSveTypes(QualType FirstType, QualType SecondType);
20952095

2096+
/// Return true if the given vector types are lax-compatible SVE vector types,
2097+
/// false otherwise.
2098+
bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType);
2099+
20962100
/// Return true if the type has been explicitly qualified with ObjC ownership.
20972101
/// A type may be implicitly qualified with ownership under ObjC ARC, and in
20982102
/// some cases the compiler treats these differently.

clang/include/clang/AST/ASTNodeTraverser.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ class ASTNodeTraverser
8585
TraversalKind GetTraversalKind() const { return Traversal; }
8686

8787
void Visit(const Decl *D) {
88+
if (Traversal == TK_IgnoreUnlessSpelledInSource && D->isImplicit())
89+
return;
90+
8891
getNodeDelegate().AddChild([=] {
8992
getNodeDelegate().Visit(D);
9093
if (!D)
@@ -144,7 +147,8 @@ class ASTNodeTraverser
144147
if (isa<DeclStmt>(S) || isa<GenericSelectionExpr>(S))
145148
return;
146149

147-
if (isa<LambdaExpr>(S) && Traversal == TK_IgnoreUnlessSpelledInSource)
150+
if (Traversal == TK_IgnoreUnlessSpelledInSource &&
151+
isa<LambdaExpr, CXXForRangeStmt, CallExpr>(S))
148152
return;
149153

150154
for (const Stmt *SubStmt : S->children())
@@ -185,6 +189,8 @@ class ASTNodeTraverser
185189
}
186190

187191
void Visit(const CXXCtorInitializer *Init) {
192+
if (Traversal == TK_IgnoreUnlessSpelledInSource && !Init->isWritten())
193+
return;
188194
getNodeDelegate().AddChild([=] {
189195
getNodeDelegate().Visit(Init);
190196
Visit(Init->getInit());
@@ -401,6 +407,9 @@ class ASTNodeTraverser
401407
if (const Expr *TRC = D->getTrailingRequiresClause())
402408
Visit(TRC);
403409

410+
if (Traversal == TK_IgnoreUnlessSpelledInSource && D->isDefaulted())
411+
return;
412+
404413
if (const auto *C = dyn_cast<CXXConstructorDecl>(D))
405414
for (const auto *I : C->inits())
406415
Visit(I);
@@ -417,6 +426,9 @@ class ASTNodeTraverser
417426
}
418427

419428
void VisitVarDecl(const VarDecl *D) {
429+
if (Traversal == TK_IgnoreUnlessSpelledInSource && D->isCXXForRangeDecl())
430+
return;
431+
420432
if (D->hasInit())
421433
Visit(D->getInit());
422434
}
@@ -717,6 +729,26 @@ class ASTNodeTraverser
717729
Visit(CatchParam);
718730
}
719731

732+
void VisitCXXForRangeStmt(const CXXForRangeStmt *Node) {
733+
if (Traversal == TK_IgnoreUnlessSpelledInSource) {
734+
Visit(Node->getInit());
735+
Visit(Node->getLoopVariable());
736+
Visit(Node->getRangeInit());
737+
Visit(Node->getBody());
738+
}
739+
}
740+
741+
void VisitCallExpr(const CallExpr *Node) {
742+
for (const auto *Child :
743+
make_filter_range(Node->children(), [this](const Stmt *Child) {
744+
if (Traversal != TK_IgnoreUnlessSpelledInSource)
745+
return false;
746+
return !isa<CXXDefaultArgExpr>(Child);
747+
})) {
748+
Visit(Child);
749+
}
750+
}
751+
720752
void VisitExpressionTemplateArgument(const TemplateArgument &TA) {
721753
Visit(TA.getAsExpr());
722754
}

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3106,9 +3106,16 @@ AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
31063106
/// \c A but not \c B.
31073107
AST_MATCHER_P(CXXRecordDecl, hasMethod, internal::Matcher<CXXMethodDecl>,
31083108
InnerMatcher) {
3109-
return matchesFirstInPointerRange(InnerMatcher, Node.method_begin(),
3110-
Node.method_end(), Finder,
3111-
Builder) != Node.method_end();
3109+
BoundNodesTreeBuilder Result(*Builder);
3110+
auto MatchIt = matchesFirstInPointerRange(InnerMatcher, Node.method_begin(),
3111+
Node.method_end(), Finder, &Result);
3112+
if (MatchIt == Node.method_end())
3113+
return false;
3114+
3115+
if (Finder->isTraversalIgnoringImplicitNodes() && (*MatchIt)->isImplicit())
3116+
return false;
3117+
*Builder = std::move(Result);
3118+
return true;
31123119
}
31133120

31143121
/// Matches the generated class of lambda expressions.
@@ -4044,7 +4051,15 @@ AST_POLYMORPHIC_MATCHER_P(argumentCountIs,
40444051
CallExpr, CXXConstructExpr,
40454052
CXXUnresolvedConstructExpr, ObjCMessageExpr),
40464053
unsigned, N) {
4047-
return Node.getNumArgs() == N;
4054+
unsigned NumArgs = Node.getNumArgs();
4055+
if (!Finder->isTraversalIgnoringImplicitNodes())
4056+
return NumArgs == N;
4057+
while (NumArgs) {
4058+
if (!isa<CXXDefaultArgExpr>(Node.getArg(NumArgs - 1)))
4059+
break;
4060+
--NumArgs;
4061+
}
4062+
return NumArgs == N;
40484063
}
40494064

40504065
/// Matches the n'th argument of a call expression or a constructor
@@ -4060,9 +4075,12 @@ AST_POLYMORPHIC_MATCHER_P2(hasArgument,
40604075
CallExpr, CXXConstructExpr,
40614076
CXXUnresolvedConstructExpr, ObjCMessageExpr),
40624077
unsigned, N, internal::Matcher<Expr>, InnerMatcher) {
4063-
return (N < Node.getNumArgs() &&
4064-
InnerMatcher.matches(
4065-
*Node.getArg(N)->IgnoreParenImpCasts(), Finder, Builder));
4078+
if (N >= Node.getNumArgs())
4079+
return false;
4080+
const Expr *Arg = Node.getArg(N);
4081+
if (Finder->isTraversalIgnoringImplicitNodes() && isa<CXXDefaultArgExpr>(Arg))
4082+
return false;
4083+
return InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, Builder);
40664084
}
40674085

40684086
/// Matches the n'th item of an initializer list expression.
@@ -4154,9 +4172,11 @@ AST_MATCHER(CXXCatchStmt, isCatchAll) {
41544172
/// record matches Foo, hasAnyConstructorInitializer matches foo_(1)
41554173
AST_MATCHER_P(CXXConstructorDecl, hasAnyConstructorInitializer,
41564174
internal::Matcher<CXXCtorInitializer>, InnerMatcher) {
4157-
return matchesFirstInPointerRange(InnerMatcher, Node.init_begin(),
4158-
Node.init_end(), Finder,
4159-
Builder) != Node.init_end();
4175+
auto MatchIt = matchesFirstInPointerRange(InnerMatcher, Node.init_begin(),
4176+
Node.init_end(), Finder, Builder);
4177+
if (MatchIt == Node.init_end())
4178+
return false;
4179+
return (*MatchIt)->isWritten() || !Finder->isTraversalIgnoringImplicitNodes();
41604180
}
41614181

41624182
/// Matches the field declaration of a constructor initializer.
@@ -4281,6 +4301,9 @@ AST_POLYMORPHIC_MATCHER_P(hasAnyArgument,
42814301
CXXUnresolvedConstructExpr, ObjCMessageExpr),
42824302
internal::Matcher<Expr>, InnerMatcher) {
42834303
for (const Expr *Arg : Node.arguments()) {
4304+
if (Finder->isTraversalIgnoringImplicitNodes() &&
4305+
isa<CXXDefaultArgExpr>(Arg))
4306+
break;
42844307
BoundNodesTreeBuilder Result(*Builder);
42854308
if (InnerMatcher.matches(*Arg, Finder, &Result)) {
42864309
*Builder = std::move(Result);
@@ -4998,6 +5021,8 @@ AST_POLYMORPHIC_MATCHER_P(hasBody,
49985021
CXXForRangeStmt,
49995022
FunctionDecl),
50005023
internal::Matcher<Stmt>, InnerMatcher) {
5024+
if (Finder->isTraversalIgnoringImplicitNodes() && isDefaultedHelper(&Node))
5025+
return false;
50015026
const Stmt *const Statement = internal::GetBodyMatcher<NodeType>::get(Node);
50025027
return (Statement != nullptr &&
50035028
InnerMatcher.matches(*Statement, Finder, Builder));
@@ -6880,6 +6905,8 @@ AST_MATCHER_P(CXXConstructorDecl, forEachConstructorInitializer,
68806905
BoundNodesTreeBuilder Result;
68816906
bool Matched = false;
68826907
for (const auto *I : Node.inits()) {
6908+
if (Finder->isTraversalIgnoringImplicitNodes() && !I->isWritten())
6909+
continue;
68836910
BoundNodesTreeBuilder InitBuilder(*Builder);
68846911
if (InnerMatcher.matches(*I, Finder, &InitBuilder)) {
68856912
Matched = true;

0 commit comments

Comments
 (0)