Index: include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- include/clang/ASTMatchers/ASTMatchers.h +++ include/clang/ASTMatchers/ASTMatchers.h @@ -167,6 +167,21 @@ /// matches "typedef int X" const internal::VariadicDynCastAllOfMatcher typedefDecl; +/// \brief Matches the underlying type of a typedef declaration +/// +/// Given +/// \code +/// typedef int X; +/// typedef float Y; +/// \endcode +/// typedefDecl(hasUnderlyingType(asString("int"))) +/// matches "typedef int X" +AST_MATCHER_P(TypedefDecl, hasUnderlyingType, internal::Matcher, + InnerMatcher) { + QualType UnderlyingType = Node.getUnderlyingType(); + return InnerMatcher.matches(UnderlyingType, Finder, Builder); +} + /// \brief Matches AST nodes that were expanded within the main-file. /// /// Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile()) Index: lib/ASTMatchers/Dynamic/Registry.cpp =================================================================== --- lib/ASTMatchers/Dynamic/Registry.cpp +++ lib/ASTMatchers/Dynamic/Registry.cpp @@ -223,6 +223,7 @@ REGISTER_MATCHER(hasTrueExpression); REGISTER_MATCHER(hasTypeLoc); REGISTER_MATCHER(hasUnaryOperand); + REGISTER_MATCHER(hasUnderlyingType); REGISTER_MATCHER(hasValueType); REGISTER_MATCHER(ifStmt); REGISTER_MATCHER(ignoringImpCasts);