Open mvanotti opened 1 month ago
@llvm/issue-subscribers-lldb
Author: Marco Vanotti (mvanotti)
constexpr
versus const
in what contexts? E.g., for global variables or static data members they're effectively the same thing?
constexpr
versusconst
in what contexts? E.g., for global variables or static data members they're effectively the same thing?
I didn't mean it in that way. The functionality I want is to tell whether a variable is const or not. I don't care about const
vs constexpr
.
Currently the only way I found to figure that out is by parsing the output of GetDisplayTypeName
method and look for the const
keyword, but it would be nice to have that in a more convenient way, either a method or in one of the TypeFlags
.
Ah thanks for clarifying. I'm not aware of such an API (@jimingham @clayborg might know?). I do see a TypeSystem::IsConst
API (and the more general TypeSystem::GetTypeQualifiers
) which has the capability of retrieving that information from an SBType
. But I don't see it exposed anywhere. I guess there just weren't any use-cases for it so far?
Out of curiosity, what would you do with such information?
I'm using the lldb python API to understand how variables are used during an execution run. Being able to identify that a variable is const
simplifies the logic a bit as I can safely filter it. This is useful in programs that have a lot of global constants in scope.
I'm using the lldb python API to understand how variables are used during an execution run. Being able to identify that a variable is
const
simplifies the logic a bit as I can safely filter it. This is useful in programs that have a lot of global constants in scope.
I don't see an issue with exposing that information. @jimingham , thoughts on adding something like SBType::IsConst
, which just calls into TypeSystem::IsConst
?
It looks like there is no clear way to determine if a variable is
const
orconstexpr
inlldb
. The best way I could find to determine that is by looking at the output ofGetDisplayTypeName()
, which contains theconst
keyword.It would be nice to have a way to tell if a variable is a constant by invoking a method, or for example, by adding it to the TypeFlags: https://lldb.llvm.org/python_api_enums.html#typeflags