[ASTImporter] Make the Import() return value consistent with the map of imported...
authorRaphael Isemann <teemperor@gmail.com>
Tue, 24 Nov 2020 22:08:57 +0000 (23:08 +0100)
committerRaphael Isemann <teemperor@gmail.com>
Tue, 24 Nov 2020 22:46:18 +0000 (23:46 +0100)
commit0c926e6d245bec176bf2554a9f0bd48ef2276678
tree0f8965cb278081b4ee8b52c364922a5a2517fa54
parenta8dc2110cd4dd69212a204bc1074729f95d5402a
[ASTImporter] Make the Import() return value consistent with the map of imported decls when merging ClassTemplateSpecializationDecls

When importing a `ClassTemplateSpecializationDecl` definition into a TU with a matching
`ClassTemplateSpecializationDecl` definition and a more recent forward decl, the ASTImporter
currently will call `MapImported()` for the definitions, but will return the forward declaration
from the `ASTImporter::Import()` call.

This is triggering some assertions in LLDB when we try to fully import some DeclContexts
before we delete the 'From' AST. The returned 'To' Decl before this patch is just the most recent
forward decl but that's not the Decl with the definition to which the ASTImporter will import
the child declarations.

This patch just changes that the ASTImporter returns the definition that the imported Decl was
merged with instead of the found forward declaration.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D92016
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp