Author: balazske Date: Wed Jul 25 03:21:06 2018 New Revision: 337898 URL: http://llvm.org/viewvc/llvm-project?rev=337898&view=rev Log: [ASTImporter] Add support for import of CXXInheritedCtorInitExpr.
Reviewers: a.sidorin, martong Reviewed By: martong Subscribers: rnkovacs, a_sidorin, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D49293 Added: cfe/trunk/test/Import/inherited-ctor-init-expr/ cfe/trunk/test/Import/inherited-ctor-init-expr/Inputs/ cfe/trunk/test/Import/inherited-ctor-init-expr/Inputs/A.cpp cfe/trunk/test/Import/inherited-ctor-init-expr/test.cpp Modified: cfe/trunk/lib/AST/ASTImporter.cpp Modified: cfe/trunk/lib/AST/ASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=337898&r1=337897&r2=337898&view=diff ============================================================================== --- cfe/trunk/lib/AST/ASTImporter.cpp (original) +++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Jul 25 03:21:06 2018 @@ -460,6 +460,7 @@ namespace clang { Expr *VisitLambdaExpr(LambdaExpr *LE); Expr *VisitInitListExpr(InitListExpr *E); Expr *VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E); + Expr *VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E); Expr *VisitArrayInitLoopExpr(ArrayInitLoopExpr *E); Expr *VisitArrayInitIndexExpr(ArrayInitIndexExpr *E); Expr *VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E); @@ -6772,6 +6773,22 @@ Expr *ASTNodeImporter::VisitCXXStdInitia return new (Importer.getToContext()) CXXStdInitializerListExpr(T, SE); } +Expr *ASTNodeImporter::VisitCXXInheritedCtorInitExpr( + CXXInheritedCtorInitExpr *E) { + QualType T = Importer.Import(E->getType()); + if (T.isNull()) + return nullptr; + + auto *Ctor = cast_or_null<CXXConstructorDecl>(Importer.Import( + E->getConstructor())); + if (!Ctor) + return nullptr; + + return new (Importer.getToContext()) CXXInheritedCtorInitExpr( + Importer.Import(E->getLocation()), T, Ctor, + E->constructsVBase(), E->inheritedFromVBase()); +} + Expr *ASTNodeImporter::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) { QualType ToType = Importer.Import(E->getType()); if (ToType.isNull()) Added: cfe/trunk/test/Import/inherited-ctor-init-expr/Inputs/A.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/inherited-ctor-init-expr/Inputs/A.cpp?rev=337898&view=auto ============================================================================== --- cfe/trunk/test/Import/inherited-ctor-init-expr/Inputs/A.cpp (added) +++ cfe/trunk/test/Import/inherited-ctor-init-expr/Inputs/A.cpp Wed Jul 25 03:21:06 2018 @@ -0,0 +1,11 @@ +class A { +public: + A(int a) : a(a) {} + int a; +}; +class B : public A { + using A::A; +}; +class C : public B { + C() : B(1) {} +}; Added: cfe/trunk/test/Import/inherited-ctor-init-expr/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/inherited-ctor-init-expr/test.cpp?rev=337898&view=auto ============================================================================== --- cfe/trunk/test/Import/inherited-ctor-init-expr/test.cpp (added) +++ cfe/trunk/test/Import/inherited-ctor-init-expr/test.cpp Wed Jul 25 03:21:06 2018 @@ -0,0 +1,6 @@ +// RUN: clang-import-test -dump-ast -expression=%s -import=%S/Inputs/A.cpp | FileCheck %s +// CHECK: | | | `-CXXInheritedCtorInitExpr + +void foo() { + C c; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits