diff options
author | Chad Rosier <mcrosier@apple.com> | 2012-07-25 17:52:16 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2012-07-25 17:52:16 +0000 |
commit | 37302ead1c067ec984a75e847cd83c6881637e72 (patch) | |
tree | e096d8ab3067cfc3e4c403d92dfcaa755b665117 /lib/Driver/Driver.cpp | |
parent | 2c6b00e7126399210b759f4da53c680bee01a706 (diff) |
[driver crash diagnostics] A few enhancements:
-Strip -iquote and -M options.
-Quote -D options to avoid problems with command line macros that include
parens.
rdar://11949066
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160743 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Driver.cpp')
-rw-r--r-- | lib/Driver/Driver.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 7f6fcb1a5e..c7819b1fce 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -504,8 +504,18 @@ void Driver::generateCompilationDiagnostics(Compilation &C, // Strip away options not necessary to reproduce the crash. // FIXME: This doesn't work with quotes (e.g., -D "foo bar"). SmallVector<std::string, 16> Flag; + Flag.push_back("-D "); Flag.push_back("-F"); Flag.push_back("-I "); + Flag.push_back("-M "); + Flag.push_back("-MD "); + Flag.push_back("-MF "); + Flag.push_back("-MG "); + Flag.push_back("-MM "); + Flag.push_back("-MMD "); + Flag.push_back("-MP "); + Flag.push_back("-MQ "); + Flag.push_back("-MT "); Flag.push_back("-o "); Flag.push_back("-coverage-file "); Flag.push_back("-dependency-file "); @@ -514,6 +524,7 @@ void Driver::generateCompilationDiagnostics(Compilation &C, Flag.push_back("-include "); Flag.push_back("-include-pch "); Flag.push_back("-isysroot "); + Flag.push_back("-iquote "); Flag.push_back("-resource-dir "); Flag.push_back("-serialize-diagnostic-file "); for (unsigned i = 0, e = Flag.size(); i < e; ++i) { @@ -524,7 +535,14 @@ void Driver::generateCompilationDiagnostics(Compilation &C, E = Cmd.find(" ", I + Flag[i].length()); if (E == std::string::npos) break; - Cmd.erase(I, E - I + 1); + // The -D option is not removed. Instead, the argument is quoted. + if (Flag[i] != "-D ") { + Cmd.erase(I, E - I + 1); + } else { + Cmd.insert(I+3, "\""); + Cmd.insert(++E, "\""); + I = E; + } } while(1); } // Append the new filename with correct preprocessed suffix. |