]> granicus.if.org Git - clang/commitdiff
AST import for CStyleCastExpr. With this, we can import Cocoa.h into an empty context
authorDouglas Gregor <dgregor@apple.com>
Fri, 19 Feb 2010 01:32:14 +0000 (01:32 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 19 Feb 2010 01:32:14 +0000 (01:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96648 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTImporter.cpp
test/ASTMerge/Inputs/exprs1.c
test/ASTMerge/Inputs/exprs2.c

index 573bab7b23c34bc5cf131cff2d354fed2112bb3c..858c8aa650bec35dcd33c862172a53ca2ab43d5b 100644 (file)
@@ -116,6 +116,7 @@ namespace {
     Expr *VisitBinaryOperator(BinaryOperator *E);
     Expr *VisitCompoundAssignOperator(CompoundAssignOperator *E);
     Expr *VisitImplicitCastExpr(ImplicitCastExpr *E);
+    Expr *VisitCStyleCastExpr(CStyleCastExpr *E);
   };
 }
 
@@ -2747,6 +2748,25 @@ Expr *ASTNodeImporter::VisitImplicitCastExpr(ImplicitCastExpr *E) {
                                                         E->isLvalueCast());
 }
 
+Expr *ASTNodeImporter::VisitCStyleCastExpr(CStyleCastExpr *E) {
+  QualType T = Importer.Import(E->getType());
+  if (T.isNull())
+    return 0;
+  
+  Expr *SubExpr = Importer.Import(E->getSubExpr());
+  if (!SubExpr)
+    return 0;
+
+  TypeSourceInfo *TInfo = Importer.Import(E->getTypeInfoAsWritten());
+  if (!TInfo && E->getTypeInfoAsWritten())
+    return 0;
+  
+  return new (Importer.getToContext()) CStyleCastExpr(T, E->getCastKind(),
+                                                      SubExpr, TInfo,
+                                            Importer.Import(E->getLParenLoc()),
+                                            Importer.Import(E->getRParenLoc()));
+}
+
 ASTImporter::ASTImporter(Diagnostic &Diags,
                          ASTContext &ToContext, FileManager &ToFileManager,
                          ASTContext &FromContext, FileManager &FromFileManager)
index 42e06de60abbb5f2da9657fb6fdb5253d8e45741..1c268da15f3d3654d1f154d5767bacb15bfe04c1 100644 (file)
@@ -4,6 +4,7 @@ enum E0 {
   E0_Val1 = (17),
   E0_Val2 = (1 << 2),
   E0_Val3 = E0_Val2,
-  E0_Val4 = sizeof(int*)
+  E0_Val4 = sizeof(int*),
+  E0_Val5 = (unsigned int)-1
 };
 
index 42e06de60abbb5f2da9657fb6fdb5253d8e45741..1c268da15f3d3654d1f154d5767bacb15bfe04c1 100644 (file)
@@ -4,6 +4,7 @@ enum E0 {
   E0_Val1 = (17),
   E0_Val2 = (1 << 2),
   E0_Val3 = E0_Val2,
-  E0_Val4 = sizeof(int*)
+  E0_Val4 = sizeof(int*),
+  E0_Val5 = (unsigned int)-1
 };