Loading clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -442,7 +442,7 @@ void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) { hasDeclaration(DeclMatcher), unless(templateSpecializationType()))))), hasParent(nestedNameSpecifierLoc()), hasAncestor(isImplicit()), hasAncestor(decl(isImplicit())), hasAncestor(UsingShadowDeclInClass), hasAncestor(functionDecl(isDefaulted())))), hasAncestor(decl().bind("dc"))) Loading @@ -466,7 +466,7 @@ void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) { hasAncestor(decl(IsInMovedNs).bind("dc")), loc(nestedNameSpecifier( specifiesType(hasDeclaration(DeclMatcher.bind("from_decl"))))), unless(anyOf(hasAncestor(isImplicit()), unless(anyOf(hasAncestor(decl(isImplicit())), hasAncestor(UsingShadowDeclInClass), hasAncestor(functionDecl(isDefaulted())), hasAncestor(typeLoc(loc(qualType(hasDeclaration( Loading Loading @@ -495,7 +495,7 @@ void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) { hasAncestor(cxxRecordDecl()))), hasParent(namespaceDecl())); Finder->addMatcher(expr(hasAncestor(decl().bind("dc")), IsInMovedNs, unless(hasAncestor(isImplicit())), unless(hasAncestor(decl(isImplicit()))), anyOf(callExpr(callee(FuncMatcher)).bind("call"), declRefExpr(to(FuncMatcher.bind("func_decl"))) .bind("func_ref"))), Loading clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -38,10 +38,10 @@ void ProBoundsConstantArrayIndexCheck::registerPPCallbacks( void ProBoundsConstantArrayIndexCheck::registerMatchers(MatchFinder *Finder) { // Note: if a struct contains an array member, the compiler-generated // constructor has an arraySubscriptExpr. Finder->addMatcher( arraySubscriptExpr( hasBase(ignoringImpCasts(hasType(constantArrayType().bind("type")))), hasIndex(expr().bind("index")), unless(hasAncestor(isImplicit()))) Finder->addMatcher(arraySubscriptExpr(hasBase(ignoringImpCasts(hasType( constantArrayType().bind("type")))), hasIndex(expr().bind("index")), unless(hasAncestor(decl(isImplicit())))) .bind("expr"), this); Loading clang/docs/LibASTMatchersReference.html +26 −2 Original line number Diff line number Diff line Loading @@ -582,6 +582,24 @@ Examples matches public virtual B. </pre></td></tr> <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>></td><td class="name" onclick="toggle('attr0')"><a name="attr0Anchor">attr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>>...</td></tr> <tr><td colspan="4" class="doc" id="attr0"><pre>Matches attributes. Attributes may be attached with a variety of different syntaxes (including keywords, C++11 attributes, GNU ``__attribute``` and MSVC `__declspec``, and ``#pragma``s). They may also be implicit. Given struct [[nodiscard]] Foo{}; void bar(int * __attribute__((nonnull)) ); __declspec(noinline) void baz(); #pragma omp declare simd int min(); attr() matches "nodiscard", "nonnull", "noinline", and the whole "#pragma" line. </pre></td></tr> <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('cxxCtorInitializer0')"><a name="cxxCtorInitializer0Anchor">cxxCtorInitializer</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>...</td></tr> <tr><td colspan="4" class="doc" id="cxxCtorInitializer0"><pre>Matches constructor initializers. Loading Loading @@ -2744,6 +2762,12 @@ Usable as: Any Matcher </pre></td></tr> <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>></td><td class="name" onclick="toggle('isImplicit1')"><a name="isImplicit1Anchor">isImplicit</a></td><td></td></tr> <tr><td colspan="4" class="doc" id="isImplicit1"><pre>Matches an entity that has been implicitly added by the compiler (e.g. implicit default/copy constructors). </pre></td></tr> <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('hasAnyOperatorName0')"><a name="hasAnyOperatorName0Anchor">hasAnyOperatorName</a></td><td>StringRef, ..., StringRef</td></tr> <tr><td colspan="4" class="doc" id="hasAnyOperatorName0"><pre>Matches operator expressions (binary or unary) that have any of the specified names. Loading Loading @@ -3808,8 +3832,8 @@ Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr> <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added by the compiler (eg. implicit default/copy constructors). <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches an entity that has been implicitly added by the compiler (e.g. implicit default/copy constructors). </pre></td></tr> Loading clang/include/clang/AST/ASTFwd.h +3 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,9 @@ class OMPClause; #define GEN_CLANG_CLAUSE_CLASS #define CLAUSE_CLASS(Enum, Str, Class) class Class; #include "llvm/Frontend/OpenMP/OMP.inc" class Attr; #define ATTR(A) class A##Attr; #include "clang/Basic/AttrList.inc" } // end namespace clang Loading clang/include/clang/AST/ASTTypeTraits.h +13 −3 Original line number Diff line number Diff line Loading @@ -25,10 +25,8 @@ #include "llvm/Support/AlignOf.h" namespace llvm { class raw_ostream; } } // namespace llvm namespace clang { Loading Loading @@ -66,6 +64,7 @@ public: static ASTNodeKind getFromNode(const Stmt &S); static ASTNodeKind getFromNode(const Type &T); static ASTNodeKind getFromNode(const OMPClause &C); static ASTNodeKind getFromNode(const Attr &A); /// \} /// Returns \c true if \c this and \c Other represent the same kind. Loading Loading @@ -152,6 +151,9 @@ private: #define GEN_CLANG_CLAUSE_CLASS #define CLAUSE_CLASS(Enum, Str, Class) NKI_##Class, #include "llvm/Frontend/OpenMP/OMP.inc" NKI_Attr, #define ATTR(A) NKI_##A##Attr, #include "clang/Basic/AttrList.inc" NKI_NumberOfKinds }; Loading Loading @@ -201,6 +203,7 @@ KIND_TO_KIND_ID(Decl) KIND_TO_KIND_ID(Stmt) KIND_TO_KIND_ID(Type) KIND_TO_KIND_ID(OMPClause) KIND_TO_KIND_ID(Attr) KIND_TO_KIND_ID(CXXBaseSpecifier) #define DECL(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Decl) #include "clang/AST/DeclNodes.inc" Loading @@ -211,6 +214,8 @@ KIND_TO_KIND_ID(CXXBaseSpecifier) #define GEN_CLANG_CLAUSE_CLASS #define CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class) #include "llvm/Frontend/OpenMP/OMP.inc" #define ATTR(A) KIND_TO_KIND_ID(A##Attr) #include "clang/Basic/AttrList.inc" #undef KIND_TO_KIND_ID inline raw_ostream &operator<<(raw_ostream &OS, ASTNodeKind K) { Loading Loading @@ -486,6 +491,11 @@ struct DynTypedNode::BaseConverter< T, std::enable_if_t<std::is_base_of<OMPClause, T>::value>> : public DynCastPtrConverter<T, OMPClause> {}; template <typename T> struct DynTypedNode::BaseConverter< T, std::enable_if_t<std::is_base_of<Attr, T>::value>> : public DynCastPtrConverter<T, Attr> {}; template <> struct DynTypedNode::BaseConverter< NestedNameSpecifier, void> : public PtrConverter<NestedNameSpecifier> {}; Loading Loading
clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -442,7 +442,7 @@ void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) { hasDeclaration(DeclMatcher), unless(templateSpecializationType()))))), hasParent(nestedNameSpecifierLoc()), hasAncestor(isImplicit()), hasAncestor(decl(isImplicit())), hasAncestor(UsingShadowDeclInClass), hasAncestor(functionDecl(isDefaulted())))), hasAncestor(decl().bind("dc"))) Loading @@ -466,7 +466,7 @@ void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) { hasAncestor(decl(IsInMovedNs).bind("dc")), loc(nestedNameSpecifier( specifiesType(hasDeclaration(DeclMatcher.bind("from_decl"))))), unless(anyOf(hasAncestor(isImplicit()), unless(anyOf(hasAncestor(decl(isImplicit())), hasAncestor(UsingShadowDeclInClass), hasAncestor(functionDecl(isDefaulted())), hasAncestor(typeLoc(loc(qualType(hasDeclaration( Loading Loading @@ -495,7 +495,7 @@ void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) { hasAncestor(cxxRecordDecl()))), hasParent(namespaceDecl())); Finder->addMatcher(expr(hasAncestor(decl().bind("dc")), IsInMovedNs, unless(hasAncestor(isImplicit())), unless(hasAncestor(decl(isImplicit()))), anyOf(callExpr(callee(FuncMatcher)).bind("call"), declRefExpr(to(FuncMatcher.bind("func_decl"))) .bind("func_ref"))), Loading
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -38,10 +38,10 @@ void ProBoundsConstantArrayIndexCheck::registerPPCallbacks( void ProBoundsConstantArrayIndexCheck::registerMatchers(MatchFinder *Finder) { // Note: if a struct contains an array member, the compiler-generated // constructor has an arraySubscriptExpr. Finder->addMatcher( arraySubscriptExpr( hasBase(ignoringImpCasts(hasType(constantArrayType().bind("type")))), hasIndex(expr().bind("index")), unless(hasAncestor(isImplicit()))) Finder->addMatcher(arraySubscriptExpr(hasBase(ignoringImpCasts(hasType( constantArrayType().bind("type")))), hasIndex(expr().bind("index")), unless(hasAncestor(decl(isImplicit())))) .bind("expr"), this); Loading
clang/docs/LibASTMatchersReference.html +26 −2 Original line number Diff line number Diff line Loading @@ -582,6 +582,24 @@ Examples matches public virtual B. </pre></td></tr> <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>></td><td class="name" onclick="toggle('attr0')"><a name="attr0Anchor">attr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>>...</td></tr> <tr><td colspan="4" class="doc" id="attr0"><pre>Matches attributes. Attributes may be attached with a variety of different syntaxes (including keywords, C++11 attributes, GNU ``__attribute``` and MSVC `__declspec``, and ``#pragma``s). They may also be implicit. Given struct [[nodiscard]] Foo{}; void bar(int * __attribute__((nonnull)) ); __declspec(noinline) void baz(); #pragma omp declare simd int min(); attr() matches "nodiscard", "nonnull", "noinline", and the whole "#pragma" line. </pre></td></tr> <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('cxxCtorInitializer0')"><a name="cxxCtorInitializer0Anchor">cxxCtorInitializer</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>...</td></tr> <tr><td colspan="4" class="doc" id="cxxCtorInitializer0"><pre>Matches constructor initializers. Loading Loading @@ -2744,6 +2762,12 @@ Usable as: Any Matcher </pre></td></tr> <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>></td><td class="name" onclick="toggle('isImplicit1')"><a name="isImplicit1Anchor">isImplicit</a></td><td></td></tr> <tr><td colspan="4" class="doc" id="isImplicit1"><pre>Matches an entity that has been implicitly added by the compiler (e.g. implicit default/copy constructors). </pre></td></tr> <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('hasAnyOperatorName0')"><a name="hasAnyOperatorName0Anchor">hasAnyOperatorName</a></td><td>StringRef, ..., StringRef</td></tr> <tr><td colspan="4" class="doc" id="hasAnyOperatorName0"><pre>Matches operator expressions (binary or unary) that have any of the specified names. Loading Loading @@ -3808,8 +3832,8 @@ Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr> <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added by the compiler (eg. implicit default/copy constructors). <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches an entity that has been implicitly added by the compiler (e.g. implicit default/copy constructors). </pre></td></tr> Loading
clang/include/clang/AST/ASTFwd.h +3 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,9 @@ class OMPClause; #define GEN_CLANG_CLAUSE_CLASS #define CLAUSE_CLASS(Enum, Str, Class) class Class; #include "llvm/Frontend/OpenMP/OMP.inc" class Attr; #define ATTR(A) class A##Attr; #include "clang/Basic/AttrList.inc" } // end namespace clang Loading
clang/include/clang/AST/ASTTypeTraits.h +13 −3 Original line number Diff line number Diff line Loading @@ -25,10 +25,8 @@ #include "llvm/Support/AlignOf.h" namespace llvm { class raw_ostream; } } // namespace llvm namespace clang { Loading Loading @@ -66,6 +64,7 @@ public: static ASTNodeKind getFromNode(const Stmt &S); static ASTNodeKind getFromNode(const Type &T); static ASTNodeKind getFromNode(const OMPClause &C); static ASTNodeKind getFromNode(const Attr &A); /// \} /// Returns \c true if \c this and \c Other represent the same kind. Loading Loading @@ -152,6 +151,9 @@ private: #define GEN_CLANG_CLAUSE_CLASS #define CLAUSE_CLASS(Enum, Str, Class) NKI_##Class, #include "llvm/Frontend/OpenMP/OMP.inc" NKI_Attr, #define ATTR(A) NKI_##A##Attr, #include "clang/Basic/AttrList.inc" NKI_NumberOfKinds }; Loading Loading @@ -201,6 +203,7 @@ KIND_TO_KIND_ID(Decl) KIND_TO_KIND_ID(Stmt) KIND_TO_KIND_ID(Type) KIND_TO_KIND_ID(OMPClause) KIND_TO_KIND_ID(Attr) KIND_TO_KIND_ID(CXXBaseSpecifier) #define DECL(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Decl) #include "clang/AST/DeclNodes.inc" Loading @@ -211,6 +214,8 @@ KIND_TO_KIND_ID(CXXBaseSpecifier) #define GEN_CLANG_CLAUSE_CLASS #define CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class) #include "llvm/Frontend/OpenMP/OMP.inc" #define ATTR(A) KIND_TO_KIND_ID(A##Attr) #include "clang/Basic/AttrList.inc" #undef KIND_TO_KIND_ID inline raw_ostream &operator<<(raw_ostream &OS, ASTNodeKind K) { Loading Loading @@ -486,6 +491,11 @@ struct DynTypedNode::BaseConverter< T, std::enable_if_t<std::is_base_of<OMPClause, T>::value>> : public DynCastPtrConverter<T, OMPClause> {}; template <typename T> struct DynTypedNode::BaseConverter< T, std::enable_if_t<std::is_base_of<Attr, T>::value>> : public DynCastPtrConverter<T, Attr> {}; template <> struct DynTypedNode::BaseConverter< NestedNameSpecifier, void> : public PtrConverter<NestedNameSpecifier> {}; Loading