From cc66b08945099b734b05d06179ea85413c69753d Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Fri, 20 Apr 2012 00:30:04 +0000 Subject: [PATCH] When generating the clang crash diagnostic script, strip out the -D, -F, and -I flags. We have preprocessed source, so we don't need these. No test case as it's fairly difficult to make the compiler crash on demand. I'll patiently wait for Ben to tell me how to do this in 2 lines of code. :) rdar://11283560 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155180 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Driver.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 3ddac69e98..1ffa9b7b7d 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -489,6 +489,20 @@ void Driver::generateCompilationDiagnostics(Compilation &C, Diag(clang::diag::note_drv_command_failed_diag_msg) << "Error generating run script: " + Script + " " + Err; } else { + // Strip -D, -F, and -I. + // FIXME: This doesn't work with quotes (e.g., -D "foo bar"). + std::string Flag[3] = {"-D ", "-F", "-I "}; + for (unsigned i = 0; i < 3; ++i) { + size_t I = 0, E = 0; + do { + I = Cmd.find(Flag[i], I); + if (I == std::string::npos) break; + + E = Cmd.find(" ", I + Flag[i].length()); + if (E == std::string::npos) break; + Cmd.erase(I, E - I + 1); + } while(1); + } ScriptOS << Cmd; Diag(clang::diag::note_drv_command_failed_diag_msg) << Script; } -- 2.40.0