Fix linkage of type info and vtable for classes without linkage.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91152 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGRTTI.cpp b/lib/CodeGen/CGRTTI.cpp
index a574703..a15ba4f 100644
--- a/lib/CodeGen/CGRTTI.cpp
+++ b/lib/CodeGen/CGRTTI.cpp
@@ -230,7 +230,7 @@
       return llvm::ConstantExpr::getBitCast(GV, Int8PtrTy);
 
     // If we're in an anonymous namespace, then we always want internal linkage.
-    if (RD->isInAnonymousNamespace())
+    if (RD->isInAnonymousNamespace() || !RD->hasLinkage())
       Linkage = llvm::GlobalVariable::InternalLinkage;
     
     bool Hidden = CGM.getDeclVisibilityMode(RD) == LangOptions::Hidden;
@@ -295,7 +295,7 @@
       return DecideExtern(PT->getPointeeType());
     if (const RecordType *RT = Ty->getAs<RecordType>())
       if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl()))
-        return !RD->isInAnonymousNamespace();
+        return !RD->isInAnonymousNamespace() && RD->hasLinkage();
     return true;
   }
 
diff --git a/lib/CodeGen/CGVtable.cpp b/lib/CodeGen/CGVtable.cpp
index 752f69c..868a341 100644
--- a/lib/CodeGen/CGVtable.cpp
+++ b/lib/CodeGen/CGVtable.cpp
@@ -1458,7 +1458,7 @@
   }
 
   llvm::GlobalVariable::LinkageTypes Linkage;
-  if (RD->isInAnonymousNamespace())
+  if (RD->isInAnonymousNamespace() || !RD->hasLinkage())
     Linkage = llvm::GlobalVariable::InternalLinkage;
   else if (KeyFunction && !MD->isInlined())
     Linkage = llvm::GlobalVariable::ExternalLinkage;