diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-02-11 03:16:21 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-02-11 03:16:21 +0000 |
commit | 64952508c2b0c8bffb45c8b410f0af3d2457f59b (patch) | |
tree | fe9642743f904ba43451b25f59782028e271a7a6 /lib | |
parent | e9c7b9ef2f2054401d099dc7666a4143ef14089d (diff) |
Driver: Add -rewrite-objc, which is an interface to clang -cc1 -rewrite-objc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95849 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Driver/Driver.cpp | 9 | ||||
-rw-r--r-- | lib/Driver/Tools.cpp | 17 |
2 files changed, 23 insertions, 3 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 53eafd78a6..15df767d97 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -622,6 +622,7 @@ void Driver::BuildActions(const ArgList &Args, ActionList &Actions) const { // -{fsyntax-only,-analyze,emit-ast,S} only run up to the compiler. } else if ((FinalPhaseArg = Args.getLastArg(options::OPT_fsyntax_only)) || + (FinalPhaseArg = Args.getLastArg(options::OPT_rewrite_objc)) || (FinalPhaseArg = Args.getLastArg(options::OPT__analyze, options::OPT__analyze_auto)) || (FinalPhaseArg = Args.getLastArg(options::OPT_emit_ast)) || @@ -742,6 +743,8 @@ Action *Driver::ConstructPhaseAction(const ArgList &Args, phases::ID Phase, if (Args.hasArg(options::OPT_fsyntax_only)) { return new CompileJobAction(Input, types::TY_Nothing); + } else if (Args.hasArg(options::OPT_rewrite_objc)) { + return new CompileJobAction(Input, types::TY_RewrittenObjC); } else if (Args.hasArg(options::OPT__analyze, options::OPT__analyze_auto)) { return new AnalyzeJobAction(Input, types::TY_Plist); } else if (Args.hasArg(options::OPT_emit_ast)) { @@ -1171,8 +1174,10 @@ bool Driver::ShouldUseClangCompiler(const Compilation &C, const JobAction &JA, return false; } - // Always use clang for precompiling and AST generation, regardless of archs. - if (isa<PrecompileJobAction>(JA) || JA.getType() == types::TY_AST) + // Always use clang for precompiling, AST generation, and rewriting, + // regardless of archs. + if (isa<PrecompileJobAction>(JA) || JA.getType() == types::TY_AST || + JA.getType() == types::TY_RewrittenObjC) return true; // Finally, don't use clang if this isn't one of the user specified archs to diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 7bc7875b11..9e7ec3b2de 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -676,6 +676,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-S"); } else if (JA.getType() == types::TY_AST) { CmdArgs.push_back("-emit-pch"); + } else if (JA.getType() == types::TY_RewrittenObjC) { + CmdArgs.push_back("-rewrite-objc"); + } else { + assert(JA.getType() == types::TY_PP_Asm && + "Unexpected output type!"); } } @@ -1325,11 +1330,18 @@ void gcc::Precompile::RenderExtraToolArgs(const JobAction &JA, void gcc::Compile::RenderExtraToolArgs(const JobAction &JA, ArgStringList &CmdArgs) const { + const Driver &D = getToolChain().getDriver(); + // If -flto, etc. are present then make sure not to force assembly output. if (JA.getType() == types::TY_LLVMBC) CmdArgs.push_back("-c"); - else + else { + if (JA.getType() != types::TY_PP_Asm) + D.Diag(clang::diag::err_drv_invalid_gcc_output_type) + << getTypeName(JA.getType()); + CmdArgs.push_back("-S"); + } } void gcc::Assemble::RenderExtraToolArgs(const JobAction &JA, @@ -1734,6 +1746,9 @@ void darwin::Compile::ConstructJob(Compilation &C, const JobAction &JA, else if (Output.getType() == types::TY_AST) D.Diag(clang::diag::err_drv_no_ast_support) << getToolChain().getTripleString(); + else if (JA.getType() != types::TY_PP_Asm) + D.Diag(clang::diag::err_drv_invalid_gcc_output_type) + << getTypeName(JA.getType()); ArgStringList OutputArgs; if (Output.getType() != types::TY_PCH) { |