diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -7025,6 +7025,16 @@ AST_TYPELOC_TRAVERSE_MATCHER_DECL(hasValueType, getValue, AST_POLYMORPHIC_SUPPORTED_TYPES(AtomicType)); +/// Matches bitint types. +/// +/// Given +/// \code +/// _BitInt(10) i; +/// \endcode +/// bitIntType() +/// matches "_BitInt(10) i" +extern const AstTypeMatcher bitIntType; + /// Matches types nodes representing C++11 auto types. /// /// Given: diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -419,6 +419,7 @@ ExpectedType VisitObjCInterfaceType(const ObjCInterfaceType *T); ExpectedType VisitObjCObjectType(const ObjCObjectType *T); ExpectedType VisitObjCObjectPointerType(const ObjCObjectPointerType *T); + ExpectedType VisitBitIntType(const BitIntType *T); // Importing declarations Error ImportDeclParts(NamedDecl *D, DeclarationName &Name, NamedDecl *&ToD, @@ -1701,6 +1702,11 @@ return Importer.getToContext().getObjCObjectPointerType(*ToPointeeTypeOrErr); } +ExpectedType clang::ASTNodeImporter::VisitBitIntType(const BitIntType *T) { + return Importer.getToContext().getBitIntType(T->isUnsigned(), + T->getNumBits()); +} + //---------------------------------------------------------------------------- // Import Declarations //---------------------------------------------------------------------------- diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -583,6 +583,13 @@ functionDecl(hasDescendant(typedefDecl(has(atomicType()))))); } +TEST_P(ImportType, ImportBitIntType) { + MatchVerifier Verifier; + testImport("void declToImport() { typedef _BitInt(10) bit_int; }", Lang_CXX11, + "", Lang_CXX11, Verifier, + functionDecl(hasDescendant(typedefDecl(has(bitIntType()))))); +} + TEST_P(ImportType, ImportUsingType) { MatchVerifier Verifier; testImport("struct C {};"