diff options
author | Eric Christopher <echristo@apple.com> | 2012-01-10 00:38:01 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2012-01-10 00:38:01 +0000 |
commit | fc3ee566ebe4456084ada041c116a94230cb3cf5 (patch) | |
tree | 9c36af84115f8b42141582c2bd30fd5a921af45a /clang/lib/Driver/Tools.cpp | |
parent | fe2603a78a7a6c6b429eff95cd4a6f1c0ebe40bb (diff) | |
download | bcm5719-llvm-fc3ee566ebe4456084ada041c116a94230cb3cf5.tar.gz bcm5719-llvm-fc3ee566ebe4456084ada041c116a94230cb3cf5.zip |
Add -g to the cc1as flags only if we're dealing with an original
source file. Otherwise -g -save-temps will error out on the compile
of any .c file.
Fixes about 4000 of the errors in the clang-tests gdb test suite.
llvm-svn: 147819
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index bacfab58b00..bd3d638afd5 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -2567,12 +2567,21 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, // Ignore explicit -force_cpusubtype_ALL option. (void) Args.hasArg(options::OPT_force__cpusubtype__ALL); - // Same as Clang::ConstructJob() we special case debug options to only pass - // -g to clang. I guess if it is wrong there then it is wrong here too :) . - Args.ClaimAllArgs(options::OPT_g_Group); - if (Arg *A = Args.getLastArg(options::OPT_g_Group)) - if (!A->getOption().matches(options::OPT_g0)) - CmdArgs.push_back("-g"); + // Determine the original source input. + const Action *SourceAction = &JA; + while (SourceAction->getKind() != Action::InputClass) { + assert(!SourceAction->getInputs().empty() && "unexpected root action!"); + SourceAction = SourceAction->getInputs()[0]; + } + + // Forward -g, assuming we are dealing with an actual assembly file. + if (SourceAction->getType() == types::TY_Asm || + SourceAction->getType() == types::TY_PP_Asm) { + Args.ClaimAllArgs(options::OPT_g_Group); + if (Arg *A = Args.getLastArg(options::OPT_g_Group)) + if (!A->getOption().matches(options::OPT_g0)) + CmdArgs.push_back("-g"); + } // Optionally embed the -cc1as level arguments into the debug info, for build // analysis. |