Skip to content

Commit 5420834

Browse files
committed
[demangler] Fix demangling a template argument which happens to be a null pointer
As seen in llvm/llvm-project#51854 llvm-cxxfilt was having trouble demangling the case "_Z1fIDnLDn0EEvv". We handled the "LDNE" case and "LPi0E" but not "LDn0E". This change adds that handling. Differential Revision: https://reviews.llvm.org/D124010
1 parent 451c557 commit 5420834

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

libcxxabi/src/demangle/ItaniumDemangle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4340,7 +4340,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExprPrimary() {
43404340
return nullptr;
43414341
}
43424342
case 'D':
4343-
if (consumeIf("DnE"))
4343+
if (consumeIf("Dn") && (consumeIf('0'), consumeIf('E')))
43444344
return make<NameType>("nullptr");
43454345
return nullptr;
43464346
case 'T':

libcxxabi/test/test_demangle.pass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ const char* cases[][2] =
644644
{"_ZNSs4_Rep20_S_empty_rep_storageE", "std::string::_Rep::_S_empty_rep_storage"},
645645
{"_ZZN23ImageLoaderMachOClassic26bindIndirectSymbolPointersERKN11ImageLoader11LinkContextEbbE13alreadyWarned", "ImageLoaderMachOClassic::bindIndirectSymbolPointers(ImageLoader::LinkContext const&, bool, bool)::alreadyWarned"},
646646
{"_ZN12_GLOBAL__N_115emergency_mutexE", "(anonymous namespace)::emergency_mutex"},
647+
{"_Z1fIDnLDn0EEvv", "void f<std::nullptr_t, nullptr>()"},
647648

648649
// clang
649650

llvm/include/llvm/Demangle/ItaniumDemangle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4340,7 +4340,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExprPrimary() {
43404340
return nullptr;
43414341
}
43424342
case 'D':
4343-
if (consumeIf("DnE"))
4343+
if (consumeIf("Dn") && (consumeIf('0'), consumeIf('E')))
43444344
return make<NameType>("nullptr");
43454345
return nullptr;
43464346
case 'T':

0 commit comments

Comments
 (0)