Fix linkage for RTTI names by re-using the logic for computing the
linkage of vtables. Before this, we were emitting RTTI names for
template instantiations with strong external linkage rather than with
weak ODR linkage.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92857 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGRTTI.cpp b/lib/CodeGen/CGRTTI.cpp
index 20e5fce..29552ce 100644
--- a/lib/CodeGen/CGRTTI.cpp
+++ b/lib/CodeGen/CGRTTI.cpp
@@ -360,27 +360,12 @@
     // If we're in an anonymous namespace, then we always want internal linkage.
     if (RD->isInAnonymousNamespace() || !RD->hasLinkage())
       return llvm::GlobalVariable::InternalLinkage;
-    
+
+    // If this class does not have a vtable, we want weak linkage.
     if (!RD->isDynamicClass())
       return llvm::GlobalValue::WeakODRLinkage;
     
-    // Get the key function.
-    const CXXMethodDecl *KeyFunction = RD->getASTContext().getKeyFunction(RD);
-    if (!KeyFunction) {
-      // There is no key function, the RTTI descriptor is emitted with weak_odr
-      // linkage.
-      return llvm::GlobalValue::WeakODRLinkage;
-    }
-
-    // If the key function is defined, but inlined, then the RTTI descriptor is
-    // emitted with weak_odr linkage.
-    const FunctionDecl* KeyFunctionDefinition;
-    if (KeyFunction->getBody(KeyFunctionDefinition) &&
-        KeyFunctionDefinition->isInlined())
-      return llvm::GlobalValue::WeakODRLinkage;
-      
-    // Otherwise, the RTTI descriptor is emitted with external linkage.
-    return llvm::GlobalValue::ExternalLinkage;
+    return CodeGenModule::getVtableLinkage(RD);
   }
 
   case Type::Vector: