[ASTImporter] Use llvm::Expected and Error in the importer API
Summary:
This is the final phase of the refactoring towards using llvm::Expected
and llvm::Error in the ASTImporter API.
This involves the following:
- remove old Import functions which returned with a pointer,
- use the Import_New functions (which return with Err or Expected) everywhere
and handle their return value
- rename Import_New functions to Import
This affects both Clang and LLDB.
Reviewers: shafik, teemperor, aprantl, a_sidorin, balazske, a.sidorin
Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits, lldb-commits
Tags: #clang, #lldb
Differential Revision: https://reviews.llvm.org/D61438
llvm-svn: 360760
diff --git a/clang/lib/AST/ExternalASTMerger.cpp b/clang/lib/AST/ExternalASTMerger.cpp
index 0075247..61e657d 100644
--- a/clang/lib/AST/ExternalASTMerger.cpp
+++ b/clang/lib/AST/ExternalASTMerger.cpp
@@ -56,7 +56,7 @@
}
auto *ND = cast<NamedDecl>(DC);
DeclarationName Name = ND->getDeclName();
- auto SourceNameOrErr = ReverseImporter.Import_New(Name);
+ auto SourceNameOrErr = ReverseImporter.Import(Name);
if (!SourceNameOrErr) {
llvm::consumeError(SourceNameOrErr.takeError());
return nullptr;
@@ -233,7 +233,7 @@
if (!SourceTag->getDefinition())
return false;
Forward.MapImported(SourceTag, Tag);
- if (llvm::Error Err = Forward.ImportDefinition_New(SourceTag))
+ if (llvm::Error Err = Forward.ImportDefinition(SourceTag))
llvm::consumeError(std::move(Err));
Tag->setCompleteDefinition(SourceTag->isCompleteDefinition());
return true;
@@ -253,7 +253,7 @@
if (!SourceInterface->getDefinition())
return false;
Forward.MapImported(SourceInterface, Interface);
- if (llvm::Error Err = Forward.ImportDefinition_New(SourceInterface))
+ if (llvm::Error Err = Forward.ImportDefinition(SourceInterface))
llvm::consumeError(std::move(Err));
return true;
});
@@ -360,7 +360,7 @@
template <typename DeclTy>
static bool importSpecializations(DeclTy *D, ASTImporter *Importer) {
for (auto *Spec : D->specializations()) {
- auto ImportedSpecOrError = Importer->Import_New(Spec);
+ auto ImportedSpecOrError = Importer->Import(Spec);
if (!ImportedSpecOrError) {
llvm::consumeError(ImportedSpecOrError.takeError());
return true;
@@ -395,7 +395,7 @@
ForEachMatchingDC(DC,
[&](ASTImporter &Forward, ASTImporter &Reverse,
Source<const DeclContext *> SourceDC) -> bool {
- auto FromNameOrErr = Reverse.Import_New(Name);
+ auto FromNameOrErr = Reverse.Import(Name);
if (!FromNameOrErr) {
llvm::consumeError(FromNameOrErr.takeError());
return false;
@@ -415,7 +415,7 @@
for (const Candidate &C : Candidates) {
Decl *LookupRes = C.first.get();
ASTImporter *Importer = C.second;
- auto NDOrErr = Importer->Import_New(LookupRes);
+ auto NDOrErr = Importer->Import(LookupRes);
assert(NDOrErr);
(void)static_cast<bool>(NDOrErr);
NamedDecl *ND = cast_or_null<NamedDecl>(*NDOrErr);
@@ -440,7 +440,7 @@
Source<const DeclContext *> SourceDC) -> bool {
for (const Decl *SourceDecl : SourceDC.get()->decls()) {
if (IsKindWeWant(SourceDecl->getKind())) {
- auto ImportedDeclOrErr = Forward.Import_New(SourceDecl);
+ auto ImportedDeclOrErr = Forward.Import(SourceDecl);
if (ImportedDeclOrErr)
assert(!(*ImportedDeclOrErr) ||
IsSameDC((*ImportedDeclOrErr)->getDeclContext(), DC));