CodeGen: fix a case of incorrect checks for ivars

Ensure that we check the ivar containing decl for the DLL storage
attribute rather than the ivar itself as the dll storage is associated
to the interface decl not the ivar decl.

llvm-svn: 316545
This commit is contained in:
Saleem Abdulrasool 2017-10-25 03:58:15 +00:00
parent f99c84d548
commit ad75c7d194
2 changed files with 18 additions and 4 deletions

View File

@ -6615,10 +6615,14 @@ CGObjCNonFragileABIMac::ObjCIvarOffsetVariable(const ObjCInterfaceDecl *ID,
Ivar->getAccessControl() == ObjCIvarDecl::Private ||
Ivar->getAccessControl() == ObjCIvarDecl::Package;
if (ID->hasAttr<DLLExportAttr>() && !IsPrivateOrPackage)
IvarOffsetGV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
else if (ID->hasAttr<DLLImportAttr>())
IvarOffsetGV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
const ObjCInterfaceDecl *ContainingID = Ivar->getContainingInterface();
if (ContainingID->hasAttr<DLLImportAttr>())
IvarOffsetGV
->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
else if (ContainingID->hasAttr<DLLExportAttr>() && !IsPrivateOrPackage)
IvarOffsetGV
->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
}
}
return IvarOffsetGV;

View File

@ -1,3 +1,4 @@
// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fdeclspec -fobjc-runtime=ios -fobjc-exceptions -S -emit-llvm -o - %s | FileCheck -check-prefix CHECK-IR %s
// RUN: %clang_cc1 -triple i686-windows-itanium -fms-extensions -fobjc-runtime=macosx -fdeclspec -fobjc-exceptions -S -emit-llvm -o - %s | FileCheck -check-prefix CHECK-IR %s
// RUN: %clang_cc1 -triple i686-windows-itanium -fms-extensions -fobjc-runtime=objfw -fdeclspec -fobjc-exceptions -S -emit-llvm -o - %s | FileCheck -check-prefix CHECK-FW %s
@ -114,6 +115,15 @@ __attribute__((__objc_exception__))
// CHECK-IR-DAG: @"OBJC_EHTYPE_$_P" = external global %struct._objc_typeinfo
@interface Q : M
@end
id f(Q *q) {
return q->_ivar;
}
// CHECK-IR-DAG: @"OBJC_IVAR_$_M._ivar" = external dllimport global i32
int g() {
@autoreleasepool {
M *mi = [M new];