[PATCH] D60465: [ASTImporter] Error handling fix in ImportDefinition_New.

Balázs Kéri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 9 07:58:37 PDT 2019


balazske created this revision.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: martong.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.

ASTImporter::ImportDefinition_New contained a call to Import
that should be Import_New now. This is fixed now.


Repository:
  rC Clang

https://reviews.llvm.org/D60465

Files:
  lib/AST/ASTImporter.cpp


Index: lib/AST/ASTImporter.cpp
===================================================================
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -8382,45 +8382,48 @@
 }
 
 Error ASTImporter::ImportDefinition_New(Decl *From) {
-  Decl *To = Import(From);
-  if (!To)
-    return llvm::make_error<ImportError>();
+  Decl *To;
+  if (Error Err = importInto(To, From))
+    return Err;
 
-  auto *FromDC = cast<DeclContext>(From);
-  ASTNodeImporter Importer(*this);
+  if (auto *FromDC = cast<DeclContext>(From)) {
+    ASTNodeImporter Importer(*this);
 
-  if (auto *ToRecord = dyn_cast<RecordDecl>(To)) {
-    if (!ToRecord->getDefinition()) {
-      return Importer.ImportDefinition(
-          cast<RecordDecl>(FromDC), ToRecord,
-          ASTNodeImporter::IDK_Everything);
+    if (auto *ToRecord = dyn_cast<RecordDecl>(To)) {
+      if (!ToRecord->getDefinition()) {
+        return Importer.ImportDefinition(
+            cast<RecordDecl>(FromDC), ToRecord,
+            ASTNodeImporter::IDK_Everything);
+      }
     }
-  }
 
-  if (auto *ToEnum = dyn_cast<EnumDecl>(To)) {
-    if (!ToEnum->getDefinition()) {
-      return Importer.ImportDefinition(
-          cast<EnumDecl>(FromDC), ToEnum, ASTNodeImporter::IDK_Everything);
+    if (auto *ToEnum = dyn_cast<EnumDecl>(To)) {
+      if (!ToEnum->getDefinition()) {
+        return Importer.ImportDefinition(
+            cast<EnumDecl>(FromDC), ToEnum, ASTNodeImporter::IDK_Everything);
+      }
     }
-  }
 
-  if (auto *ToIFace = dyn_cast<ObjCInterfaceDecl>(To)) {
-    if (!ToIFace->getDefinition()) {
-      return Importer.ImportDefinition(
-          cast<ObjCInterfaceDecl>(FromDC), ToIFace,
-          ASTNodeImporter::IDK_Everything);
+    if (auto *ToIFace = dyn_cast<ObjCInterfaceDecl>(To)) {
+      if (!ToIFace->getDefinition()) {
+        return Importer.ImportDefinition(
+            cast<ObjCInterfaceDecl>(FromDC), ToIFace,
+            ASTNodeImporter::IDK_Everything);
+      }
     }
-  }
 
-  if (auto *ToProto = dyn_cast<ObjCProtocolDecl>(To)) {
-    if (!ToProto->getDefinition()) {
-      return Importer.ImportDefinition(
-          cast<ObjCProtocolDecl>(FromDC), ToProto,
-          ASTNodeImporter::IDK_Everything);
+    if (auto *ToProto = dyn_cast<ObjCProtocolDecl>(To)) {
+      if (!ToProto->getDefinition()) {
+        return Importer.ImportDefinition(
+            cast<ObjCProtocolDecl>(FromDC), ToProto,
+            ASTNodeImporter::IDK_Everything);
+      }
     }
+
+    return Importer.ImportDeclContext(FromDC, true);
   }
 
-  return Importer.ImportDeclContext(FromDC, true);
+  return Error::success();
 }
 
 void ASTImporter::ImportDefinition(Decl *From) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60465.194329.patch
Type: text/x-patch
Size: 2676 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190409/84765445/attachment.bin>


More information about the cfe-commits mailing list