[lldb] Fix another crash in covariant type handling
authorPavel Labath <pavel@labath.sk>
Thu, 26 Mar 2020 12:23:51 +0000 (13:23 +0100)
committerPavel Labath <pavel@labath.sk>
Mon, 30 Mar 2020 14:00:21 +0000 (16:00 +0200)
commit7b00eeb53de06c7979fd2a88436c3387d0492ee8
tree8ab11788f57a32a119eca2b5bc48be92f8279b0f
parent135709aa9013565b9d02000bb0ca744f7585e6a5
[lldb] Fix another crash in covariant type handling

Summary:
D73024 seems to have fixed one set crash, but it introduced another.
Namely, if a class contains a covariant method returning itself, the
logic in MaybeCompleteReturnType could cause us to attempt a recursive
import, which would result in an assertion failure in
clang::DeclContext::removeDecl.

For some reason, this only manifested itself if the class contained at
least two member variables, and the class itself was imported as a
result of a recursive covariant import.

This patch fixes the crash by not attempting to import classes which are
already completed in MaybeCompleteReturnType. However, it's not clear to
me if this is the right fix, or if this should be handled automatically
by functions lower in the stack.

Reviewers: teemperor, shafik

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76840
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
lldb/test/API/lang/cpp/covariant-return-types/TestCovariantReturnTypes.py
lldb/test/API/lang/cpp/covariant-return-types/main.cpp