Skip to content

[llvm] [Demangle] Fix MSVC demangling for placeholder return types #106178

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
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ enum class PrimitiveKind {
Double,
Ldouble,
Nullptr,
Auto,
DecltypeAuto,
};

enum class CharKind {
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Demangle/MicrosoftDemangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,10 @@ Demangler::demanglePrimitiveType(std::string_view &MangledName) {
return Arena.alloc<PrimitiveTypeNode>(PrimitiveKind::Char16);
case 'U':
return Arena.alloc<PrimitiveTypeNode>(PrimitiveKind::Char32);
case 'P':
return Arena.alloc<PrimitiveTypeNode>(PrimitiveKind::Auto);
case 'T':
return Arena.alloc<PrimitiveTypeNode>(PrimitiveKind::DecltypeAuto);
}
break;
}
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ void PrimitiveTypeNode::outputPre(OutputBuffer &OB, OutputFlags Flags) const {
OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Double, "double");
OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Ldouble, "long double");
OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Nullptr, "std::nullptr_t");
OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Auto, "auto");
OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, DecltypeAuto, "decltype(auto)");
}
outputQualifiers(OB, Quals, true, false);
}
Expand Down
18 changes: 18 additions & 0 deletions llvm/test/Demangle/ms-placeholder-return-type.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
; RUN: llvm-undname < %s | FileCheck %s

; CHECK-NOT: Invalid mangled name

?TestNonTemplateAuto@@YA@XZ
; CHECK: __cdecl TestNonTemplateAuto(void)

??$AutoT@X@@YA?A_PXZ
; CHECK: auto __cdecl AutoT<void>(void)

??$AutoT@X@@YA?B_PXZ
; CHECK: auto const __cdecl AutoT<void>(void)

??$AutoT@X@@YA?A_TXZ
; CHECK: decltype(auto) __cdecl AutoT<void>(void)

??$AutoT@X@@YA?B_TXZ
; CHECK: decltype(auto) const __cdecl AutoT<void>(void)
Loading