aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/LangOptions.h5
-rw-r--r--include/clang/Driver/CC1Options.td6
-rw-r--r--include/clang/Driver/ToolChain.h10
-rw-r--r--include/clang/Frontend/CodeGenOptions.h1
-rw-r--r--lib/ARCMigrate/ARCMT.cpp2
-rw-r--r--lib/ARCMigrate/TransBlockObjCVariable.cpp4
-rw-r--r--lib/ARCMigrate/TransProperties.cpp4
-rw-r--r--lib/CodeGen/CGObjC.cpp10
-rw-r--r--lib/Driver/Compilation.cpp1
-rw-r--r--lib/Driver/ToolChain.cpp19
-rw-r--r--lib/Driver/ToolChains.cpp12
-rw-r--r--lib/Driver/ToolChains.h4
-rw-r--r--lib/Driver/Tools.cpp109
-rw-r--r--lib/Frontend/CompilerInvocation.cpp12
-rw-r--r--lib/Frontend/InitPreprocessor.cpp4
-rw-r--r--lib/Lex/PPMacroExpansion.cpp2
-rw-r--r--lib/Sema/SemaObjCProperty.cpp2
-rw-r--r--lib/Sema/SemaType.cpp4
-rw-r--r--test/ARCMT/assign-prop-no-arc-runtime.m2
-rw-r--r--test/ARCMT/assign-prop-no-arc-runtime.m.result2
-rw-r--r--test/ARCMT/assign-prop-with-arc-runtime.m2
-rw-r--r--test/ARCMT/assign-prop-with-arc-runtime.m.result2
-rw-r--r--test/ARCMT/rewrite-block-var.m2
-rw-r--r--test/ARCMT/rewrite-block-var.m.result2
-rw-r--r--test/CodeGenObjC/arc-block-ivar-layout.m2
-rw-r--r--test/CodeGenObjC/arc-foreach.m2
-rw-r--r--test/CodeGenObjC/arc-ivar-layout.m2
-rw-r--r--test/CodeGenObjC/arc-no-runtime.m2
-rw-r--r--test/CodeGenObjC/arc-unopt.m2
-rw-r--r--test/CodeGenObjC/arc-weak-property.m2
-rw-r--r--test/CodeGenObjC/arc.m4
-rw-r--r--test/CodeGenObjC/autorelease.m4
-rw-r--r--test/CodeGenObjCXX/arc-mangle.mm2
-rw-r--r--test/CodeGenObjCXX/arc-new-delete.mm2
-rw-r--r--test/CodeGenObjCXX/arc-pseudo-destructors.mm2
-rw-r--r--test/CodeGenObjCXX/arc-references.mm2
-rw-r--r--test/CodeGenObjCXX/arc.mm2
-rw-r--r--test/Driver/ios-simulator-arcruntime.c8
-rw-r--r--test/Lexer/has_feature_objc_arc.m4
-rw-r--r--test/SemaObjC/arc-no-runtime.m2
-rw-r--r--test/SemaObjC/arc-non-pod-memaccess.m4
-rw-r--r--test/SemaObjC/arc-property-decl-attrs.m2
-rw-r--r--test/SemaObjC/arc-property-lifetime.m2
-rw-r--r--test/SemaObjC/arc-property.m2
-rw-r--r--test/SemaObjC/arc-type-conversion.m2
-rw-r--r--test/SemaObjC/arc.m2
-rw-r--r--test/SemaObjC/warn-retain-cycle.m2
-rw-r--r--test/SemaObjC/weak-property.m2
-rw-r--r--test/SemaObjCXX/arc-libcxx.mm2
-rw-r--r--test/SemaObjCXX/arc-libstdcxx.mm2
-rw-r--r--test/SemaObjCXX/arc-object-init-destroy.mm2
-rw-r--r--test/SemaObjCXX/arc-overloading.mm2
-rw-r--r--test/SemaObjCXX/arc-templates.mm2
-rw-r--r--test/SemaObjCXX/arc-type-conversion.mm2
-rw-r--r--test/SemaObjCXX/arc-type-traits.mm2
55 files changed, 171 insertions, 128 deletions
diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h
index 7eda0aa3fd..6d4dc5b8dc 100644
--- a/include/clang/Basic/LangOptions.h
+++ b/include/clang/Basic/LangOptions.h
@@ -131,7 +131,7 @@ public:
// FIXME: This is just a temporary option, for testing purposes.
unsigned NoBitFieldTypeAlign : 1;
unsigned ObjCAutoRefCount : 1; // Objective C automated reference counting
- unsigned ObjCNoAutoRefCountRuntime : 1; // ARC w/o extra runtime support
+ unsigned ObjCRuntimeHasWeak : 1; // The ARC runtime supports __weak
unsigned ObjCInferRelatedReturnType : 1; // Infer Objective-C related return
// types
unsigned FakeAddressSpaceMap : 1; // Use a fake address space map, for
@@ -176,7 +176,8 @@ public:
Trigraphs = BCPLComment = Bool = DollarIdents = AsmPreprocessor = 0;
GNUMode = GNUKeywords = ImplicitInt = Digraphs = 0;
HexFloats = 0;
- ObjCAutoRefCount = ObjCNoAutoRefCountRuntime = 0;
+ ObjCAutoRefCount = 0;
+ ObjCRuntimeHasWeak = 0;
ObjCInferRelatedReturnType = 0;
GC = ObjC1 = ObjC2 = ObjCNonFragileABI = ObjCNonFragileABI2 = 0;
AppleKext = 0;
diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td
index 653f346b9e..aab0213b95 100644
--- a/include/clang/Driver/CC1Options.td
+++ b/include/clang/Driver/CC1Options.td
@@ -494,10 +494,12 @@ def fobjc_arc : Flag<"-fobjc-arc">,
HelpText<"Synthesize retain and release calls for Objective-C pointers">;
def fobjc_arc_cxxlib_EQ : Joined<"-fobjc-arc-cxxlib=">,
HelpText<"Objective-C++ Automatic Reference Counting standard library kind">;
-def fobjc_no_arc_runtime : Flag<"-fobjc-no-arc-runtime">,
- HelpText<"Implement -fobjc-arc without any extra runtime support">;
def fobjc_arc_exceptions : Flag<"-fobjc-arc-exceptions">,
HelpText<"Use EH-safe code when synthesizing retains and releases in -fobjc-arc">;
+def fobjc_runtime_has_arc : Flag<"-fobjc-runtime-has-arc">,
+ HelpText<"The target Objective-C runtime provides ARC entrypoints">;
+def fobjc_runtime_has_weak : Flag<"-fobjc-runtime-has-weak">,
+ HelpText<"The target Objective-C runtime supports ARC weak operations">;
def fobjc_gc : Flag<"-fobjc-gc">,
HelpText<"Enable Objective-C garbage collection">;
def fobjc_gc_only : Flag<"-fobjc-gc-only">,
diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h
index a570beaf79..4836d3ffac 100644
--- a/include/clang/Driver/ToolChain.h
+++ b/include/clang/Driver/ToolChain.h
@@ -26,6 +26,7 @@ namespace driver {
class HostInfo;
class InputArgList;
class JobAction;
+ class ObjCRuntime;
class Tool;
/// ToolChain - Access to tools for a single platform.
@@ -166,9 +167,6 @@ public:
/// UseSjLjExceptions - Does this tool chain use SjLj exceptions.
virtual bool UseSjLjExceptions() const { return false; }
- /// HasARCRuntime - Does this tool chain provide a specialized ARC runtime.
- virtual bool HasARCRuntime() const { return true; }
-
/// ComputeLLVMTriple - Return the LLVM target triple to use, after taking
/// command line arguments into account.
virtual std::string ComputeLLVMTriple(const ArgList &Args) const;
@@ -180,6 +178,12 @@ public:
/// Clang.
virtual std::string ComputeEffectiveClangTriple(const ArgList &Args) const;
+ /// configureObjCRuntime - Configure the known properties of the
+ /// Objective-C runtime for this platform.
+ ///
+ /// FIXME: this doesn't really belong here.
+ virtual void configureObjCRuntime(ObjCRuntime &runtime) const;
+
// GetCXXStdlibType - Determine the C++ standard library type to use with the
// given compilation arguments.
virtual CXXStdlibType GetCXXStdlibType(const ArgList &Args) const;
diff --git a/include/clang/Frontend/CodeGenOptions.h b/include/clang/Frontend/CodeGenOptions.h
index 2191980b95..d415d0a889 100644
--- a/include/clang/Frontend/CodeGenOptions.h
+++ b/include/clang/Frontend/CodeGenOptions.h
@@ -76,6 +76,7 @@ public:
unsigned NoNaNsFPMath : 1; /// Assume FP arguments, results not NaN.
unsigned NoZeroInitializedInBSS : 1; /// -fno-zero-initialized-in-bss
unsigned ObjCDispatchMethod : 2; /// Method of Objective-C dispatch to use.
+ unsigned ObjCRuntimeHasARC : 1; /// The target runtime supports ARC natively
unsigned OmitLeafFramePointer : 1; /// Set when -momit-leaf-frame-pointer is
/// enabled.
unsigned OptimizationLevel : 3; /// The -O[0-4] option specified.
diff --git a/lib/ARCMigrate/ARCMT.cpp b/lib/ARCMigrate/ARCMT.cpp
index 7f3479604e..0678a255d7 100644
--- a/lib/ARCMigrate/ARCMT.cpp
+++ b/lib/ARCMigrate/ARCMT.cpp
@@ -189,7 +189,7 @@ CompilerInvocation *createInvocationForMigration(CompilerInvocation &origCI) {
CInvok->getDiagnosticOpts().ErrorLimit = 0;
CInvok->getDiagnosticOpts().Warnings.push_back(
"error=arc-unsafe-retained-assign");
- CInvok->getLangOpts().ObjCNoAutoRefCountRuntime = !HasARCRuntime(origCI);
+ CInvok->getLangOpts().ObjCRuntimeHasWeak = HasARCRuntime(origCI);
return CInvok.take();
}
diff --git a/lib/ARCMigrate/TransBlockObjCVariable.cpp b/lib/ARCMigrate/TransBlockObjCVariable.cpp
index ba556277cc..97695cbccf 100644
--- a/lib/ARCMigrate/TransBlockObjCVariable.cpp
+++ b/lib/ARCMigrate/TransBlockObjCVariable.cpp
@@ -98,12 +98,12 @@ public:
BlocksAttr *attr = var->getAttr<BlocksAttr>();
if(!attr)
continue;
- bool hasARCRuntime = !Pass.Ctx.getLangOptions().ObjCNoAutoRefCountRuntime;
+ bool hasWeak = Pass.Ctx.getLangOptions().ObjCRuntimeHasWeak;
SourceManager &SM = Pass.Ctx.getSourceManager();
Transaction Trans(Pass.TA);
Pass.TA.replaceText(SM.getInstantiationLoc(attr->getLocation()),
"__block",
- hasARCRuntime ? "__weak" : "__unsafe_unretained");
+ hasWeak ? "__weak" : "__unsafe_unretained");
}
}
diff --git a/lib/ARCMigrate/TransProperties.cpp b/lib/ARCMigrate/TransProperties.cpp
index e0009ac241..0efc4c0fad 100644
--- a/lib/ARCMigrate/TransProperties.cpp
+++ b/lib/ARCMigrate/TransProperties.cpp
@@ -112,7 +112,7 @@ public:
}
void applyWeak(PropData &prop) {
- assert(!Pass.Ctx.getLangOptions().ObjCNoAutoRefCountRuntime);
+ assert(Pass.Ctx.getLangOptions().ObjCRuntimeHasWeak);
Transaction Trans(Pass.TA);
Pass.TA.insert(prop.IvarD->getLocation(), "__weak ");
@@ -157,7 +157,7 @@ public:
// There is a "error: existing ivar for assign property must be
// __unsafe_unretained"; fix it.
- if (Pass.Ctx.getLangOptions().ObjCNoAutoRefCountRuntime) {
+ if (!Pass.Ctx.getLangOptions().ObjCRuntimeHasWeak) {
// We will just add __unsafe_unretained to the ivar.
Transaction Trans(Pass.TA);
Pass.TA.insert(ivarD->getLocation(), "__unsafe_unretained ");
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index db9873b817..d8ce1f4a75 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -1311,7 +1311,7 @@ static llvm::Constant *createARCRuntimeFunction(CodeGenModule &CGM,
// In -fobjc-no-arc-runtime, emit weak references to the runtime
// support library.
- if (CGM.getLangOptions().ObjCNoAutoRefCountRuntime)
+ if (!CGM.getCodeGenOpts().ObjCRuntimeHasARC)
if (llvm::Function *f = dyn_cast<llvm::Function>(fn))
f->setLinkage(llvm::Function::ExternalWeakLinkage);
@@ -2457,13 +2457,7 @@ void CodeGenFunction::EmitObjCAutoreleasePoolStmt(
// Keep track of the current cleanup stack depth.
RunCleanupsScope Scope(*this);
- const llvm::Triple Triple = getContext().Target.getTriple();
- if (CGM.getLangOptions().ObjCAutoRefCount ||
- (CGM.isTargetDarwin() &&
- ((Triple.getArch() == llvm::Triple::x86_64 &&
- !Triple.isMacOSXVersionLT(10,7,0))
- || (Triple.getEnvironmentName() == "iphoneos" &&
- !Triple.isOSVersionLT(5,0))))) {
+ if (CGM.getCodeGenOpts().ObjCRuntimeHasARC) {
llvm::Value *token = EmitObjCAutoreleasePoolPush();
EHStack.pushCleanup<CallObjCAutoreleasePoolObject>(NormalCleanup, token);
} else {
diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp
index 2657faa0d3..e15e40295c 100644
--- a/lib/Driver/Compilation.cpp
+++ b/lib/Driver/Compilation.cpp
@@ -13,6 +13,7 @@
#include "clang/Driver/ArgList.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/ObjCRuntime.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/ToolChain.h"
diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp
index cbbbc5c4de..0cce517549 100644
--- a/lib/Driver/ToolChain.cpp
+++ b/lib/Driver/ToolChain.cpp
@@ -15,7 +15,9 @@
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/HostInfo.h"
+#include "clang/Driver/ObjCRuntime.h"
#include "clang/Driver/Options.h"
+#include "llvm/Support/ErrorHandling.h"
using namespace clang::driver;
@@ -47,6 +49,23 @@ bool ToolChain::HasNativeLLVMSupport() const {
return false;
}
+void ToolChain::configureObjCRuntime(ObjCRuntime &runtime) const {
+ switch (runtime.getKind()) {
+ case ObjCRuntime::NeXT:
+ // Assume a minimal NeXT runtime.
+ runtime.HasARC = false;
+ runtime.HasWeak = false;
+ return;
+
+ case ObjCRuntime::GNU:
+ // Assume a maximal GNU runtime.
+ runtime.HasARC = true;
+ runtime.HasWeak = true;
+ return;
+ }
+ llvm_unreachable("invalid runtime kind!");
+}
+
/// getARMTargetCPU - Get the (LLVM) name of the ARM cpu we are targeting.
//
// FIXME: tblgen this.
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index b4501acbb1..68ebc1b6b3 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -19,6 +19,7 @@
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/HostInfo.h"
+#include "clang/Driver/ObjCRuntime.h"
#include "clang/Driver/OptTable.h"
#include "clang/Driver/Option.h"
#include "clang/Driver/Options.h"
@@ -74,8 +75,7 @@ bool Darwin::HasNativeLLVMSupport() const {
return true;
}
-/// Darwin provides an ARC runtime starting in MacOS X 10.7 and iOS 5.0.
-bool Darwin::HasARCRuntime() const {
+bool Darwin::hasARCRuntime() const {
// FIXME: Remove this once there is a proper way to detect an ARC runtime
// for the simulator.
switch (ARCRuntimeForSimulator) {
@@ -93,6 +93,14 @@ bool Darwin::HasARCRuntime() const {
return !isMacosxVersionLT(10, 7);
}
+/// Darwin provides an ARC runtime starting in MacOS X 10.7 and iOS 5.0.
+void Darwin::configureObjCRuntime(ObjCRuntime &runtime) const {
+ if (runtime.getKind() != ObjCRuntime::NeXT)
+ return ToolChain::configureObjCRuntime(runtime);
+
+ runtime.HasARC = runtime.HasWeak = hasARCRuntime();
+}
+
// FIXME: Can we tablegen this?
static const char *GetArmArchForMArch(llvm::StringRef Value) {
if (Value == "armv6k")
diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h
index 9ed0dc2ef8..d68016b3a2 100644
--- a/lib/Driver/ToolChains.h
+++ b/lib/Driver/ToolChains.h
@@ -80,6 +80,8 @@ private:
/// initialized.
std::string MacosxVersionMin;
+ bool hasARCRuntime() const;
+
private:
void AddDeploymentTarget(DerivedArgList &Args) const;
@@ -184,7 +186,7 @@ public:
virtual bool HasNativeLLVMSupport() const;
- virtual bool HasARCRuntime() const;
+ virtual void configureObjCRuntime(ObjCRuntime &runtime) const;
virtual DerivedArgList *TranslateArgs(const DerivedArgList &Args,
const char *BoundArch) const;
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 4e70c5c372..d0fd914bf0 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -17,6 +17,7 @@
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Job.h"
#include "clang/Driver/HostInfo.h"
+#include "clang/Driver/ObjCRuntime.h"
#include "clang/Driver/Option.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/ToolChain.h"
@@ -1600,47 +1601,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
options::OPT_fno_lax_vector_conversions))
CmdArgs.push_back("-fno-lax-vector-conversions");
- // Allow -fno-objc-arr to trump -fobjc-arr/-fobjc-arc.
- // NOTE: This logic is duplicated in ToolChains.cpp.
- bool ARC = isObjCAutoRefCount(Args);
- if (ARC) {
- CmdArgs.push_back("-fobjc-arc");
-
- // Certain deployment targets don't have runtime support.
- if (!getToolChain().HasARCRuntime())
- CmdArgs.push_back("-fobjc-no-arc-runtime");
-
- // Allow the user to enable full exceptions code emission.
- // We define off for Objective-CC, on for Objective-C++.
- if (Args.hasFlag(options::OPT_fobjc_arc_exceptions,
- options::OPT_fno_objc_arc_exceptions,
- /*default*/ types::isCXX(InputType)))
- CmdArgs.push_back("-fobjc-arc-exceptions");
- }
-
- // -fobjc-infer-related-result-type is the default, except in the Objective-C
- // rewriter.
- if (IsRewriter)
- CmdArgs.push_back("-fno-objc-infer-related-result-type");
-
- // Handle -fobjc-gc and -fobjc-gc-only. They are exclusive, and -fobjc-gc-only
- // takes precedence.
- const Arg *GCArg = Args.getLastArg(options::OPT_fobjc_gc_only);
- if (!GCArg)
- GCArg = Args.getLastArg(options::OPT_fobjc_gc);
- if (GCArg) {
- if (ARC) {
- D.Diag(clang::diag::err_drv_objc_gc_arr)
- << GCArg->getAsString(Args);
- } else if (getToolChain().SupportsObjCGC()) {
- GCArg->render(Args, CmdArgs);
- } else {
- // FIXME: We should move this to a hard error.
- D.Diag(clang::diag::warn_drv_objc_gc_unsupported)
- << GCArg->getAsString(Args);
- }
- }
-
if (Args.getLastArg(options::OPT_fapple_kext))
CmdArgs.push_back("-fapple-kext");
@@ -1805,17 +1765,23 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
false))
CmdArgs.push_back("-fgnu89-inline");
- // -fnext-runtime defaults to on Darwin and when rewriting Objective-C, and is
- // -the -cc1 default.
- bool NeXTRuntimeIsDefault =
- IsRewriter || getToolChain().getTriple().getOS() == llvm::Triple::Darwin;
- if (!Args.hasFlag(options::OPT_fnext_runtime, options::OPT_fgnu_runtime,
- NeXTRuntimeIsDefault))
- CmdArgs.push_back("-fgnu-runtime");
-
// -fobjc-nonfragile-abi=0 is default.
+ ObjCRuntime objCRuntime;
unsigned objcABIVersion = 0;
if (types::isObjC(InputType)) {
+ bool NeXTRuntimeIsDefault
+ = (IsRewriter || getToolChain().getTriple().isOSDarwin());
+ if (Args.hasFlag(options::OPT_fnext_runtime, options::OPT_fgnu_runtime,
+ NeXTRuntimeIsDefault))
+ objCRuntime.setKind(ObjCRuntime::NeXT);
+ else
+ objCRuntime.setKind(ObjCRuntime::GNU);
+ getToolChain().configureObjCRuntime(objCRuntime);
+ if (objCRuntime.HasARC)
+ CmdArgs.push_back("-fobjc-runtime-has-arc");
+ if (objCRuntime.HasWeak)
+ CmdArgs.push_back("-fobjc-runtime-has-weak");
+
// Compute the Objective-C ABI "version" to use. Version numbers are
// slightly confusing for historical reasons:
// 1 - Traditional "fragile" ABI
@@ -1890,6 +1856,43 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
#endif
}
+ // Allow -fno-objc-arr to trump -fobjc-arr/-fobjc-arc.
+ // NOTE: This logic is duplicated in ToolChains.cpp.
+ bool ARC = isObjCAutoRefCount(Args);
+ if (ARC) {
+ CmdArgs.push_back("-fobjc-arc");
+
+ // Allow the user to enable full exceptions code emission.
+ // We define off for Objective-CC, on for Objective-C++.
+ if (Args.hasFlag(options::OPT_fobjc_arc_exceptions,
+ options::OPT_fno_objc_arc_exceptions,
+ /*default*/ types::isCXX(InputType)))
+ CmdArgs.push_back("-fobjc-arc-exceptions");
+ }
+
+ // -fobjc-infer-related-result-type is the default, except in the Objective-C
+ // rewriter.
+ if (IsRewriter)
+ CmdArgs.push_back("-fno-objc-infer-related-result-type");
+
+ // Handle -fobjc-gc and -fobjc-gc-only. They are exclusive, and -fobjc-gc-only
+ // takes precedence.
+ const Arg *GCArg = Args.getLastArg(options::OPT_fobjc_gc_only);
+ if (!GCArg)
+ GCArg = Args.getLastArg(options::OPT_fobjc_gc);
+ if (GCArg) {
+ if (ARC) {
+ D.Diag(clang::diag::err_drv_objc_gc_arr)
+ << GCArg->getAsString(Args);
+ } else if (getToolChain().SupportsObjCGC()) {
+ GCArg->render(Args, CmdArgs);
+ } else {
+ // FIXME: We should move this to a hard error.
+ D.Diag(clang::diag::warn_drv_objc_gc_unsupported)
+ << GCArg->getAsString(Args);
+ }
+ }
+
// Add exception args.
addExceptionArgs(Args, InputType, getToolChain().getTriple(),
KernelOrKext, IsRewriter, objcABIVersion, CmdArgs);
@@ -3237,8 +3240,12 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
// In ARC, if we don't have runtime support, link in the runtime
// stubs. We have to do this *before* adding any of the normal
// linker inputs so that its initializer gets run first.
- if (!getDarwinToolChain().HasARCRuntime() && isObjCAutoRefCount(Args))
- getDarwinToolChain().AddLinkARCArgs(Args, CmdArgs);
+ if (isObjCAutoRefCount(Args)) {
+ ObjCRuntime runtime;
+ getDarwinToolChain().configureObjCRuntime(runtime);
+ if (!runtime.HasARC)
+ getDarwinToolChain().AddLinkARCArgs(Args, CmdArgs);
+ }
AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 12e51a61e1..31c86432b7 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -123,6 +123,8 @@ static void CodeGenOptsToArgs(const CodeGenOptions &Opts,
Res.push_back("-dwarf-debug-flags");
Res.push_back(Opts.DwarfDebugFlags);
}
+ if (Opts.ObjCRuntimeHasARC)
+ Res.push_back("-fobjc-runtime-has-arc");
if (Opts.EmitGcovArcs)
Res.push_back("-femit-coverage-data");
if (Opts.EmitGcovNotes)
@@ -690,8 +692,8 @@ static void LangOptsToArgs(const LangOptions &Opts,
}
if (Opts.ObjCAutoRefCount)
Res.push_back("-fobjc-arc");
- if (Opts.ObjCNoAutoRefCountRuntime)
- Res.push_back("-fobjc-no-arc-runtime");
+ if (Opts.ObjCRuntimeHasWeak)
+ Res.push_back("-fobjc-runtime-has-weak");
if (!Opts.ObjCInferRelatedResultType)
Res.push_back("-fno-objc-infer-related-result-type");
@@ -976,6 +978,7 @@ static void ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.AsmVerbose = Args.hasArg(OPT_masm_verbose);
Opts.ObjCAutoRefCountExceptions = Args.hasArg(OPT_fobjc_arc_exceptions);
+ Opts.ObjCRuntimeHasARC = Args.hasArg(OPT_fobjc_runtime_has_arc);
Opts.CXAAtExit = !Args.hasArg(OPT_fno_use_cxa_atexit);
Opts.CXXCtorDtorAliases = Args.hasArg(OPT_mconstructor_aliases);
Opts.CodeModel = Args.getLastArgValue(OPT_mcode_model);
@@ -1532,10 +1535,11 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.ObjCAutoRefCount = 1;
if (!Args.hasArg(OPT_fobjc_nonfragile_abi))
Diags.Report(diag::err_arc_nonfragile_abi);
- if (Args.hasArg(OPT_fobjc_no_arc_runtime))
- Opts.ObjCNoAutoRefCountRuntime = 1;
}
+ if (Args.hasArg(OPT_fobjc_runtime_has_weak))
+ Opts.ObjCRuntimeHasWeak = 1;
+
if (Args.hasArg(OPT_fno_objc_infer_related_result_type))
Opts.ObjCInferRelatedResultType = 0;
}
diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp
index b07fb4395f..9428cd5de0 100644
--- a/lib/Frontend/InitPreprocessor.cpp
+++ b/lib/Frontend/InitPreprocessor.cpp
@@ -250,7 +250,7 @@ static void AddObjCXXARCLibcxxDefines(const LangOptions &LangOpts,
<< "}\n"
<< "\n";
- if (!LangOpts.ObjCNoAutoRefCountRuntime) {
+ if (LangOpts.ObjCRuntimeHasWeak) {
Out << "template <class _Tp>\n"
<< "inline __attribute__ ((__visibility__(\"hidden\"),"
<< "__always_inline__))\n"
@@ -318,7 +318,7 @@ static void AddObjCXXARCLibstdcxxDefines(const LangOptions &LangOpts,
<< "};\n"
<< "\n";
- if (!LangOpts.ObjCNoAutoRefCountRuntime) {
+ if (LangOpts.ObjCRuntimeHasWeak) {
Out << "template<typename _Tp>\n"
<< "struct __is_scalar<__attribute__((objc_ownership(weak))) _Tp> {\n"
<< " enum { __value = 0 };\n"
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp
index d7c4defb36..f1d03713a9 100644
--- a/lib/Lex/PPMacroExpansion.cpp
+++ b/lib/Lex/PPMacroExpansion.cpp
@@ -596,7 +596,7 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
.Case("objc_arr", LangOpts.ObjCAutoRefCount) // FIXME: REMOVE?
.Case("objc_arc", LangOpts.ObjCAutoRefCount)
.Case("objc_arc_weak", LangOpts.ObjCAutoRefCount &&
- !LangOpts.ObjCNoAutoRefCountRuntime)