[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/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 4d25bf3..72a3373 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -1415,7 +1415,14 @@
FileManager file_manager(file_system_options);
ASTImporter importer(*dst_ast, file_manager, *src_ast, file_manager, false);
- return importer.Import(source_decl);
+ if (llvm::Expected<clang::Decl *> ret_or_error =
+ importer.Import(source_decl)) {
+ return *ret_or_error;
+ } else {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+ LLDB_LOG_ERROR(log, ret_or_error.takeError(), "Couldn't import decl: {0}");
+ return nullptr;
+ }
}
bool ClangASTContext::AreTypesSame(CompilerType type1, CompilerType type2,