зеркало из https://github.com/microsoft/clang-1.git
Fix linkage of type info and vtable for classes without linkage.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91152 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
6f9f25dfc7
Коммит
470fb73d4e
|
@ -230,7 +230,7 @@ public:
|
|||
return llvm::ConstantExpr::getBitCast(GV, Int8PtrTy);
|
||||
|
||||
// If we're in an anonymous namespace, then we always want internal linkage.
|
||||
if (RD->isInAnonymousNamespace())
|
||||
if (RD->isInAnonymousNamespace() || !RD->hasLinkage())
|
||||
Linkage = llvm::GlobalVariable::InternalLinkage;
|
||||
|
||||
bool Hidden = CGM.getDeclVisibilityMode(RD) == LangOptions::Hidden;
|
||||
|
@ -295,7 +295,7 @@ public:
|
|||
return DecideExtern(PT->getPointeeType());
|
||||
if (const RecordType *RT = Ty->getAs<RecordType>())
|
||||
if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl()))
|
||||
return !RD->isInAnonymousNamespace();
|
||||
return !RD->isInAnonymousNamespace() && RD->hasLinkage();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1458,7 +1458,7 @@ void CGVtableInfo::MaybeEmitVtable(GlobalDecl GD) {
|
|||
}
|
||||
|
||||
llvm::GlobalVariable::LinkageTypes Linkage;
|
||||
if (RD->isInAnonymousNamespace())
|
||||
if (RD->isInAnonymousNamespace() || !RD->hasLinkage())
|
||||
Linkage = llvm::GlobalVariable::InternalLinkage;
|
||||
else if (KeyFunction && !MD->isInlined())
|
||||
Linkage = llvm::GlobalVariable::ExternalLinkage;
|
||||
|
|
|
@ -28,6 +28,8 @@ struct D {
|
|||
|
||||
void D::f() { }
|
||||
|
||||
static struct : D { } e;
|
||||
|
||||
// B has a key function that is not defined in this translation unit so its vtable
|
||||
// has external linkage.
|
||||
// CHECK: @_ZTV1B = external constant
|
||||
|
@ -43,6 +45,12 @@ void D::f() { }
|
|||
// CHECK: @_ZTI1D = constant
|
||||
// CHECK: @_ZTV1D = constant
|
||||
|
||||
// The anonymous struct for e has no linkage, so the vtable should have
|
||||
// internal linkage.
|
||||
// CHECK: @"_ZTS3$_0" = internal constant
|
||||
// CHECK: @"_ZTI3$_0" = internal constant
|
||||
// CHECK: @"_ZTV3$_0" = internal constant
|
||||
|
||||
// The A vtable should have internal linkage since it is inside an anonymous
|
||||
// namespace.
|
||||
// CHECK: @_ZTSN12_GLOBAL__N_11AE = internal constant
|
||||
|
|
Загрузка…
Ссылка в новой задаче