From 91f8860de5f4280607e74c9d653751cd3f891ca7 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Mon, 7 Dec 2009 19:56:42 +0000 Subject: [PATCH] Mangle basic_ostream and basic_iostream specializations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90794 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/Mangle.cpp | 46 ++++++++++++++++++++-------- test/CodeGenCXX/mangle-subst-std.cpp | 8 +++++ 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index df708eda9c..2d86709f8f 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -1261,6 +1261,25 @@ static bool isCharSpecialization(QualType T, const char *Name) { return SD->getIdentifier()->getName() == Name; } +template +bool isStreamCharSpecialization(const ClassTemplateSpecializationDecl *SD, + const char (&Str)[StrLen]) { + if (!SD->getIdentifier()->isStr(Str)) + return false; + + const TemplateArgumentList &TemplateArgs = SD->getTemplateArgs(); + if (TemplateArgs.size() != 2) + return false; + + if (!isCharType(TemplateArgs[0].getAsType())) + return false; + + if (!isCharSpecialization(TemplateArgs[1].getAsType(), "char_traits")) + return false; + + return true; +} + bool CXXNameMangler::mangleStandardSubstitution(const NamedDecl *ND) { // ::= St # ::std:: if (const NamespaceDecl *NS = dyn_cast(ND)) { @@ -1311,23 +1330,26 @@ bool CXXNameMangler::mangleStandardSubstitution(const NamedDecl *ND) { return true; } - // ::= So # ::std::basic_ostream ::= Si # ::std::basic_istream > - if (SD->getIdentifier()->isStr("basic_ostream")) { - const TemplateArgumentList &TemplateArgs = SD->getTemplateArgs(); - - if (TemplateArgs.size() != 2) - return false; - - if (!isCharType(TemplateArgs[0].getAsType())) - return false; - - if (!isCharSpecialization(TemplateArgs[1].getAsType(), "char_traits")) - return false; + if (isStreamCharSpecialization(SD, "basic_istream")) { + Out << "Si"; + return true; + } + // ::= So # ::std::basic_ostream > + if (isStreamCharSpecialization(SD, "basic_ostream")) { Out << "So"; return true; } + + // ::= Sd # ::std::basic_iostream > + if (isStreamCharSpecialization(SD, "basic_iostream")) { + Out << "Sd"; + return true; + } } return false; } diff --git a/test/CodeGenCXX/mangle-subst-std.cpp b/test/CodeGenCXX/mangle-subst-std.cpp index 8a410b8b04..a2994c4abf 100644 --- a/test/CodeGenCXX/mangle-subst-std.cpp +++ b/test/CodeGenCXX/mangle-subst-std.cpp @@ -32,12 +32,20 @@ namespace std { void f(std::string) { } namespace std { + template struct basic_istream { }; template struct basic_ostream { }; + template struct basic_iostream { }; } +// CHECK: _Z1fSi +void f(std::basic_istream >) { } + // CHECK: _Z1fSo void f(std::basic_ostream >) { } +// CHECK: _Z1fSd +void f(std::basic_iostream >) { } + extern "C++" { namespace std { -- 2.40.0