strimo378 created this revision. strimo378 added a reviewer: aaron.ballman. Herald added a subscriber: martong. Herald added a reviewer: a.sidorin. Herald added a reviewer: shafik. Herald added a project: All. strimo378 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D158047 Files: clang/include/clang/ASTMatchers/ASTMatchers.h clang/lib/AST/ASTImporter.cpp clang/unittests/AST/ASTImporterTest.cpp Index: clang/unittests/AST/ASTImporterTest.cpp =================================================================== --- clang/unittests/AST/ASTImporterTest.cpp +++ clang/unittests/AST/ASTImporterTest.cpp @@ -583,6 +583,13 @@ functionDecl(hasDescendant(typedefDecl(has(atomicType()))))); } +TEST_P(ImportType, ImportBitIntType) { + MatchVerifier<Decl> Verifier; + testImport("void declToImport() { typedef _BitInt(10) bit_int; }", Lang_CXX11, + "", Lang_CXX11, Verifier, + functionDecl(hasDescendant(typedefDecl(has(bitIntType()))))); +} + TEST_P(ImportType, ImportUsingType) { MatchVerifier<Decl> Verifier; testImport("struct C {};" Index: clang/lib/AST/ASTImporter.cpp =================================================================== --- clang/lib/AST/ASTImporter.cpp +++ 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 //---------------------------------------------------------------------------- Index: clang/include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- clang/include/clang/ASTMatchers/ASTMatchers.h +++ 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> bitIntType; + /// Matches types nodes representing C++11 auto types. /// /// Given:
Index: clang/unittests/AST/ASTImporterTest.cpp =================================================================== --- clang/unittests/AST/ASTImporterTest.cpp +++ clang/unittests/AST/ASTImporterTest.cpp @@ -583,6 +583,13 @@ functionDecl(hasDescendant(typedefDecl(has(atomicType()))))); } +TEST_P(ImportType, ImportBitIntType) { + MatchVerifier<Decl> Verifier; + testImport("void declToImport() { typedef _BitInt(10) bit_int; }", Lang_CXX11, + "", Lang_CXX11, Verifier, + functionDecl(hasDescendant(typedefDecl(has(bitIntType()))))); +} + TEST_P(ImportType, ImportUsingType) { MatchVerifier<Decl> Verifier; testImport("struct C {};" Index: clang/lib/AST/ASTImporter.cpp =================================================================== --- clang/lib/AST/ASTImporter.cpp +++ 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 //---------------------------------------------------------------------------- Index: clang/include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- clang/include/clang/ASTMatchers/ASTMatchers.h +++ 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> bitIntType; + /// Matches types nodes representing C++11 auto types. /// /// Given:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits