From 5ac6d49065df82b7015fabb533e7a130b8e7f86f Mon Sep 17 00:00:00 2001 From: Gabor Marton Date: Wed, 15 May 2019 10:29:48 +0000 Subject: [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 --- .../Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp') diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 5212712b104..83cbe517643 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -272,9 +272,15 @@ static clang::QualType ExportAllDeclaredTypes( merger.AddSources(importer_source); clang::ASTImporter &exporter = merger.ImporterForOrigin(source); CompleteAllDeclContexts(exporter, file, root); - clang::QualType ret = exporter.Import(root); + llvm::Expected ret_or_error = exporter.Import(root); merger.RemoveSources(importer_source); - return ret; + if (ret_or_error) { + return *ret_or_error; + } else { + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS); + LLDB_LOG_ERROR(log, ret_or_error.takeError(), "Couldn't import type: {0}"); + return clang::QualType(); + } } TypeFromUser ClangExpressionDeclMap::DeportType(ClangASTContext &target, -- cgit v1.2.3