]> granicus.if.org Git - clang/commitdiff
If the key function of a record is inline, then the RTTI data should have weak_odr...
authorAnders Carlsson <andersca@mac.com>
Thu, 31 Dec 2009 19:36:25 +0000 (19:36 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 31 Dec 2009 19:36:25 +0000 (19:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92371 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGRTTI.cpp
test/CodeGenCXX/rtti-linkage.cpp

index b00b9155e865e11314df229fd7f40b65a28379d3..db6c5075ede4ec827f27e98c4f7ed9612d7aeecf 100644 (file)
@@ -372,6 +372,14 @@ static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(QualType Ty) {
       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;
+    KeyFunction->getBody(KeyFunctionDefinition);
+
+    if (KeyFunctionDefinition->isInlined())
+      return llvm::GlobalValue::WeakODRLinkage;
+      
     // Otherwise, the RTTI descriptor is emitted with external linkage.
     return llvm::GlobalValue::ExternalLinkage;
   }
index 63c19aa250c368061811a8056f20f2efca1e555c..799c1d41c72616c17bbb2af4bd835ea92d6456db 100644 (file)
@@ -24,6 +24,8 @@
 // CHECK: _ZTSM1AP1C = internal constant
 // CHECK: _ZTIM1AP1C = internal constant
 
+// CHECK: _ZTS1F = weak_odr constant
+
 // CHECK: _ZTSN12_GLOBAL__N_11DE = internal constant
 // CHECK: _ZTIN12_GLOBAL__N_11DE = internal constant
 // CHECK: _ZTSPN12_GLOBAL__N_11DE = internal constant
@@ -76,6 +78,13 @@ namespace {
   
 };
 
+// F has a key function defined in the translation unit, but it is inline so the RTTI
+// data should be emitted with weak_odr linkage.
+struct F {
+  virtual void f();
+};
+
+inline void F::f() { }
 const D getD();
 
 const std::type_info &t2() {