]> granicus.if.org Git - clang/commitdiff
[ASTImporter] Remove import of definition from GetAlreadyImportedOrNull
authorGabor Marton <martongabesz@gmail.com>
Wed, 12 Dec 2018 11:22:55 +0000 (11:22 +0000)
committerGabor Marton <martongabesz@gmail.com>
Wed, 12 Dec 2018 11:22:55 +0000 (11:22 +0000)
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

include/clang/AST/ASTImporter.h
lib/AST/ASTImporter.cpp

index b292261bf80449345f081b508cb2d7a9dd1393fb..cbd5c3414bac61e23828dc10c22053e00dafd13a 100644 (file)
@@ -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.
index 633b2e48db4dde08bcfe6124989ef8e9468c55d3..90724241dbb2cfaa28d16c256243add121c43016 100644 (file)
@@ -1580,6 +1580,9 @@ Error ASTNodeImporter::ImportDeclParts(
     return Err;
 
   ToD = cast_or_null<NamedDecl>(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<Decl *, Decl *>::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<Decl *> ASTImporter::Import_New(Decl *FromD) {