[PATCH] D158047: [clang][ASTImporter] Add import of 'BitIntType'
Timo Stripf via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 15 19:59:00 PDT 2023
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:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158047.550581.patch
Type: text/x-patch
Size: 2409 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230816/a8b947a8/attachment.bin>
More information about the cfe-commits
mailing list