This patch separates the generic portion of ClangExpressionVariable, which stores information about a variable that different parts of LLDB use, from the compiler-specific portion that only the expression parser cares about.
Details
Diff Detail
Event Timeline
In general this looks good. It seems to me that in almost all the uses of ClangExpressionVariable::CreateVariableInList, you actually only want the ClangExpressionVariable *, since you pretty much always turn around an get that out of the ExpressionVariableSP anyway. So it might be more convenient to have CreateVariableInList return a ClangExpressionVariable *, and if you find yourself needing the ExpressionVariableSP, then just have ExpressionVariable implement shared_from_this, and you can use that to resurrect the shared pointer.
According to Jim's suggestions, made CreateVariableInList return a ClangExpressionVariable * rather than a ExpressionVariableSP. Also made ExpressionVariable be able to get a shared pointer from itself, so that the few cases that want to create a variable and get a shared pointer can do that correctly.
Is there any reason ClangExpression::FindVariableInList doesn't work the same way as CreateVariableInList. It seems like for that one you also usually want the ClangExpressionVariable when you call it?
Working on that now. I have to be careful not just to stuff ClangExpressionVariable* into ExpressionVariableSP, but to use shared_from_this, otherwise I get crashes in the testsuite. I'll update this patch once I get that cleaned up.
Applied Jim's suggestion that FindVariableInList return a ClangExpressionVariable *. Also fixed some places where we should have called shared_from_this instead of creating a new shared pointer.
That look good. There's one place (noted inline) where you are missing a newline at the end of a file. Fix that and it's good to go.
source/Expression/ExpressionVariable.cpp | ||
---|---|---|
32–33 | Add missing newline. |
Add missing newline.