Hi eli.friedman, rsmith, rjmccall,

On builds of clang compiled with asserts, we would crash during
mangling.
On builds of clang compiler without asserts, we would mangle in an extra
prefix.

i.e. Funtion()::Function::Type<void>[...] rather than Funtion()::Type<void>[...]

http://llvm-reviews.chandlerc.com/D1932

Files:
  lib/AST/ItaniumMangle.cpp
  test/CodeGenCXX/mangle-local-class-names.cpp

Index: lib/AST/ItaniumMangle.cpp
===================================================================
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -1504,18 +1504,16 @@
   if (NoFunction && isLocalContainerContext(DC))
     return;
 
-  assert(!isLocalContainerContext(DC));
-
-  const NamedDecl *ND = cast<NamedDecl>(DC);  
+  const NamedDecl *ND = cast<NamedDecl>(DC);
   if (mangleSubstitution(ND))
     return;
   
   // Check if we have a template.
   const TemplateArgumentList *TemplateArgs = 0;
   if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) {
     mangleTemplatePrefix(TD);
     mangleTemplateArgs(*TemplateArgs);
-  } else {
+  } else if (!isLocalContainerContext(DC)) {
     manglePrefix(getEffectiveDeclContext(ND), NoFunction);
     mangleUnqualifiedName(ND);
   }
Index: test/CodeGenCXX/mangle-local-class-names.cpp
===================================================================
--- test/CodeGenCXX/mangle-local-class-names.cpp
+++ test/CodeGenCXX/mangle-local-class-names.cpp
@@ -95,3 +95,23 @@
   y.g();
 }
 void CallLocalAnonStruct() { LocalAnonStruct(); }
+
+// CHECK: @_ZZ4Fun1vEN5Type15Type2IvE4Fun2Ev
+// CHECK: @_ZZZ4Fun1vEN5Type15Type2IvE4Fun2EvEN5Type35Type4IvE4Fun3Ev
+void Fun1() {
+  struct Type1 {
+    template <typename = void>
+    struct Type2 {
+      static void Fun2() {
+        struct Type3 {
+          template <typename = void>
+          struct Type4 {
+            static void Fun3() {}
+          };
+        };
+        Type3::template Type4<>::Fun3();
+      }
+    };
+  };
+  Type1::Type2<>::Fun2();
+}
Index: lib/AST/ItaniumMangle.cpp
===================================================================
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -1504,18 +1504,16 @@
   if (NoFunction && isLocalContainerContext(DC))
     return;
 
-  assert(!isLocalContainerContext(DC));
-
-  const NamedDecl *ND = cast<NamedDecl>(DC);  
+  const NamedDecl *ND = cast<NamedDecl>(DC);
   if (mangleSubstitution(ND))
     return;
   
   // Check if we have a template.
   const TemplateArgumentList *TemplateArgs = 0;
   if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) {
     mangleTemplatePrefix(TD);
     mangleTemplateArgs(*TemplateArgs);
-  } else {
+  } else if (!isLocalContainerContext(DC)) {
     manglePrefix(getEffectiveDeclContext(ND), NoFunction);
     mangleUnqualifiedName(ND);
   }
Index: test/CodeGenCXX/mangle-local-class-names.cpp
===================================================================
--- test/CodeGenCXX/mangle-local-class-names.cpp
+++ test/CodeGenCXX/mangle-local-class-names.cpp
@@ -95,3 +95,23 @@
   y.g();
 }
 void CallLocalAnonStruct() { LocalAnonStruct(); }
+
+// CHECK: @_ZZ4Fun1vEN5Type15Type2IvE4Fun2Ev
+// CHECK: @_ZZZ4Fun1vEN5Type15Type2IvE4Fun2EvEN5Type35Type4IvE4Fun3Ev
+void Fun1() {
+  struct Type1 {
+    template <typename = void>
+    struct Type2 {
+      static void Fun2() {
+        struct Type3 {
+          template <typename = void>
+          struct Type4 {
+            static void Fun3() {}
+          };
+        };
+        Type3::template Type4<>::Fun3();
+      }
+    };
+  };
+  Type1::Type2<>::Fun2();
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to