]> granicus.if.org Git - clang/commitdiff
[ASTImporter] Added ability to import AtomicType nodes
authorGabor Horvath <xazax.hun@gmail.com>
Wed, 23 Nov 2016 15:24:23 +0000 (15:24 +0000)
committerGabor Horvath <xazax.hun@gmail.com>
Wed, 23 Nov 2016 15:24:23 +0000 (15:24 +0000)
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

lib/AST/ASTImporter.cpp
unittests/AST/ASTImporterTest.cpp

index e783854448bbae76776fe4a0cc1253729986c262..1a7522db91ad31546e5950e1b904200ab3a4f275 100644 (file)
@@ -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) \
index 2255d7652c285ffd1546a571845f1a3c2befcb78..57b41f12b0bac7ee8e47c344d1d88dfd2511cc04 100644 (file)
@@ -474,5 +474,20 @@ TEST(ImportExpr, ImportVAArgExpr) {
 }
 
 
+TEST(ImportType, ImportAtomicType) {
+  MatchVerifier<Decl> 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