diff options
author | Anders Carlsson <andersca@mac.com> | 2009-12-07 19:56:42 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-12-07 19:56:42 +0000 |
commit | 91f8860de5f4280607e74c9d653751cd3f891ca7 (patch) | |
tree | 8cd6014d61868cbce15a3cea931dd7a83d7975be /lib/CodeGen/Mangle.cpp | |
parent | bc773a0bd20231c405476d15c5e8bfb3eb365293 (diff) |
Mangle basic_ostream and basic_iostream specializations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90794 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/Mangle.cpp')
-rw-r--r-- | lib/CodeGen/Mangle.cpp | 46 |
1 files changed, 34 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 <std::size_t StrLen> +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) { // <substitution> ::= St # ::std:: if (const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) { @@ -1311,23 +1330,26 @@ bool CXXNameMangler::mangleStandardSubstitution(const NamedDecl *ND) { return true; } - // <substitution> ::= So # ::std::basic_ostream<char, + // <substitution> ::= Si # ::std::basic_istream<char, // ::std::char_traits<char> > - 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; + } + // <substitution> ::= So # ::std::basic_ostream<char, + // ::std::char_traits<char> > + if (isStreamCharSpecialization(SD, "basic_ostream")) { Out << "So"; return true; } + + // <substitution> ::= Sd # ::std::basic_iostream<char, + // ::std::char_traits<char> > + if (isStreamCharSpecialization(SD, "basic_iostream")) { + Out << "Sd"; + return true; + } } return false; } |