]> granicus.if.org Git - clang/commitdiff
Don't substitute 'St' for 'std' when the namespace is nested inside another namespace.
authorAnders Carlsson <andersca@mac.com>
Wed, 2 Jun 2010 15:58:27 +0000 (15:58 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 2 Jun 2010 15:58:27 +0000 (15:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105330 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/Mangle.cpp
test/CodeGenCXX/mangle-subst-std.cpp

index b7d8e2704a43bad4cec5f9e7d9b3ffe5b0f9a223..c246bb50c69ed106c47c2ab39ba5f231515733e6 100644 (file)
@@ -362,12 +362,6 @@ void CXXNameMangler::mangleFunctionEncoding(const FunctionDecl *FD) {
   mangleBareFunctionType(FT, MangleReturnType);
 }
 
-/// isStd - Return whether a given namespace is the 'std' namespace.
-static bool isStd(const NamespaceDecl *NS) {
-  const IdentifierInfo *II = NS->getOriginalNamespace()->getIdentifier();
-  return II && II->isStr("std");
-}
-
 static const DeclContext *IgnoreLinkageSpecDecls(const DeclContext *DC) {
   while (isa<LinkageSpecDecl>(DC)) {
     DC = DC->getParent();
@@ -376,15 +370,21 @@ static const DeclContext *IgnoreLinkageSpecDecls(const DeclContext *DC) {
   return DC;
 }
 
+/// isStd - Return whether a given namespace is the 'std' namespace.
+static bool isStd(const NamespaceDecl *NS) {
+  if (!IgnoreLinkageSpecDecls(NS->getParent())->isTranslationUnit())
+    return false;
+  
+  const IdentifierInfo *II = NS->getOriginalNamespace()->getIdentifier();
+  return II && II->isStr("std");
+}
+
 // isStdNamespace - Return whether a given decl context is a toplevel 'std'
 // namespace.
 static bool isStdNamespace(const DeclContext *DC) {
   if (!DC->isNamespace())
     return false;
 
-  if (!IgnoreLinkageSpecDecls(DC->getParent())->isTranslationUnit())
-    return false;
-
   return isStd(cast<NamespaceDecl>(DC));
 }
 
index 4c15eaac8835a8b6236347719687ed433c361e42..9c1e978294c860ac0f6d7f4680b6513e3b5fe2e9 100644 (file)
@@ -99,3 +99,13 @@ void f(not_string) { }
 void create_streams() {
   std::basic_iostream<char> bio(17);
 }
+
+// Make sure we don't mangle 'std' as 'St' here.
+namespace N {
+  namespace std {
+    struct A { void f(); };
+    
+    // CHECK: define void @_ZN1N3std1A1fEv
+    void A::f() { }
+  }
+}