diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 304ad2e1ee51..573bab7b23c3 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -112,6 +112,7 @@ namespace { 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 @@ Expr *ASTNodeImporter::VisitUnaryOperator(UnaryOperator *E) { 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()) diff --git a/clang/test/ASTMerge/Inputs/exprs1.c b/clang/test/ASTMerge/Inputs/exprs1.c index 03150a9e377e..42e06de60abb 100644 --- a/clang/test/ASTMerge/Inputs/exprs1.c +++ b/clang/test/ASTMerge/Inputs/exprs1.c @@ -3,6 +3,7 @@ enum E0 { E0_Val0 = 'a', E0_Val1 = (17), E0_Val2 = (1 << 2), - E0_Val3 = E0_Val2 + E0_Val3 = E0_Val2, + E0_Val4 = sizeof(int*) }; diff --git a/clang/test/ASTMerge/Inputs/exprs2.c b/clang/test/ASTMerge/Inputs/exprs2.c index 03150a9e377e..42e06de60abb 100644 --- a/clang/test/ASTMerge/Inputs/exprs2.c +++ b/clang/test/ASTMerge/Inputs/exprs2.c @@ -3,6 +3,7 @@ enum E0 { E0_Val0 = 'a', E0_Val1 = (17), E0_Val2 = (1 << 2), - E0_Val3 = E0_Val2 + E0_Val3 = E0_Val2, + E0_Val4 = sizeof(int*) };