]> granicus.if.org Git - clang/commitdiff
Use GetAddrOfRTTI when getting the RTTI pointer for a base class.
authorAnders Carlsson <andersca@mac.com>
Fri, 11 Dec 2009 16:37:06 +0000 (16:37 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 11 Dec 2009 16:37:06 +0000 (16:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91127 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGRTTI.cpp
test/CodeGenCXX/rtti-linkage.cpp [new file with mode: 0644]

index c8ce4ec6b991a31c280db849d63c62be0f1359a9..24b3efff6d9ee8c9f244ccc7a61c149b7f0c2ade 100644 (file)
@@ -257,10 +257,7 @@ public:
              e = RD->bases_end(); i != e; ++i) {
         const CXXRecordDecl *Base =
           cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->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 (file)
index 0000000..a2a1cdd
--- /dev/null
@@ -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() { }