[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/CxxModuleHandler.cpp b/lldb/source/Symbol/CxxModuleHandler.cpp
index 3f97672..68a2aab 100644
--- a/lldb/source/Symbol/CxxModuleHandler.cpp
+++ b/lldb/source/Symbol/CxxModuleHandler.cpp
@@ -9,6 +9,7 @@
#include "lldb/Symbol/CxxModuleHandler.h"
#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Utility/Log.h"
#include "clang/Sema/Lookup.h"
#include "llvm/Support/Error.h"
@@ -214,13 +215,15 @@
// Import the foreign template arguments.
llvm::SmallVector<TemplateArgument, 4> imported_args;
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+
// If this logic is changed, also update templateArgsAreSupported.
for (const TemplateArgument &arg : foreign_args.asArray()) {
switch (arg.getKind()) {
case TemplateArgument::Type: {
- llvm::Expected<QualType> type = m_importer->Import_New(arg.getAsType());
+ llvm::Expected<QualType> type = m_importer->Import(arg.getAsType());
if (!type) {
- llvm::consumeError(type.takeError());
+ LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
return {};
}
imported_args.push_back(TemplateArgument(*type));
@@ -229,9 +232,9 @@
case TemplateArgument::Integral: {
llvm::APSInt integral = arg.getAsIntegral();
llvm::Expected<QualType> type =
- m_importer->Import_New(arg.getIntegralType());
+ m_importer->Import(arg.getIntegralType());
if (!type) {
- llvm::consumeError(type.takeError());
+ LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
return {};
}
imported_args.push_back(