[cfe-commits] r96647 - 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:24:24 PST 2010
Author: dgregor
Date: Thu Feb 18 19:24:23 2010
New Revision: 96647
URL: http://llvm.org/viewvc/llvm-project?rev=96647&view=rev
Log:
AST import for sizeof and alignof expressions
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=96647&r1=96646&r2=96647&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Thu Feb 18 19:24:23 2010
@@ -112,6 +112,7 @@
Expr *VisitCharacterLiteral(CharacterLiteral *E);
Expr *VisitParenExpr(ParenExpr *E);
Expr *VisitUnaryOperator(UnaryOperator *E);
+ Expr *VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E);
Expr *VisitBinaryOperator(BinaryOperator *E);
Expr *VisitCompoundAssignOperator(CompoundAssignOperator *E);
Expr *VisitImplicitCastExpr(ImplicitCastExpr *E);
@@ -2663,6 +2664,30 @@
Importer.Import(E->getOperatorLoc()));
}
+Expr *ASTNodeImporter::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) {
+ QualType ResultType = Importer.Import(E->getType());
+
+ if (E->isArgumentType()) {
+ TypeSourceInfo *TInfo = Importer.Import(E->getArgumentTypeInfo());
+ if (!TInfo)
+ return 0;
+
+ return new (Importer.getToContext()) SizeOfAlignOfExpr(E->isSizeOf(),
+ TInfo, ResultType,
+ Importer.Import(E->getOperatorLoc()),
+ Importer.Import(E->getRParenLoc()));
+ }
+
+ Expr *SubExpr = Importer.Import(E->getArgumentExpr());
+ if (!SubExpr)
+ return 0;
+
+ return new (Importer.getToContext()) SizeOfAlignOfExpr(E->isSizeOf(),
+ SubExpr, ResultType,
+ Importer.Import(E->getOperatorLoc()),
+ Importer.Import(E->getRParenLoc()));
+}
+
Expr *ASTNodeImporter::VisitBinaryOperator(BinaryOperator *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=96647&r1=96646&r2=96647&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/Inputs/exprs1.c (original)
+++ cfe/trunk/test/ASTMerge/Inputs/exprs1.c Thu Feb 18 19:24:23 2010
@@ -3,6 +3,7 @@
E0_Val0 = 'a',
E0_Val1 = (17),
E0_Val2 = (1 << 2),
- E0_Val3 = E0_Val2
+ E0_Val3 = E0_Val2,
+ E0_Val4 = sizeof(int*)
};
Modified: cfe/trunk/test/ASTMerge/Inputs/exprs2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/Inputs/exprs2.c?rev=96647&r1=96646&r2=96647&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/Inputs/exprs2.c (original)
+++ cfe/trunk/test/ASTMerge/Inputs/exprs2.c Thu Feb 18 19:24:23 2010
@@ -3,6 +3,7 @@
E0_Val0 = 'a',
E0_Val1 = (17),
E0_Val2 = (1 << 2),
- E0_Val3 = E0_Val2
+ E0_Val3 = E0_Val2,
+ E0_Val4 = sizeof(int*)
};
More information about the cfe-commits
mailing list