From: Fariborz Jahanian Date: Wed, 4 Apr 2012 18:50:28 +0000 (+0000) Subject: modern objc translator. Add more X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e982cc0ea3e9255b8aacf8f0bff559e9b1cfd72e;p=clang modern objc translator. Add more rewriter specific option to cc1 with -rewrite-objc. // rdar://11143173 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154037 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 4c1cd392af..e5be1e08b6 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1279,6 +1279,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // Select the appropriate action. bool IsRewriter = false; + bool IsModernRewriter = false; + if (isa(JA)) { assert(JA.getType() == types::TY_Plist && "Invalid output type."); CmdArgs.push_back("-analyze"); @@ -1349,6 +1351,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-emit-pch"); } else if (JA.getType() == types::TY_RewrittenObjC) { CmdArgs.push_back("-rewrite-objc"); + IsModernRewriter = true; } else if (JA.getType() == types::TY_RewrittenLegacyObjC) { CmdArgs.push_back("-rewrite-objc"); IsRewriter = true; @@ -2226,7 +2229,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, ObjCRuntime objCRuntime; unsigned objcABIVersion = 0; bool NeXTRuntimeIsDefault - = (IsRewriter || getToolChain().getTriple().isOSDarwin()); + = (IsRewriter || IsModernRewriter || + getToolChain().getTriple().isOSDarwin()); if (Args.hasFlag(options::OPT_fnext_runtime, options::OPT_fgnu_runtime, NeXTRuntimeIsDefault)) { objCRuntime.setKind(ObjCRuntime::NeXT); @@ -2260,8 +2264,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args); } else { // Otherwise, determine if we are using the non-fragile ABI. - bool NonFragileABIIsDefault - = (!IsRewriter && getToolChain().IsObjCNonFragileABIDefault()); + bool NonFragileABIIsDefault = + (IsModernRewriter || + (!IsRewriter && getToolChain().IsObjCNonFragileABIDefault())); if (Args.hasFlag(options::OPT_fobjc_nonfragile_abi, options::OPT_fno_objc_nonfragile_abi, NonFragileABIIsDefault)) { @@ -2341,7 +2346,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // -fobjc-infer-related-result-type is the default, except in the Objective-C // rewriter. - if (IsRewriter) + if (IsRewriter || IsModernRewriter) CmdArgs.push_back("-fno-objc-infer-related-result-type"); // Handle -fobjc-gc and -fobjc-gc-only. They are exclusive, and -fobjc-gc-only diff --git a/test/Driver/rewrite-objc.m b/test/Driver/rewrite-objc.m index c5712609d7..7b080fc35e 100644 --- a/test/Driver/rewrite-objc.m +++ b/test/Driver/rewrite-objc.m @@ -3,7 +3,7 @@ // TEST0: clang{{.*}}" "-cc1" // TEST0: "-rewrite-objc" // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead. -// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-dispatch-method=mixed" "-fobjc-default-synthesize-properties" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option" +// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-dispatch-method=mixed" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option" // TEST0: rewrite-objc.m" // RUN: not %clang -ccc-no-clang -target unknown -rewrite-objc %s -o - -### 2>&1 | \