Don't use mangleCXXRTTIName in TBAA for C code.

This changes the TBAA code so it doesn't use mangleCXXRTTIName in C,
because it doesn't really make sense there.  Also, as sort of a
defense-in-depth change, fix the mangler so it handles C RecordDecls
correctly.

No tests because I don't know the TBAA code well enough to write a test,
and I don't know how else to trigger mangling a local struct in C.

Fixes a crash with r185450 reported by Joerg Sonnenberger.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185721 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp
index adfc3a7..7921982 100644
--- a/lib/AST/ItaniumMangle.cpp
+++ b/lib/AST/ItaniumMangle.cpp
@@ -72,11 +72,11 @@
   return isa<FunctionDecl>(DC) || isa<ObjCMethodDecl>(DC) || isa<BlockDecl>(DC);
 }
 
-static const CXXRecordDecl *GetLocalClassDecl(const Decl *D) {
+static const RecordDecl *GetLocalClassDecl(const Decl *D) {
   const DeclContext *DC = getEffectiveDeclContext(D);
   while (!DC->isNamespace() && !DC->isTranslationUnit()) {
     if (isLocalContainerContext(DC))
-      return dyn_cast<CXXRecordDecl>(D);
+      return dyn_cast<RecordDecl>(D);
     D = cast<Decl>(DC);
     DC = getEffectiveDeclContext(D);
   }
@@ -1280,7 +1280,7 @@
   //                 _ <entity name>
   // <discriminator> := _ <non-negative number>
   assert(isa<NamedDecl>(D) || isa<BlockDecl>(D));
-  const CXXRecordDecl *RD = GetLocalClassDecl(D);
+  const RecordDecl *RD = GetLocalClassDecl(D);
   const DeclContext *DC = getEffectiveDeclContext(RD ? RD : D);
 
   Out << 'Z';
@@ -1301,9 +1301,10 @@
     // numbering will be local to the particular argument in which it appears
     // -- other default arguments do not affect its encoding.
     bool SkipDiscriminator = false;
-    if (RD->isLambda()) {
+    const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD);
+    if (CXXRD->isLambda()) {
       if (const ParmVarDecl *Parm
-                 = dyn_cast_or_null<ParmVarDecl>(RD->getLambdaContextDecl())) {
+              = dyn_cast_or_null<ParmVarDecl>(CXXRD->getLambdaContextDecl())) {
         if (const FunctionDecl *Func
               = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
           Out << 'd';