[cfe-commits] r122033 - in /cfe/trunk: lib/CodeGen/CGRTTI.cpp test/CodeGenCXX/rtti-linkage.cpp
John McCall
rjmccall at apple.com
Thu Dec 16 18:58:03 PST 2010
Author: rjmccall
Date: Thu Dec 16 20:58:03 2010
New Revision: 122033
URL: http://llvm.org/viewvc/llvm-project?rev=122033&view=rev
Log:
Give hidden visibility to RTTI for derived types. This is kindof a hacky
way to do this, but it fixes rdar://problem/8778973
Modified:
cfe/trunk/lib/CodeGen/CGRTTI.cpp
cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp
Modified: cfe/trunk/lib/CodeGen/CGRTTI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRTTI.cpp?rev=122033&r1=122032&r2=122033&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRTTI.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRTTI.cpp Thu Dec 16 20:58:03 2010
@@ -535,7 +535,8 @@
BuildVTablePointer(cast<Type>(Ty));
// And the name.
- Fields.push_back(BuildName(Ty, DecideHidden(Ty), Linkage));
+ bool Hidden = DecideHidden(Ty);
+ Fields.push_back(BuildName(Ty, Hidden, Linkage));
switch (Ty->getTypeClass()) {
#define TYPE(Class, Base)
@@ -636,8 +637,9 @@
if (const RecordType *RT = dyn_cast<RecordType>(Ty))
CGM.setTypeVisibility(GV, cast<CXXRecordDecl>(RT->getDecl()),
/*ForRTTI*/ true, /*ForDefinition*/ true);
- else if (CGM.getCodeGenOpts().HiddenWeakVTables &&
- Linkage == llvm::GlobalValue::WeakODRLinkage)
+ else if (Hidden ||
+ (CGM.getCodeGenOpts().HiddenWeakVTables &&
+ Linkage == llvm::GlobalValue::WeakODRLinkage))
GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
return llvm::ConstantExpr::getBitCast(GV, Int8PtrTy);
Modified: cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp?rev=122033&r1=122032&r2=122033&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp Thu Dec 16 20:58:03 2010
@@ -4,6 +4,10 @@
#include <typeinfo>
// CHECK-WITH-HIDDEN: _ZTSFN12_GLOBAL__N_11DEvE = internal constant
+// CHECK-WITH-HIDDEN: @_ZTSPK2T4 = weak_odr hidden constant
+// CHECK-WITH-HIDDEN: @_ZTS2T4 = weak_odr hidden constant
+// CHECK-WITH-HIDDEN: @_ZTI2T4 = weak_odr hidden constant
+// CHECK-WITH-HIDDEN: @_ZTIPK2T4 = weak_odr hidden constant
// CHECK: _ZTSP1C = internal constant
// CHECK: _ZTS1C = internal constant
@@ -128,3 +132,9 @@
(void) typeid(T<1>);
(void) typeid(T<2>);
}
+
+// rdar://problem/8778973
+struct T4 {};
+void t4(const T4 *ptr) {
+ const void *value = &typeid(ptr);
+}
More information about the cfe-commits
mailing list