In addition to the Sema tests, this change needs tests in CodeGenObjC to show where the attribute is applied in the IR.
--- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -2334,5 +2334,9 @@ llvm::Constant *CodeGenModule::getNSConcreteStackBlock() { Int8PtrTy->getPointerTo(), nullptr); configureBlocksRuntimeObject(*this, NSConcreteStackBlock); + if (getContext().getLangOpts().MSVCCompat) { + auto *GV = cast<llvm::GlobalValue>(NSConcreteStackBlock->stripPointerCasts()); + GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); + } return NSConcreteStackBlock; } I have a feeling that you want to configure all of these blocks runtime references to be dllimport, so maybe move this into configureBlocksRuntimeObject and do it before the early return. You probably also want to conditionalize these imports on Triple::isOSBinFormatCOFF() instead of MSVCCompat. Any Windows blocks runtime will want to import these. llvm::Value *CGObjCGNU::EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) { - return GetClassNamed(CGF, "NSAutoreleasePool", false); + return GetClassNamed(CGF, "NSAutoreleasePool", false, CGF.CGM.getTarget().getTriple().isKnownWindowsMSVCEnvironment()); } Again, probably isOSBinFormatCOFF. I suppose you don't want to use dllimport if the obj-c runtime is statically linked, so you might want to wrap this all up in a predicate like CGObjCGNU::isRuntimeDLLImport. Also, wrap to 80cols with clang-format. +++ b/test/SemaObjC/dllimport.m This file should have Unix line endings. On Mon, Apr 4, 2016 at 12:34 PM, Wes Witt via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Please accept this diff as a change to support dllimport of objective c > interfaces on windows. I’ve included a new test and changes to an existing > test as well. All clang tests pass on Linux & Windows. This change is > required for Microsoft’s use of the clang compiler in support of objective > c on windows. > > > > Thanks, > > Wes Witt > > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits