aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2024-04-25 09:06:48 +0200
committerGitHub <noreply@github.com>2024-04-25 09:06:48 +0200
commit565bdb55453f0bdd59d9325b8a748cb42e6df95b (patch)
tree9028cbcbba87f14d2d5571b62c92a51cb8073960 /clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
parentd86cc73bbfd9a22d9a0d498d72c9b2ee235128e9 (diff)
downloadllvm-565bdb55453f0bdd59d9325b8a748cb42e6df95b.zip
llvm-565bdb55453f0bdd59d9325b8a748cb42e6df95b.tar.gz
llvm-565bdb55453f0bdd59d9325b8a748cb42e6df95b.tar.bz2
[lldb] Add SB API to access static constexpr member values (#89730)
The main change is the addition of a new SBTypeStaticField class, representing a static member of a class. It can be retrieved created through SBType::GetStaticFieldWithName. It contains several methods (GetName, GetMangledName, etc.) whose meaning is hopefully obvious. The most interesting method is lldb::SBValue GetConstantValue(lldb::SBTarget) which returns a the value of the field -- if it is a compile time constant. The reason for that is that only constants have their values represented in the clang AST. For non-constants, we need to go back to the module containing that constant, and ask retrieve the associated ValueObjectVariable. That's easy enough if the we are still in the type system of the module (because then the type system will contain the pointer to the module symbol file), but it's hard when the type has been copied into another AST (e.g. during expression evaluation). To do that we would need to walk the ast import chain backwards to find the source TypeSystem, and I haven't found a nice way to do that. Another possibility would be to use the mangled name of the variable to perform a lookup (in all modules). That is sort of what happens when evaluating the variable in an expression (which does work), but I did not want to commit to that implementation as it's not necessary for my use case (and if anyone wants to, he can use the GetMangledName function and perform the lookup manually). The patch adds a couple of new TypeSystem functions to surface the information needed to implement this functionality.
Diffstat (limited to 'clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp')
0 files changed, 0 insertions, 0 deletions