]> granicus.if.org Git - clang/commitdiff
Make sure mangling doesn't crash in another case. Add some more tests.
authorEli Friedman <eli.friedman@gmail.com>
Fri, 11 Dec 2009 20:21:38 +0000 (20:21 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 11 Dec 2009 20:21:38 +0000 (20:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91149 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/Mangle.cpp
test/CodeGenCXX/mangle-unnamed.cpp [new file with mode: 0644]
test/CodeGenCXX/mangle.cpp

index 57f125e33669c04d8095acda03f84fe2bf4d17c9..afc70fa479aabc3d39185e8b496c62faf9cd0dc2 100644 (file)
@@ -548,7 +548,7 @@ void CXXNameMangler::mangleLocalName(const NamedDecl *ND) {
     mangleFunctionEncoding(cast<FunctionDecl>(ND->getDeclContext()));
 
   Out << 'E';
-  mangleSourceName(ND->getIdentifier());
+  mangleUnqualifiedName(ND);
 }
 
 void CXXNameMangler::manglePrefix(const DeclContext *DC) {
diff --git a/test/CodeGenCXX/mangle-unnamed.cpp b/test/CodeGenCXX/mangle-unnamed.cpp
new file mode 100644 (file)
index 0000000..66c81e5
--- /dev/null
@@ -0,0 +1,39 @@
+// RUN: clang-cc -emit-llvm-only -verify %s
+
+struct S {
+  virtual ~S() { }
+};
+
+// PR5706
+// Make sure this doesn't crash; the mangling doesn't matter because the name
+// doesn't have linkage.
+static struct : S { } obj8;
+
+void f() {
+  // Make sure this doesn't crash; the mangling doesn't matter because the
+  // generated vtable/etc. aren't modifiable (although it would be nice for
+  // codesize to make it consistent inside inline functions).
+  static struct : S { } obj8;
+}
+
+inline int f2() {
+  // FIXME: We don't mangle the names of a or x correctly!
+  static struct { int a() { static int x; return ++x; } } obj;
+  return obj.a();
+}
+
+int f3() { return f2(); }
+
+struct A {
+  typedef struct { int x; } *ptr;
+  ptr m;
+  int a() {
+    static struct x {
+      // FIXME: We don't mangle the names of a or x correctly!
+      int a(ptr A::*memp) { static int x; return ++x; }
+    } a;
+    return a.a(&A::m);
+  }
+};
+
+int f4() { return A().a(); }
index a2e92e9738d757fb8bd4ae5500862fa09c995574..38f3c8bd3fb364ff8ee297e8dd260976249566cf 100644 (file)
@@ -228,11 +228,3 @@ template<typename T> typename __enable_if<(__is_scalar<T>::__value), void>::__ty
 template void ft8<int>();
 // CHECK: @_Z3ft8IPvEN11__enable_ifIXsr11__is_scalarIT_E7__valueEvE6__typeEv
 template void ft8<void*>();
-
-// PR5706
-// This example was crashing in the mangler code
-struct S8 {
-  virtual ~S8() { }
-};
-
-static struct : S8 { } obj8;