-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[lldb][dwarf] Compute fully qualified names on simplified template names with DWARFTypePrinter #112811
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][dwarf] Compute fully qualified names on simplified template names with DWARFTypePrinter #112811
Changes from 1 commit
3fc0675
38a459b
769c4fb
58605dc
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 |
|---|---|---|
|
|
@@ -24,9 +24,11 @@ class DWARFUnit; | |
| class DWARFDebugInfoEntry; | ||
| class DWARFDeclContext; | ||
| class SymbolFileDWARF; | ||
| class DWARFFormValue; | ||
|
|
||
| class DWARFBaseDIE { | ||
| public: | ||
| using DWARFFormValue = dwarf::DWARFFormValue; | ||
| DWARFBaseDIE() = default; | ||
|
|
||
| DWARFBaseDIE(DWARFUnit *cu, DWARFDebugInfoEntry *die) | ||
|
|
@@ -46,6 +48,7 @@ class DWARFBaseDIE { | |
| explicit operator bool() const { return IsValid(); } | ||
|
|
||
| bool IsValid() const { return m_cu && m_die; } | ||
| bool isValid() const { return IsValid(); } | ||
|
|
||
| bool HasChildren() const; | ||
|
|
||
|
|
@@ -85,6 +88,8 @@ class DWARFBaseDIE { | |
| // Accessing information about a DIE | ||
| dw_tag_t Tag() const; | ||
|
|
||
| dw_tag_t getTag() const { return Tag(); } | ||
|
|
||
| dw_offset_t GetOffset() const; | ||
|
|
||
| // Get the LLDB user ID for this DIE. This is often just the DIE offset, | ||
|
|
@@ -95,6 +100,8 @@ class DWARFBaseDIE { | |
|
|
||
| const char *GetName() const; | ||
|
|
||
| const char *getShortName() const { return GetName(); } | ||
|
||
|
|
||
| lldb::ModuleSP GetModule() const; | ||
|
|
||
| // Getting attribute values from the DIE. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1403,26 +1403,6 @@ static TemplateParameterList *CreateTemplateParameterList( | |
| return template_param_list; | ||
| } | ||
|
|
||
| std::string TypeSystemClang::PrintTemplateParams( | ||
| const TemplateParameterInfos &template_param_infos) { | ||
| llvm::SmallVector<NamedDecl *, 8> ignore; | ||
| clang::TemplateParameterList *template_param_list = | ||
| CreateTemplateParameterList(getASTContext(), template_param_infos, | ||
| ignore); | ||
| llvm::SmallVector<clang::TemplateArgument, 2> args( | ||
| template_param_infos.GetArgs()); | ||
| if (template_param_infos.hasParameterPack()) { | ||
| llvm::ArrayRef<TemplateArgument> pack_args = | ||
| template_param_infos.GetParameterPackArgs(); | ||
| args.append(pack_args.begin(), pack_args.end()); | ||
| } | ||
| std::string str; | ||
| llvm::raw_string_ostream os(str); | ||
| clang::printTemplateArgumentList(os, args, GetTypePrintingPolicy(), | ||
| template_param_list); | ||
| return str; | ||
| } | ||
|
Member
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. Nice |
||
|
|
||
| clang::FunctionTemplateDecl *TypeSystemClang::CreateFunctionTemplateDecl( | ||
| clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, | ||
| clang::FunctionDecl *func_decl, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Test lldb is able to compute the fully qualified names on templates with | ||
| // -gsimple-template-names and -fdebug-types-section. | ||
|
|
||
| // REQUIRES: lld | ||
|
|
||
| // Test against logging to see if we print the fully qualified names correctly. | ||
| // RUN: %clangxx --target=x86_64-pc-linux -g -gsimple-template-names %s -o %t | ||
| // RUN: %lldb %t -o "log enable dwarf comp" -o "target variable v1 v2" -o exit | FileCheck %s --check-prefix=LOG | ||
|
|
||
| // Test that we following DW_AT_signature correctly. If not, lldb might confuse the types of v1 and v2. | ||
| // RUN: %clangxx --target=x86_64-pc-linux -g -gsimple-template-names -fdebug-types-section %s -o %t | ||
| // RUN: %lldb %t -o "target variable v1 v2" -o exit | FileCheck %s --check-prefix=TYPE | ||
|
|
||
| // LOG: unique name: ::t2<outer_struct1::t1<int> > | ||
| // LOG: unique name: ::t2<outer_struct2::t1<int> > | ||
|
||
|
|
||
| // TYPE: (t2<outer_struct1::t1<int> >) v1 = {} | ||
| // TYPE-NEXT: (t2<outer_struct2::t1<int> >) v2 = {} | ||
|
Member
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. Do we need to check the typename that gets displayed here? Is that actually affected by this patch?
Contributor
Author
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. No, they are not affected by this patch. When I working on this change, I had an oversight on not calling |
||
|
|
||
| struct outer_struct1 { | ||
| template <typename> struct t1 {}; | ||
| }; | ||
|
|
||
| struct outer_struct2 { | ||
| template <typename> struct t1 {}; | ||
| }; | ||
|
|
||
| template <typename> struct t2 {}; | ||
| t2<outer_struct1::t1<int>> v1; | ||
| t2<outer_struct2::t1<int>> v2; | ||
| int main() {} | ||
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.
How about using
operator boolas the common api ?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.
Removed both
IsValid()andIsValid()and switched to useoperator bool ().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.
I'm sorry, I guess I wasn't clear about this. What I was suggesting is to just revert the addition
isValid-- as there already exists a comon API. I didn't want to remove things that are already there. (I mean, I'd be fine with that doing that under the flag of moving the LLDB API closer to LLVM, but I don't think we ought to do that as a part of this PR)