Skip to content

[llvm-cxxfilt] Added the option --no-params #75348

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

Merged
merged 3 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion libcxxabi/src/demangle/ItaniumDemangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -5431,7 +5431,10 @@ Node *AbstractManglingParser<Derived, Alloc>::parseEncoding(bool ParseParams) {
if (IsEndOfEncoding())
return Name;

// ParseParams may be false in top-level only, when called from parse().
// ParseParams maybe false at the top level only, when called from parse().
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// ParseParams maybe false at the top level only, when called from parse().
// ParseParams may be false at the top level only, when called from parse().

Apologies for the typo in my original suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much. I have updated the comment and the description.

// For example in the mangled name _Z3fooILZ3BarEET_f, ParseParams may be
// false when demangling 3fooILZ3BarEET_f but is always true when demangling
// 3Bar.
if (!ParseParams) {
while (consume())
;
Expand Down
5 changes: 4 additions & 1 deletion llvm/include/llvm/Demangle/ItaniumDemangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -5430,7 +5430,10 @@ Node *AbstractManglingParser<Derived, Alloc>::parseEncoding(bool ParseParams) {
if (IsEndOfEncoding())
return Name;

// ParseParams may be false in top-level only, when called from parse().
// ParseParams maybe false at the top level only, when called from parse().
// For example in the mangled name _Z3fooILZ3BarEET_f, ParseParams may be
// false when demangling 3fooILZ3BarEET_f but is always true when demangling
// 3Bar.
if (!ParseParams) {
while (consume())
;
Expand Down
22 changes: 14 additions & 8 deletions llvm/test/tools/llvm-cxxfilt/no-params.test
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
RUN: llvm-cxxfilt _Z3fooIiJEEvf _Z3fooIPFcfEET_d _ZN1f2baC2ERKNS_2baIT_EE | FileCheck %s --check-prefix=CHECK-PARAMS
RUN: llvm-cxxfilt -p _Z3fooIiJEEvf _Z3fooIPFcfEET_d _ZN1f2baC2ERKNS_2baIT_EE | FileCheck %s --check-prefix=CHECK-NO-PARAMS --match-full-lines
RUN: llvm-cxxfilt --no-params _Z3fooIiJEEvf _Z3fooIPFcfEET_d _ZN1f2baC2ERKNS_2baIT_EE | FileCheck %s --check-prefix=CHECK-NO-PARAMS --match-full-lines
RUN: llvm-cxxfilt _Z3fooILZ3BarEET_f _Z3fooIPFcfEET_d _ZN1f2baC2ERKNS_2baIT_EE _Z3foov.123 | FileCheck %s --check-prefix=CHECK-PARAMS
RUN: llvm-cxxfilt -p _Z3fooILZ3BarEET_f _Z3fooIPFcfEET_d _ZN1f2baC2ERKNS_2baIT_EE _Z3foov.123 | FileCheck %s --check-prefix=CHECK-NO-PARAMS --match-full-lines
RUN: llvm-cxxfilt --no-params _Z3fooILZ3BarEET_f _Z3fooIPFcfEET_d _ZN1f2baC2ERKNS_2baIT_EE _Z3foov.123 | FileCheck %s --check-prefix=CHECK-NO-PARAMS --match-full-lines

# Use a simple valid mangled name to check that -p or --no-params flag omits
# function parameters and the return type.
# Check that -p or --no-params flag omits function parameters and the return
# type.

CHECK-PARAMS: void foo<int>(float)
CHECK-NO-PARAMS: foo<int>
CHECK-PARAMS: Bar foo<Bar>(float)
CHECK-NO-PARAMS: foo<Bar>

# Check that only the top-level function is impacted by the switch, and that
# nested function types in the encoding (e.g. where a function type is being
Expand All @@ -21,8 +21,14 @@ CHECK-NO-PARAMS: foo<char (*)(float)>

# Use an invalid mangled name broken in the function parameters to check how -p
# or --no-params flag works. If the option is given we should be able to
# demangle function name just fine. If it is not given, demangling will fail
# demangle the function name just fine. If it is not given, demangling will fail
# because of the invalid params.

CHECK-PARAMS: _ZN1f2baC2ERKNS_2baIT_EE
CHECK-NO-PARAMS: f::ba::ba

# Check that a vendor specific suffix is also omitted when --no-params is
# specified. This matches c++filt's behaviour.

CHECK-PARAMS: foo() (.123)
CHECK-NO-PARAMS: foo