[PATCH] D49293: [ASTImporter] Add support for import of CXXInheritedCtorInitExpr.

Balázs Kéri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 13 06:59:38 PDT 2018


balazske created this revision.
Herald added subscribers: cfe-commits, martong.
Herald added a reviewer: a.sidorin.

Repository:
  rC Clang

https://reviews.llvm.org/D49293

Files:
  lib/AST/ASTImporter.cpp
  test/Import/inherited-ctor-init-expr/Inputs/A.cpp
  test/Import/inherited-ctor-init-expr/test.cpp


Index: test/Import/inherited-ctor-init-expr/test.cpp
===================================================================
--- /dev/null
+++ test/Import/inherited-ctor-init-expr/test.cpp
@@ -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;
+}
Index: test/Import/inherited-ctor-init-expr/Inputs/A.cpp
===================================================================
--- /dev/null
+++ test/Import/inherited-ctor-init-expr/Inputs/A.cpp
@@ -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) {}
+};
Index: lib/AST/ASTImporter.cpp
===================================================================
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -458,6 +458,7 @@
     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);
@@ -6731,6 +6732,22 @@
   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 = dyn_cast<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())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49293.155376.patch
Type: text/x-patch
Size: 2035 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180713/93698c06/attachment.bin>


More information about the cfe-commits mailing list