From: Anders Carlsson Date: Fri, 11 Dec 2009 16:37:06 +0000 (+0000) Subject: Use GetAddrOfRTTI when getting the RTTI pointer for a base class. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e7135613a558020f003972b2a5ae5f8d5306508;p=clang Use GetAddrOfRTTI when getting the RTTI pointer for a base class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91127 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGRTTI.cpp b/lib/CodeGen/CGRTTI.cpp index c8ce4ec6b9..24b3efff6d 100644 --- a/lib/CodeGen/CGRTTI.cpp +++ b/lib/CodeGen/CGRTTI.cpp @@ -257,10 +257,7 @@ public: e = RD->bases_end(); i != e; ++i) { const CXXRecordDecl *Base = cast(i->getType()->getAs()->getDecl()); - if (Base->isPolymorphic()) - info.push_back(CGM.GenerateRTTIRef(Base)); - else - info.push_back(CGM.GenerateRTTI(Base)); + info.push_back(CGM.GetAddrOfRTTI(Base)); if (simple) break; int64_t offset; diff --git a/test/CodeGenCXX/rtti-linkage.cpp b/test/CodeGenCXX/rtti-linkage.cpp new file mode 100644 index 0000000000..a2a1cdd48c --- /dev/null +++ b/test/CodeGenCXX/rtti-linkage.cpp @@ -0,0 +1,16 @@ +// RUN: clang-cc %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s + +// CHECK: _ZTS1B = constant +// CHECK: _ZTS1A = weak_odr constant +// CHECK: _ZTI1A = weak_odr constant +// CHECK: _ZTI1B = constant + +// A has no key function, so its RTTI data should be weak_odr. +struct A { }; + +// B has a key function defined in the translation unit, so the RTTI data should +// be emitted in this translation unit and have external linkage. +struct B : A { + virtual void f(); +}; +void B::f() { }