Fix for PR5706: let mangleName deal with mangling names without identifiers
correctly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91136 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index d156ba5..57f125e 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -877,10 +877,7 @@
   mangleType(static_cast<const TagType*>(T));
 }
 void CXXNameMangler::mangleType(const TagType *T) {
-  if (!T->getDecl()->getIdentifier())
-    mangleName(T->getDecl()->getTypedefForAnonDecl());
-  else
-    mangleName(T->getDecl());
+  mangleName(T->getDecl());
 }
 
 // <type>       ::= <array-type>
diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp
index 38f3c8b..a2e92e9 100644
--- a/test/CodeGenCXX/mangle.cpp
+++ b/test/CodeGenCXX/mangle.cpp
@@ -228,3 +228,11 @@
 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;