[cfe-commits] r91127 - in /cfe/trunk: lib/CodeGen/CGRTTI.cpp test/CodeGenCXX/rtti-linkage.cpp

Anders Carlsson andersca at mac.com
Fri Dec 11 08:37:06 PST 2009


Author: andersca
Date: Fri Dec 11 10:37:06 2009
New Revision: 91127

URL: http://llvm.org/viewvc/llvm-project?rev=91127&view=rev
Log:
Use GetAddrOfRTTI when getting the RTTI pointer for a base class.

Added:
    cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp
Modified:
    cfe/trunk/lib/CodeGen/CGRTTI.cpp

Modified: cfe/trunk/lib/CodeGen/CGRTTI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRTTI.cpp?rev=91127&r1=91126&r2=91127&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGRTTI.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRTTI.cpp Fri Dec 11 10:37:06 2009
@@ -257,10 +257,7 @@
              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;

Added: cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp?rev=91127&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp Fri Dec 11 10:37:06 2009
@@ -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() { }





More information about the cfe-commits mailing list