r316545 - CodeGen: fix a case of incorrect checks for ivars
Saleem Abdulrasool via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 24 20:58:15 PDT 2017
Author: compnerd
Date: Tue Oct 24 20:58:15 2017
New Revision: 316545
URL: http://llvm.org/viewvc/llvm-project?rev=316545&view=rev
Log:
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.
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/test/CodeGenObjC/dllstorage.m
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=316545&r1=316544&r2=316545&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Oct 24 20:58:15 2017
@@ -6615,10 +6615,14 @@ CGObjCNonFragileABIMac::ObjCIvarOffsetVa
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;
Modified: cfe/trunk/test/CodeGenObjC/dllstorage.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/dllstorage.m?rev=316545&r1=316544&r2=316545&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/dllstorage.m (original)
+++ cfe/trunk/test/CodeGenObjC/dllstorage.m Tue Oct 24 20:58:15 2017
@@ -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
+ at interface Q : M
+ at 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];
More information about the cfe-commits
mailing list