[all-commits] [llvm/llvm-project] 565bdb: [lldb] Add SB API to access static constexpr membe...
Pavel Labath via All-commits
all-commits at lists.llvm.org
Thu Apr 25 00:07:09 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 565bdb55453f0bdd59d9325b8a748cb42e6df95b
https://github.com/llvm/llvm-project/commit/565bdb55453f0bdd59d9325b8a748cb42e6df95b
Author: Pavel Labath <pavel at labath.sk>
Date: 2024-04-25 (Thu, 25 Apr 2024)
Changed paths:
M lldb/include/lldb/API/SBTarget.h
M lldb/include/lldb/API/SBType.h
M lldb/include/lldb/API/SBValue.h
M lldb/include/lldb/Symbol/CompilerDecl.h
M lldb/include/lldb/Symbol/CompilerType.h
M lldb/include/lldb/Symbol/TypeSystem.h
M lldb/source/API/SBType.cpp
M lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
M lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
M lldb/source/Symbol/CompilerDecl.cpp
M lldb/source/Symbol/CompilerType.cpp
M lldb/test/API/python_api/type/TestTypeList.py
M lldb/test/API/python_api/type/main.cpp
Log Message:
-----------
[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.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list