[ASTImporter] Added error handling for AST import.
Summary:
The goal of this change is to make the ASTImporter::Import functions return
llvm::Expected instead of the imported type.
As first part the ASTNodeImporter visit functions are updated to return with
llvm::Expected. Various `import` functions are added to ASTNodeImporter to
simplify the code and have a common place for interface towards ASTImporter
(from ASTNodeImporter). There is some temporary code that is needed before
ASTImporter is updated.
Reviewers: a.sidorin, a_sidorin, xazax.hun
Reviewed By: a_sidorin
Subscribers: dkrupp, Szelethus, rnkovacs, martong, jfb, cfe-commits
Differential Revision: https://reviews.llvm.org/D51633
llvm-svn: 344783
diff --git a/clang/lib/AST/ExternalASTMerger.cpp b/clang/lib/AST/ExternalASTMerger.cpp
index ae28c58..e7ca3ac 100644
--- a/clang/lib/AST/ExternalASTMerger.cpp
+++ b/clang/lib/AST/ExternalASTMerger.cpp
@@ -230,7 +230,8 @@
if (!SourceTag->getDefinition())
return false;
Forward.MapImported(SourceTag, Tag);
- Forward.ImportDefinition(SourceTag);
+ if (llvm::Error Err = Forward.ImportDefinition_New(SourceTag))
+ llvm::consumeError(std::move(Err));
Tag->setCompleteDefinition(SourceTag->isCompleteDefinition());
return true;
});
@@ -249,7 +250,8 @@
if (!SourceInterface->getDefinition())
return false;
Forward.MapImported(SourceInterface, Interface);
- Forward.ImportDefinition(SourceInterface);
+ if (llvm::Error Err = Forward.ImportDefinition_New(SourceInterface))
+ llvm::consumeError(std::move(Err));
return true;
});
}