summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Demangle/MicrosoftDemangle.cpp11
-rw-r--r--llvm/test/Demangle/invalid-manglings.test5
2 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp
index 2b41c0037f9..c3bdfa23d1f 100644
--- a/llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -947,8 +947,17 @@ Demangler::demangleTemplateInstantiationName(StringView &MangledName,
if (Error)
return nullptr;
- if (NBB & NBB_Template)
+ if (NBB & NBB_Template) {
+ // NBB_Template is only set for types and non-leaf names ("a::" in "a::b").
+ // A conversion operator only makes sense in a leaf name , so reject it in
+ // NBB_Template contexts.
+ if (Identifier->kind() == NodeKind::ConversionOperatorIdentifier) {
+ Error = true;
+ return nullptr;
+ }
+
memorizeIdentifier(Identifier);
+ }
return Identifier;
}
diff --git a/llvm/test/Demangle/invalid-manglings.test b/llvm/test/Demangle/invalid-manglings.test
index 869d63a274f..2673770c1de 100644
--- a/llvm/test/Demangle/invalid-manglings.test
+++ b/llvm/test/Demangle/invalid-manglings.test
@@ -129,3 +129,8 @@
; CHECK-EMPTY:
; CHECK-NEXT: ??_R4foo@@
; CHECK-NEXT: error: Invalid mangled name
+
+?foo@?$?BH@@QAEHXZ
+; CHECK-EMPTY:
+; CHECK-NEXT: ?foo@?$?BH@@QAEHXZ
+; CHECK-NEXT: error: Invalid mangled name
OpenPOWER on IntegriCloud