diff options
author | Chad Rosier <mcrosier@apple.com> | 2012-05-03 22:38:00 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2012-05-03 22:38:00 +0000 |
commit | 44727629b766bf34bc2299c40f5ee8e4c7a71391 (patch) | |
tree | 5ffbaa94653c5f7ab2f6a4a69983052c34bd7413 /lib/Driver | |
parent | 0513448ae71478fd08d7e925bab46db1ddac3dfa (diff) | |
download | clang-44727629b766bf34bc2299c40f5ee8e4c7a71391.tar.gz |
[driver - crash diagnostics] Convert the flags back to an array of strings and use
array_lengthof. Also, append the new filename with correct preprocessed suffix.
Last part of rdar://11285725
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156117 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver')
-rw-r--r-- | lib/Driver/Driver.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index e22fc658a8..3e7a5a23de 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -521,7 +521,19 @@ void Driver::generateCompilationDiagnostics(Compilation &C, Cmd.erase(I, E - I + 1); } while(1); } - // FIXME: Append the new filename with correct preprocessed suffix. + // Append the new filename with correct preprocessed suffix. + size_t I, E; + I = Cmd.find("-main-file-name "); + assert (I != std::string::npos && "Expected to find -main-file-name"); + I += 16; + E = Cmd.find(" ", I); + assert (E != std::string::npos && "-main-file-name missing argument?"); + std::string OldFilename = Cmd.substr(I, E - I); + std::string NewFilename = llvm::sys::path::filename(*it).str(); + I = Cmd.rfind(OldFilename); + E = I + OldFilename.length() - 1; + I = Cmd.rfind(" ", I); + Cmd.replace(I + 1, E - I, NewFilename); ScriptOS << Cmd; Diag(clang::diag::note_drv_command_failed_diag_msg) << Script; } |