]> granicus.if.org Git - clang/commitdiff
AST import of parenthesized expressions, unary operators, binary
authorDouglas Gregor <dgregor@apple.com>
Fri, 19 Feb 2010 01:07:06 +0000 (01:07 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 19 Feb 2010 01:07:06 +0000 (01:07 +0000)
operators, and compound assignment operators.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96643 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 69887bfc1c9ba60152d30f84698aa0e4b311a078..661adb82f25cb72e0da529b5e072da01c16d9038 100644 (file)
@@ -109,6 +109,10 @@ namespace {
     Expr *VisitExpr(Expr *E);
     Expr *VisitIntegerLiteral(IntegerLiteral *E);
     Expr *VisitCharacterLiteral(CharacterLiteral *E);
+    Expr *VisitParenExpr(ParenExpr *E);
+    Expr *VisitUnaryOperator(UnaryOperator *E);
+    Expr *VisitBinaryOperator(BinaryOperator *E);
+    Expr *VisitCompoundAssignOperator(CompoundAssignOperator *E);
     Expr *VisitImplicitCastExpr(ImplicitCastExpr *E);
   };
 }
@@ -2609,6 +2613,76 @@ Expr *ASTNodeImporter::VisitCharacterLiteral(CharacterLiteral *E) {
                                           Importer.Import(E->getLocation()));
 }
 
+Expr *ASTNodeImporter::VisitParenExpr(ParenExpr *E) {
+  Expr *SubExpr = Importer.Import(E->getSubExpr());
+  if (!SubExpr)
+    return 0;
+  
+  return new (Importer.getToContext()) 
+                                  ParenExpr(Importer.Import(E->getLParen()),
+                                            Importer.Import(E->getRParen()),
+                                            SubExpr);
+}
+
+Expr *ASTNodeImporter::VisitUnaryOperator(UnaryOperator *E) {
+  QualType T = Importer.Import(E->getType());
+  if (T.isNull())
+    return 0;
+
+  Expr *SubExpr = Importer.Import(E->getSubExpr());
+  if (!SubExpr)
+    return 0;
+  
+  return new (Importer.getToContext()) UnaryOperator(SubExpr, E->getOpcode(),
+                                                     T,
+                                         Importer.Import(E->getOperatorLoc()));                                        
+}
+
+Expr *ASTNodeImporter::VisitBinaryOperator(BinaryOperator *E) {
+  QualType T = Importer.Import(E->getType());
+  if (T.isNull())
+    return 0;
+
+  Expr *LHS = Importer.Import(E->getLHS());
+  if (!LHS)
+    return 0;
+  
+  Expr *RHS = Importer.Import(E->getRHS());
+  if (!RHS)
+    return 0;
+  
+  return new (Importer.getToContext()) BinaryOperator(LHS, RHS, E->getOpcode(),
+                                                      T,
+                                          Importer.Import(E->getOperatorLoc()));
+}
+
+Expr *ASTNodeImporter::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
+  QualType T = Importer.Import(E->getType());
+  if (T.isNull())
+    return 0;
+  
+  QualType CompLHSType = Importer.Import(E->getComputationLHSType());
+  if (CompLHSType.isNull())
+    return 0;
+  
+  QualType CompResultType = Importer.Import(E->getComputationResultType());
+  if (CompResultType.isNull())
+    return 0;
+  
+  Expr *LHS = Importer.Import(E->getLHS());
+  if (!LHS)
+    return 0;
+  
+  Expr *RHS = Importer.Import(E->getRHS());
+  if (!RHS)
+    return 0;
+  
+  return new (Importer.getToContext()) 
+                        CompoundAssignOperator(LHS, RHS, E->getOpcode(),
+                                               T, CompLHSType, CompResultType,
+                                          Importer.Import(E->getOperatorLoc()));
+}
+
 Expr *ASTNodeImporter::VisitImplicitCastExpr(ImplicitCastExpr *E) {
   QualType T = Importer.Import(E->getType());
   if (T.isNull())
index f9de8df7fd5ff9fc54557ce4137d4d74d573fe85..bc768879799d3d7cab6901515336d9d48255470a 100644 (file)
@@ -1,5 +1,7 @@
 // Matching
 enum E0 {
-  E0_Val0 = 'a'
+  E0_Val0 = 'a',
+  E0_Val1 = (17),
+  E0_Val2 = (1 << 2)
 };
 
index f9de8df7fd5ff9fc54557ce4137d4d74d573fe85..bc768879799d3d7cab6901515336d9d48255470a 100644 (file)
@@ -1,5 +1,7 @@
 // Matching
 enum E0 {
-  E0_Val0 = 'a'
+  E0_Val0 = 'a',
+  E0_Val1 = (17),
+  E0_Val2 = (1 << 2)
 };