diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index d730e3f6af51fe..7a3541442e4d57 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -4131,6 +4131,23 @@ AST_POLYMORPHIC_MATCHER_P( return Inner.matches(source->getTypeLoc(), Finder, Builder); } +/// Matches if the matched type is a Plain Old Data (POD) type. +/// +/// Given +/// \code +/// class Y +/// { +/// public: +/// int a; +/// std::string b; +/// }; +/// \endcode +/// fieldDecl(hasType(qualType(isPODType()))) +/// matches Y::a +AST_MATCHER(QualType, isPODType) { + return Node.isPODType(Finder->getASTContext()); +} + /// Matches if the matched type is represented by the given string. /// /// Given diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp index 6bf845c0c12582..72b6a061f56fb7 100644 --- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp +++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp @@ -379,6 +379,7 @@ RegistryMaps::RegistryMaps() { REGISTER_MATCHER(hasTypeLoc); REGISTER_MATCHER(hasUnaryOperand); REGISTER_MATCHER(hasUnarySelector); + REGISTER_MATCHER(isPODType); REGISTER_MATCHER(hasUnderlyingDecl); REGISTER_MATCHER(hasUnderlyingType); REGISTER_MATCHER(hasUnqualifiedDesugaredType);