[cfe-commits] r96643 - in /cfe/trunk: lib/AST/ASTImporter.cpp test/ASTMerge/Inputs/exprs1.c test/ASTMerge/Inputs/exprs2.c
Douglas Gregor
dgregor at apple.com
Thu Feb 18 17:07:06 PST 2010
Author: dgregor
Date: Thu Feb 18 19:07:06 2010
New Revision: 96643
URL: http://llvm.org/viewvc/llvm-project?rev=96643&view=rev
Log:
AST import of parenthesized expressions, unary operators, binary
operators, and compound assignment operators.
Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/test/ASTMerge/Inputs/exprs1.c
cfe/trunk/test/ASTMerge/Inputs/exprs2.c
Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=96643&r1=96642&r2=96643&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Thu Feb 18 19:07:06 2010
@@ -109,6 +109,10 @@
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 @@
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())
Modified: cfe/trunk/test/ASTMerge/Inputs/exprs1.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/Inputs/exprs1.c?rev=96643&r1=96642&r2=96643&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/Inputs/exprs1.c (original)
+++ cfe/trunk/test/ASTMerge/Inputs/exprs1.c Thu Feb 18 19:07:06 2010
@@ -1,5 +1,7 @@
// Matching
enum E0 {
- E0_Val0 = 'a'
+ E0_Val0 = 'a',
+ E0_Val1 = (17),
+ E0_Val2 = (1 << 2)
};
Modified: cfe/trunk/test/ASTMerge/Inputs/exprs2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/Inputs/exprs2.c?rev=96643&r1=96642&r2=96643&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/Inputs/exprs2.c (original)
+++ cfe/trunk/test/ASTMerge/Inputs/exprs2.c Thu Feb 18 19:07:06 2010
@@ -1,5 +1,7 @@
// Matching
enum E0 {
- E0_Val0 = 'a'
+ E0_Val0 = 'a',
+ E0_Val1 = (17),
+ E0_Val2 = (1 << 2)
};
More information about the cfe-commits
mailing list