diff options
author | Balazs Keri <1.int32@gmail.com> | 2019-04-08 13:59:15 +0000 |
---|---|---|
committer | Balazs Keri <1.int32@gmail.com> | 2019-04-08 13:59:15 +0000 |
commit | 36e125b91f9f7164da78ff053dff229558699a35 (patch) | |
tree | 75b3896fe3b169543b51c132f8834ecdeb328eb0 /lib/CrossTU/CrossTranslationUnit.cpp | |
parent | 9a63380260860b657b72f07c4f0e61e382ab934a (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@357913 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CrossTU/CrossTranslationUnit.cpp')
-rw-r--r-- | lib/CrossTU/CrossTranslationUnit.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/CrossTU/CrossTranslationUnit.cpp b/lib/CrossTU/CrossTranslationUnit.cpp index 04c98545ae..3e787419aa 100644 --- a/lib/CrossTU/CrossTranslationUnit.cpp +++ b/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; } |