From: David Chisnall Date: Fri, 30 Sep 2011 13:32:35 +0000 (+0000) Subject: Remove the conditional that avoided passing the Objective-C runtime specification... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3c3ccd283f8c35dbb200a76eacfa17f7861e03bb;p=clang Remove the conditional that avoided passing the Objective-C runtime specification flags to cc1. This fixes PR10369 (__builtin_NSStringMakeConstantString() selecting the wrong runtime in C / C++ code and crashing, although it doesn't fix the problem that instantiating the Mac runtime for non-Darwin targets was crashing.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140853 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index e9c6df10ef..936dee16c9 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1903,90 +1903,88 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // -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 { - CmdArgs.push_back("-fgnu-runtime"); - 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"); - if (objCRuntime.HasTerminate) - CmdArgs.push_back("-fobjc-runtime-has-terminate"); - - // Compute the Objective-C ABI "version" to use. Version numbers are - // slightly confusing for historical reasons: - // 1 - Traditional "fragile" ABI - // 2 - Non-fragile ABI, version 1 - // 3 - Non-fragile ABI, version 2 - objcABIVersion = 1; - // If -fobjc-abi-version= is present, use that to set the version. - if (Arg *A = Args.getLastArg(options::OPT_fobjc_abi_version_EQ)) { - if (StringRef(A->getValue(Args)) == "1") - objcABIVersion = 1; - else if (StringRef(A->getValue(Args)) == "2") - objcABIVersion = 2; - else if (StringRef(A->getValue(Args)) == "3") - objcABIVersion = 3; - else - D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args); - } else { - // Otherwise, determine if we are using the non-fragile ABI. - if (Args.hasFlag(options::OPT_fobjc_nonfragile_abi, - options::OPT_fno_objc_nonfragile_abi, - getToolChain().IsObjCNonFragileABIDefault())) { - // Determine the non-fragile ABI version to use. + bool NeXTRuntimeIsDefault + = (IsRewriter || getToolChain().getTriple().isOSDarwin()); + if (Args.hasFlag(options::OPT_fnext_runtime, options::OPT_fgnu_runtime, + NeXTRuntimeIsDefault)) { + objCRuntime.setKind(ObjCRuntime::NeXT); + } else { + CmdArgs.push_back("-fgnu-runtime"); + 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"); + if (objCRuntime.HasTerminate) + CmdArgs.push_back("-fobjc-runtime-has-terminate"); + + // Compute the Objective-C ABI "version" to use. Version numbers are + // slightly confusing for historical reasons: + // 1 - Traditional "fragile" ABI + // 2 - Non-fragile ABI, version 1 + // 3 - Non-fragile ABI, version 2 + objcABIVersion = 1; + // If -fobjc-abi-version= is present, use that to set the version. + if (Arg *A = Args.getLastArg(options::OPT_fobjc_abi_version_EQ)) { + if (StringRef(A->getValue(Args)) == "1") + objcABIVersion = 1; + else if (StringRef(A->getValue(Args)) == "2") + objcABIVersion = 2; + else if (StringRef(A->getValue(Args)) == "3") + objcABIVersion = 3; + else + D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args); + } else { + // Otherwise, determine if we are using the non-fragile ABI. + if (Args.hasFlag(options::OPT_fobjc_nonfragile_abi, + options::OPT_fno_objc_nonfragile_abi, + getToolChain().IsObjCNonFragileABIDefault())) { + // Determine the non-fragile ABI version to use. #ifdef DISABLE_DEFAULT_NONFRAGILEABI_TWO - unsigned NonFragileABIVersion = 1; + unsigned NonFragileABIVersion = 1; #else - unsigned NonFragileABIVersion = 2; + unsigned NonFragileABIVersion = 2; #endif - if (Arg *A = Args.getLastArg( - options::OPT_fobjc_nonfragile_abi_version_EQ)) { - if (StringRef(A->getValue(Args)) == "1") - NonFragileABIVersion = 1; - else if (StringRef(A->getValue(Args)) == "2") - NonFragileABIVersion = 2; - else - D.Diag(diag::err_drv_clang_unsupported) - << A->getAsString(Args); - } - - objcABIVersion = 1 + NonFragileABIVersion; - } else { - objcABIVersion = 1; + if (Arg *A = Args.getLastArg( + options::OPT_fobjc_nonfragile_abi_version_EQ)) { + if (StringRef(A->getValue(Args)) == "1") + NonFragileABIVersion = 1; + else if (StringRef(A->getValue(Args)) == "2") + NonFragileABIVersion = 2; + else + D.Diag(diag::err_drv_clang_unsupported) + << A->getAsString(Args); } + + objcABIVersion = 1 + NonFragileABIVersion; + } else { + objcABIVersion = 1; } + } - if (objcABIVersion == 2 || objcABIVersion == 3) { - CmdArgs.push_back("-fobjc-nonfragile-abi"); + if (objcABIVersion == 2 || objcABIVersion == 3) { + CmdArgs.push_back("-fobjc-nonfragile-abi"); - // -fobjc-dispatch-method is only relevant with the nonfragile-abi, and - // legacy is the default. - if (!Args.hasFlag(options::OPT_fobjc_legacy_dispatch, - options::OPT_fno_objc_legacy_dispatch, - getToolChain().IsObjCLegacyDispatchDefault())) { - if (getToolChain().UseObjCMixedDispatch()) - CmdArgs.push_back("-fobjc-dispatch-method=mixed"); - else - CmdArgs.push_back("-fobjc-dispatch-method=non-legacy"); - } + // -fobjc-dispatch-method is only relevant with the nonfragile-abi, and + // legacy is the default. + if (!Args.hasFlag(options::OPT_fobjc_legacy_dispatch, + options::OPT_fno_objc_legacy_dispatch, + getToolChain().IsObjCLegacyDispatchDefault())) { + if (getToolChain().UseObjCMixedDispatch()) + CmdArgs.push_back("-fobjc-dispatch-method=mixed"); + else + CmdArgs.push_back("-fobjc-dispatch-method=non-legacy"); } + } - // -fobjc-default-synthesize-properties=0 is default. - if (Args.hasFlag(options::OPT_fobjc_default_synthesize_properties, - options::OPT_fno_objc_default_synthesize_properties, - getToolChain().IsObjCDefaultSynthPropertiesDefault())) { - CmdArgs.push_back("-fobjc-default-synthesize-properties"); - } + // -fobjc-default-synthesize-properties=0 is default. + if (Args.hasFlag(options::OPT_fobjc_default_synthesize_properties, + options::OPT_fno_objc_default_synthesize_properties, + getToolChain().IsObjCDefaultSynthPropertiesDefault())) { + CmdArgs.push_back("-fobjc-default-synthesize-properties"); } // Allow -fno-objc-arr to trump -fobjc-arr/-fobjc-arc.