-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb][SBAPI] Add new SBType::GetTemplateParameterValue API #126901
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -446,6 +446,7 @@ class LLDB_API SBValue { | |
friend class SBModule; | ||
friend class SBTarget; | ||
friend class SBThread; | ||
friend class SBType; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was necessary to get access to the SBValue constructor |
||
friend class SBTypeStaticField; | ||
friend class SBTypeSummary; | ||
friend class SBValueList; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -687,6 +687,40 @@ lldb::TemplateArgumentKind SBType::GetTemplateArgumentKind(uint32_t idx) { | |
return eTemplateArgumentKindNull; | ||
} | ||
|
||
lldb::SBValue SBType::GetTemplateArgumentValue(lldb::SBTarget target, | ||
uint32_t idx) { | ||
LLDB_INSTRUMENT_VA(this, target, idx); | ||
|
||
if (!IsValid()) | ||
return SBValue(); | ||
|
||
std::optional<CompilerType::IntegralTemplateArgument> arg; | ||
const bool expand_pack = true; | ||
switch (GetTemplateArgumentKind(idx)) { | ||
case eTemplateArgumentKindIntegral: | ||
arg = m_opaque_sp->GetCompilerType(false).GetIntegralTemplateArgument( | ||
idx, expand_pack); | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
if (!arg) | ||
return {}; | ||
|
||
Scalar value{arg->value}; | ||
|
||
if (!value.IsValid()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this ever be not valid? What would that even mean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea we don't need this |
||
return {}; | ||
|
||
DataExtractor data; | ||
value.GetData(data); | ||
|
||
auto value_obj_sp = ValueObjectConstResult::Create( | ||
target.GetSP().get(), arg->type, ConstString("value"), data); | ||
return SBValue(std::move(value_obj_sp)); | ||
} | ||
|
||
SBType SBType::FindDirectNestedType(const char *name) { | ||
LLDB_INSTRUMENT_VA(this, name); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
CXX_SOURCES := main.cpp | ||
CXXFLAGS_EXTRAS := -std=c++20 | ||
|
||
include Makefile.rules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was only necessary to get access to
SBTarget::GetSP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is completely optional, it just seemed like a good opportunity to advertise my idea for avoiding these random criss-cross friend declarations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, sorry, this is my bad. I didn't mean to imply that it should be done in this patch. I do like this idea, but I think that if we do that, it should be done in a more wider fashion rather than a one-off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah fair enough, reverted that for now