[AST] Revert mangling changes from r339428

As discussed in https://reviews.llvm.org/D50144, we want Obj-C classes
to have the same mangling as C++ structs, to support headers like the
following:

```
@class I;
struct I;

void f(I *);
```

since the header can be used from both C++ and Obj-C++ TUs, and we want
a consistent mangling across the two to prevent link errors. Itanium
mangles both the same way, and so should the MS ABI.

The main concern with having the same mangling for C++ structs and Obj-C
classes was that we want to treat them differently for the purposes of
exception handling, e.g. we don't want a C++ catch statement for a
struct to be able to catch an Obj-C class with the same name as the
struct. We can accomplish this by mangling Obj-C class names differently
in their RTTI, which I'll do in a follow-up patch.

Differential Revision: https://reviews.llvm.org/D52581

llvm-svn: 343808
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index 1d4bdaa..072184d 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -482,7 +482,7 @@
     mangleFunctionEncoding(FD, Context.shouldMangleDeclName(FD));
   else if (const VarDecl *VD = dyn_cast<VarDecl>(D))
     mangleVariableEncoding(VD);
-  else if (!isa<ObjCInterfaceDecl>(D))
+  else
     llvm_unreachable("Tried to mangle unexpected NamedDecl!");
 }
 
@@ -1951,13 +1951,13 @@
     llvm_unreachable("placeholder types shouldn't get to name mangling");
 
   case BuiltinType::ObjCId:
-    mangleArtificalTagType(TTK_Struct, ".objc_object");
+    mangleArtificalTagType(TTK_Struct, "objc_object");
     break;
   case BuiltinType::ObjCClass:
-    mangleArtificalTagType(TTK_Struct, ".objc_class");
+    mangleArtificalTagType(TTK_Struct, "objc_class");
     break;
   case BuiltinType::ObjCSel:
-    mangleArtificalTagType(TTK_Struct, ".objc_selector");
+    mangleArtificalTagType(TTK_Struct, "objc_selector");
     break;
 
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
@@ -2637,10 +2637,9 @@
 
 void MicrosoftCXXNameMangler::mangleType(const ObjCInterfaceType *T, Qualifiers,
                                          SourceRange) {
-  // ObjC interfaces are mangled as if they were structs with a name that is
-  // not a valid C/C++ identifier
+  // ObjC interfaces have structs underlying them.
   mangleTagTypeKind(TTK_Struct);
-  mangle(T->getDecl(), ".objc_cls_");
+  mangleName(T->getDecl());
 }
 
 void MicrosoftCXXNameMangler::mangleType(const ObjCObjectType *T,
@@ -2661,11 +2660,11 @@
 
   Out << "?$";
   if (T->isObjCId())
-    mangleSourceName(".objc_object");
+    mangleSourceName("objc_object");
   else if (T->isObjCClass())
-    mangleSourceName(".objc_class");
+    mangleSourceName("objc_class");
   else
-    mangleSourceName((".objc_cls_" + T->getInterface()->getName()).str());
+    mangleSourceName(T->getInterface()->getName());
 
   for (const auto &Q : T->quals())
     mangleObjCProtocol(Q);