[cfe-commits] r90794 - in /cfe/trunk: lib/CodeGen/Mangle.cpp test/CodeGenCXX/mangle-subst-std.cpp

Anders Carlsson andersca at mac.com
Mon Dec 7 11:56:42 PST 2009


Author: andersca
Date: Mon Dec  7 13:56:42 2009
New Revision: 90794

URL: http://llvm.org/viewvc/llvm-project?rev=90794&view=rev
Log:
Mangle basic_ostream and basic_iostream specializations.

Modified:
    cfe/trunk/lib/CodeGen/Mangle.cpp
    cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp

Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=90794&r1=90793&r2=90794&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Mon Dec  7 13:56:42 2009
@@ -1261,6 +1261,25 @@
   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 @@
       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;
 }

Modified: cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp?rev=90794&r1=90793&r2=90794&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp Mon Dec  7 13:56:42 2009
@@ -32,12 +32,20 @@
 void f(std::string) { }
 
 namespace std {
+  template<typename, typename> struct basic_istream { };
   template<typename, typename> struct basic_ostream { };
+  template<typename, typename> struct basic_iostream { };
 }
 
+// CHECK: _Z1fSi
+void f(std::basic_istream<char, std::char_traits<char> >) { }
+
 // CHECK: _Z1fSo
 void f(std::basic_ostream<char, std::char_traits<char> >) { }
 
+// CHECK: _Z1fSd
+void f(std::basic_iostream<char, std::char_traits<char> >) { }
+
 extern "C++" {
 namespace std
 {





More information about the cfe-commits mailing list