From b1162f178feb312b452e1b2095e0ed3413ba47fe Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 23 Feb 2010 18:20:18 +0000 Subject: [PATCH] PR6400: Handle an extreme edge case in mangling correctly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96961 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/Mangle.cpp | 3 +++ test/CodeGenCXX/mangle-subst-std.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index a302225c7f..123ce61338 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -1652,6 +1652,9 @@ bool CXXNameMangler::mangleStandardSubstitution(const NamedDecl *ND) { // ::std::char_traits, // ::std::allocator > if (SD->getIdentifier()->isStr("basic_string")) { + if (!isStdNamespace(SD->getDeclContext())) + return false; + const TemplateArgumentList &TemplateArgs = SD->getTemplateArgs(); if (TemplateArgs.size() != 3) diff --git a/test/CodeGenCXX/mangle-subst-std.cpp b/test/CodeGenCXX/mangle-subst-std.cpp index 913c8f101b..062610bd74 100644 --- a/test/CodeGenCXX/mangle-subst-std.cpp +++ b/test/CodeGenCXX/mangle-subst-std.cpp @@ -55,3 +55,9 @@ namespace std terminate_handler set_terminate(terminate_handler) { return 0; } } } + +// Make sure we don't treat the following like std::string +// CHECK: define void @_Z1f12basic_stringIcSt11char_traitsIcESaIcEE +template struct basic_string { }; +typedef basic_string, std::allocator > not_string; +void f(not_string) { } -- 2.40.0