From: Gabor Horvath Date: Wed, 23 Nov 2016 15:24:23 +0000 (+0000) Subject: [ASTImporter] Added ability to import AtomicType nodes X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2e60df097d8baa9d0ca441e7fd2ff72d4fecd5d3;p=clang [ASTImporter] Added ability to import AtomicType nodes Patch by: Kareem Khazem Differential Revision: https://reviews.llvm.org/D26328 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@287763 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index e783854448..1a7522db91 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -39,6 +39,7 @@ namespace clang { // Importing types QualType VisitType(const Type *T); + QualType VisitAtomicType(const AtomicType *T); QualType VisitBuiltinType(const BuiltinType *T); QualType VisitDecayedType(const DecayedType *T); QualType VisitComplexType(const ComplexType *T); @@ -1600,6 +1601,14 @@ QualType ASTNodeImporter::VisitType(const Type *T) { return QualType(); } +QualType ASTNodeImporter::VisitAtomicType(const AtomicType *T){ + QualType UnderlyingType = Importer.Import(T->getValueType()); + if(UnderlyingType.isNull()) + return QualType(); + + return Importer.getToContext().getAtomicType(UnderlyingType); +} + QualType ASTNodeImporter::VisitBuiltinType(const BuiltinType *T) { switch (T->getKind()) { #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ diff --git a/unittests/AST/ASTImporterTest.cpp b/unittests/AST/ASTImporterTest.cpp index 2255d7652c..57b41f12b0 100644 --- a/unittests/AST/ASTImporterTest.cpp +++ b/unittests/AST/ASTImporterTest.cpp @@ -474,5 +474,20 @@ TEST(ImportExpr, ImportVAArgExpr) { } +TEST(ImportType, ImportAtomicType) { + MatchVerifier Verifier; + EXPECT_TRUE(testImport("void declToImport() { typedef _Atomic(int) a_int; }", + Lang_CXX11, "", Lang_CXX11, Verifier, + functionDecl( + hasBody( + compoundStmt( + has( + declStmt( + has( + typedefDecl( + has(atomicType())))))))))); +} + + } // end namespace ast_matchers } // end namespace clang