forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lldb] Fix crash when adding members to an "incomplete" type (llvm#10…
…2116) This fixes a regression caused by delayed type definition searching (llvm#96755 and friends): If we end up adding a member (e.g. a typedef) to a type that we've already attempted to complete (and failed), the resulting AST would end up inconsistent (we would start to "forcibly" complete it, but never finish it), and importing it into an expression AST would crash. This patch fixes this by detecting the situation and finishing the definition as well. (cherry picked from commit 57cd100)
- Loading branch information
Showing
2 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
lldb/test/Shell/SymbolFile/DWARF/x86/typedef-in-incomplete-type.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// RUN: %clangxx --target=x86_64-pc-linux -flimit-debug-info -o %t -c %s -g | ||
// RUN: %lldb %t -o "target var a" -o "expr -- var" -o exit | FileCheck %s | ||
|
||
// This forces lldb to attempt to complete the type A. Since it has no | ||
// definition it will fail. | ||
// CHECK: target var a | ||
// CHECK: (A) a = <incomplete type "A"> | ||
|
||
// Now attempt to display the second variable, which will try to add a typedef | ||
// to the incomplete type. Make sure that succeeds. Use the expression command | ||
// to make sure the resulting AST can be imported correctly. | ||
// CHECK: expr -- var | ||
// CHECK: (A::X) $0 = 0 | ||
|
||
struct A { | ||
// Declare the constructor, but don't define it to avoid emitting the | ||
// definition in the debug info. | ||
A(); | ||
using X = int; | ||
}; | ||
|
||
A a; | ||
A::X var; |