The LLDB expression parser relies on using the external AST source support in LLDB. This allows us to find a class at the root namespace level, but it wouldn't allow us to find nested classes all of the time. When LLDB finds a class via this mechanism, it would be able to complete this class when needed, but during completion, we wouldn't populate nested types within this class which would prevent us from finding contained types when needed as clang would expect them to be present if a class was completed. When we parse a type for a class, struct or union, we make a forward declaration to the class which can be completed. Now when the class is completed, we also add any contained types to the class' declaration context which now allows these types to be found. If we have a struct that contains a struct, we will add the forward declaration of the contained structure which can be c ompleted later. Having this forward declaration makes it possible for LLDB to find everything it needs now. This should fix an existing issue: https://github.com/llvm/llvm-project/issues/53904 Previously, contained types could be parsed by accident and allow expression to complete successfully. Other times we would have to run an expression multiple times because our old type lookup from our expressions would cau se a type to be parsed, but not used in the current expression, but this would have parsed a type into the containing decl context and the expression might succeed if it is run again.
32 lines
584 B
C++
32 lines
584 B
C++
namespace a {
|
|
namespace b {
|
|
namespace c {
|
|
static int d = 12;
|
|
enum Color { Red, Green, Blue };
|
|
} // namespace c
|
|
} // namespace b
|
|
} // namespace a
|
|
|
|
struct A {
|
|
int _a = 'a';
|
|
struct B {
|
|
short _b = 'b';
|
|
struct C {
|
|
char _c = 'c';
|
|
enum EnumType : int { Eleven = 11 };
|
|
static EnumType enum_static;
|
|
};
|
|
};
|
|
};
|
|
|
|
A::B::C::EnumType A::B::C::enum_static = A::B::C::Eleven;
|
|
|
|
int foo() {
|
|
a::b::c::Color color = a::b::c::Blue;
|
|
return A::B::C::enum_static == a::b::c::d && ((int)color == 0);
|
|
}
|
|
|
|
int main() {
|
|
return foo(); // Stop here to evaluate expressions
|
|
}
|