-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[lldb] add TemplateRange and NameQualifiersRange to DemangledNameInfo #150999
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
Changes from all commits
9b3551c
35bb830
a059d51
c2e9516
17f7a5a
9bbde80
8321eb0
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 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -92,6 +92,14 @@ void TrackingOutputBuffer::finalizeStart() { | |||||||||||
if (NameInfo.BasenameRange.second == 0) | ||||||||||||
NameInfo.BasenameRange.second = getCurrentPosition(); | ||||||||||||
|
||||||||||||
// There is something between the basename and the start of the function | ||||||||||||
// arguments. Assume those are template arguments (which *should* be true for | ||||||||||||
// C++ demangled names, but this assumption may change in the future, in | ||||||||||||
// which case this needs to be adjusted). | ||||||||||||
if (NameInfo.BasenameRange.second != NameInfo.ArgumentsRange.first) | ||||||||||||
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. Lets add a comment
Suggested change
|
||||||||||||
NameInfo.TemplateArgumentsRange = {NameInfo.BasenameRange.second, | ||||||||||||
NameInfo.ArgumentsRange.first}; | ||||||||||||
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. I wonder if we should modify We could change it to:
And inside The benefit being that we won't get any surprises when the demangler decides to put things between the template arguments and function parameters. Would this work with your planned Swift plugin changes? 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. I agree that this would be much more robust. 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.
The only seemingly related failing test is
This value should be (0, 0): { "_ZN8nlohmann16json_abi_v3_11_310basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbxydS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC1EDn",
{
/*.BasenameRange=*/{344, 354}, /*.TemplateArgumentsRange=*/{0, 0}, /*.ScopeRange=*/{0, 344},
/*.ArgumentsRange=*/{354, 370}, /*.QualifiersRange=*/{370, 370}, /*.NameQualifiersRange=*/{0, 0},
/*.PrefixRange=*/{0, 0}, /*.SuffixRange=*/{0, 0}
},
/*.basename=*/"basic_json",
/*.scope=*/"nlohmann::json_abi_v3_11_3::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char>>, void>::",
/*.qualifiers=*/""
} I think we should override more methods in 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 you paste the diff you used to run these tests? 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. Oh sorry, yes: diff --git a/lldb/source/Core/DemangledNameInfo.cpp b/lldb/source/Core/DemangledNameInfo.cpp
index 95db524fba2d..021016d7c072 100644
--- a/lldb/source/Core/DemangledNameInfo.cpp
+++ b/lldb/source/Core/DemangledNameInfo.cpp
@@ -80,6 +80,20 @@ void TrackingOutputBuffer::finalizeQualifiersEnd() {
NameInfo.QualifiersRange.second = getCurrentPosition();
}
+void TrackingOutputBuffer::updateTemplateArgumentsStart() {
+ if (!shouldTrack())
+ return;
+
+ NameInfo.TemplateArgumentsRange.first = getCurrentPosition();
+}
+
+void TrackingOutputBuffer::updateTemplateArgumentsEnd() {
+ if (!shouldTrack())
+ return;
+
+ NameInfo.TemplateArgumentsRange.second = getCurrentPosition();
+}
+
void TrackingOutputBuffer::finalizeStart() {
if (!shouldTrack())
return;
@@ -92,9 +106,9 @@ void TrackingOutputBuffer::finalizeStart() {
if (NameInfo.BasenameRange.second == 0)
NameInfo.BasenameRange.second = getCurrentPosition();
- if (NameInfo.BasenameRange.second != NameInfo.ArgumentsRange.first)
- NameInfo.TemplateArgumentsRange = {NameInfo.BasenameRange.second,
- NameInfo.ArgumentsRange.first};
+ // if (NameInfo.BasenameRange.second != NameInfo.ArgumentsRange.first)
+ // NameInfo.TemplateArgumentsRange = {NameInfo.BasenameRange.second,
+ // NameInfo.ArgumentsRange.first};
assert(!shouldTrack());
assert(canFinalize());
@@ -228,7 +242,9 @@ void TrackingOutputBuffer::printLeftImpl(const NestedName &N) {
void TrackingOutputBuffer::printLeftImpl(const NameWithTemplateArgs &N) {
N.Name->print(*this);
updateBasenameEnd();
+ updateTemplateArgumentsStart();
N.TemplateArgs->print(*this);
+ updateTemplateArgumentsEnd();
}
} // namespace lldb_private 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. Ah i think it's because we're tracking the template arguments when printing the scope. Ideally we would only track them when we already have a basename. But that doesn't get finalized until we're in 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. I think I understand. I've reverted my changes and added the comment like you asked above. Thanks! |
||||||||||||
|
||||||||||||
assert(!shouldTrack()); | ||||||||||||
assert(canFinalize()); | ||||||||||||
} | ||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.