From: Gabor Marton Date: Wed, 12 Dec 2018 11:22:55 +0000 (+0000) Subject: [ASTImporter] Remove import of definition from GetAlreadyImportedOrNull X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=df55f5633e966afc4b3d5fc76e76f89ba4140b3c;p=clang [ASTImporter] Remove import of definition from GetAlreadyImportedOrNull Summary: a_sidorin Reviewers: a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D53755 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348923 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/ASTImporter.h b/include/clang/AST/ASTImporter.h index b292261bf8..cbd5c3414b 100644 --- a/include/clang/AST/ASTImporter.h +++ b/include/clang/AST/ASTImporter.h @@ -209,7 +209,7 @@ class Attr; /// Return the copy of the given declaration in the "to" context if /// it has already been imported from the "from" context. Otherwise return /// NULL. - Decl *GetAlreadyImportedOrNull(Decl *FromD); + Decl *GetAlreadyImportedOrNull(const Decl *FromD) const; /// Import the given declaration context from the "from" /// AST context into the "to" AST context. diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 633b2e48db..90724241db 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -1580,6 +1580,9 @@ Error ASTNodeImporter::ImportDeclParts( return Err; ToD = cast_or_null(Importer.GetAlreadyImportedOrNull(D)); + if (ToD) + if (Error Err = ASTNodeImporter(*this).ImportDefinitionIfNeeded(D, ToD)) + return Err; return Error::success(); } @@ -7745,17 +7748,12 @@ Attr *ASTImporter::Import(const Attr *FromAttr) { return ToAttr; } -Decl *ASTImporter::GetAlreadyImportedOrNull(Decl *FromD) { - llvm::DenseMap::iterator Pos = ImportedDecls.find(FromD); - if (Pos != ImportedDecls.end()) { - Decl *ToD = Pos->second; - // FIXME: move this call to ImportDeclParts(). - if (Error Err = ASTNodeImporter(*this).ImportDefinitionIfNeeded(FromD, ToD)) - llvm::consumeError(std::move(Err)); - return ToD; - } else { +Decl *ASTImporter::GetAlreadyImportedOrNull(const Decl *FromD) const { + auto Pos = ImportedDecls.find(FromD); + if (Pos != ImportedDecls.end()) + return Pos->second; + else return nullptr; - } } Expected ASTImporter::Import_New(Decl *FromD) {