JonasToth created this revision. JonasToth added reviewers: aaron.ballman, alexfh, NoQ, dcoughlin. Herald added a subscriber: cfe-commits.
This patch introduces a new matcher for `DecltypeType` and its underlying type in order to fix a bug in clang-tidy, see https://reviews.llvm.org/D48717 for more. Repository: rC Clang https://reviews.llvm.org/D48759 Files: include/clang/ASTMatchers/ASTMatchers.h lib/ASTMatchers/ASTMatchersInternal.cpp lib/ASTMatchers/Dynamic/Registry.cpp Index: lib/ASTMatchers/Dynamic/Registry.cpp =================================================================== --- lib/ASTMatchers/Dynamic/Registry.cpp +++ lib/ASTMatchers/Dynamic/Registry.cpp @@ -134,6 +134,7 @@ REGISTER_MATCHER(atomicExpr); REGISTER_MATCHER(atomicType); REGISTER_MATCHER(autoType); + REGISTER_MATCHER(decltypeType); REGISTER_MATCHER(binaryOperator); REGISTER_MATCHER(binaryConditionalOperator); REGISTER_MATCHER(blockDecl); Index: lib/ASTMatchers/ASTMatchersInternal.cpp =================================================================== --- lib/ASTMatchers/ASTMatchersInternal.cpp +++ lib/ASTMatchers/ASTMatchersInternal.cpp @@ -798,6 +798,7 @@ const AstTypeMatcher<VariableArrayType> variableArrayType; const AstTypeMatcher<AtomicType> atomicType; const AstTypeMatcher<AutoType> autoType; +const AstTypeMatcher<DecltypeType> decltypeType; const AstTypeMatcher<FunctionType> functionType; const AstTypeMatcher<FunctionProtoType> functionProtoType; const AstTypeMatcher<ParenType> parenType; Index: include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- include/clang/ASTMatchers/ASTMatchers.h +++ include/clang/ASTMatchers/ASTMatchers.h @@ -5063,6 +5063,18 @@ /// matches "auto n" and "auto i" extern const AstTypeMatcher<AutoType> autoType; +/// Matches types nodes representing C++11 decltype(<expr>) types. +/// +/// Given: +/// \code +/// short i = 1; +/// int j = 42; +/// decltype(i + j) result = i + j; +/// \endcode +/// decltypeType() +/// matches "decltype(i + j)" +extern const AstTypeMatcher<DecltypeType> decltypeType; + /// Matches \c AutoType nodes where the deduced type is a specific type. /// /// Note: There is no \c TypeLoc for the deduced type and thus no @@ -5080,6 +5092,10 @@ AST_TYPE_TRAVERSE_MATCHER(hasDeducedType, getDeducedType, AST_POLYMORPHIC_SUPPORTED_TYPES(AutoType)); +/// Matches \c DecltypeType nodes to find out the underlying type. +AST_TYPE_TRAVERSE_MATCHER(hasUnderlyingType, getUnderlyingType, + AST_POLYMORPHIC_SUPPORTED_TYPES(DecltypeType)); + /// Matches \c FunctionType nodes. /// /// Given
Index: lib/ASTMatchers/Dynamic/Registry.cpp =================================================================== --- lib/ASTMatchers/Dynamic/Registry.cpp +++ lib/ASTMatchers/Dynamic/Registry.cpp @@ -134,6 +134,7 @@ REGISTER_MATCHER(atomicExpr); REGISTER_MATCHER(atomicType); REGISTER_MATCHER(autoType); + REGISTER_MATCHER(decltypeType); REGISTER_MATCHER(binaryOperator); REGISTER_MATCHER(binaryConditionalOperator); REGISTER_MATCHER(blockDecl); Index: lib/ASTMatchers/ASTMatchersInternal.cpp =================================================================== --- lib/ASTMatchers/ASTMatchersInternal.cpp +++ lib/ASTMatchers/ASTMatchersInternal.cpp @@ -798,6 +798,7 @@ const AstTypeMatcher<VariableArrayType> variableArrayType; const AstTypeMatcher<AtomicType> atomicType; const AstTypeMatcher<AutoType> autoType; +const AstTypeMatcher<DecltypeType> decltypeType; const AstTypeMatcher<FunctionType> functionType; const AstTypeMatcher<FunctionProtoType> functionProtoType; const AstTypeMatcher<ParenType> parenType; Index: include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- include/clang/ASTMatchers/ASTMatchers.h +++ include/clang/ASTMatchers/ASTMatchers.h @@ -5063,6 +5063,18 @@ /// matches "auto n" and "auto i" extern const AstTypeMatcher<AutoType> autoType; +/// Matches types nodes representing C++11 decltype(<expr>) types. +/// +/// Given: +/// \code +/// short i = 1; +/// int j = 42; +/// decltype(i + j) result = i + j; +/// \endcode +/// decltypeType() +/// matches "decltype(i + j)" +extern const AstTypeMatcher<DecltypeType> decltypeType; + /// Matches \c AutoType nodes where the deduced type is a specific type. /// /// Note: There is no \c TypeLoc for the deduced type and thus no @@ -5080,6 +5092,10 @@ AST_TYPE_TRAVERSE_MATCHER(hasDeducedType, getDeducedType, AST_POLYMORPHIC_SUPPORTED_TYPES(AutoType)); +/// Matches \c DecltypeType nodes to find out the underlying type. +AST_TYPE_TRAVERSE_MATCHER(hasUnderlyingType, getUnderlyingType, + AST_POLYMORPHIC_SUPPORTED_TYPES(DecltypeType)); + /// Matches \c FunctionType nodes. /// /// Given
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits