summaryrefslogtreecommitdiffstats
path: root/clang/lib/CrossTU
diff options
context:
space:
mode:
authorBalazs Keri <1.int32@gmail.com>2019-04-08 13:59:15 +0000
committerBalazs Keri <1.int32@gmail.com>2019-04-08 13:59:15 +0000
commita1f6b103f3964bcdf434e2c45428b4f097454cb6 (patch)
tree7fb055f9aa20b8398ca415a2be022692311ada1c /clang/lib/CrossTU
parent50c3b290ed8749b568439908adcfca85df33535d (diff)
downloadbcm5719-llvm-a1f6b103f3964bcdf434e2c45428b4f097454cb6.tar.gz
bcm5719-llvm-a1f6b103f3964bcdf434e2c45428b4f097454cb6.zip
Changed every use of ASTImporter::Import to Import_New
Reviewers: a.sidorin, shafik, martong, a_sidorin Reviewed By: a_sidorin Subscribers: rnkovacs, dkrupp, martong, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D55049 llvm-svn: 357913
Diffstat (limited to 'clang/lib/CrossTU')
-rw-r--r--clang/lib/CrossTU/CrossTranslationUnit.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index 04c98545ae5..3e787419aa4 100644
--- a/clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -357,13 +357,28 @@ CrossTranslationUnitContext::importDefinition(const FunctionDecl *FD) {
assert(FD->hasBody() && "Functions to be imported should have body.");
ASTImporter &Importer = getOrCreateASTImporter(FD->getASTContext());
- auto *ToDecl =
- cast_or_null<FunctionDecl>(Importer.Import(const_cast<FunctionDecl *>(FD)));
- if (!ToDecl)
+ auto ToDeclOrError = Importer.Import_New(FD);
+ if (!ToDeclOrError) {
+ handleAllErrors(ToDeclOrError.takeError(),
+ [&](const ImportError &IE) {
+ switch (IE.Error) {
+ case ImportError::NameConflict:
+ // FIXME: Add statistic.
+ break;
+ case ImportError::UnsupportedConstruct:
+ // FIXME: Add statistic.
+ break;
+ case ImportError::Unknown:
+ llvm_unreachable("Unknown import error happened.");
+ break;
+ }
+ });
return llvm::make_error<IndexError>(index_error_code::failed_import);
- assert(ToDecl->hasBody());
- assert(FD->hasBody() && "Functions already imported should have body.");
+ }
+ auto *ToDecl = cast<FunctionDecl>(*ToDeclOrError);
+ assert(ToDecl->hasBody() && "Imported function should have body.");
++NumGetCTUSuccess;
+
return ToDecl;
}
OpenPOWER on IntegriCloud