summaryrefslogtreecommitdiff
path: root/lib/Tooling/ArgumentsAdjusters.cpp
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2017-10-19 23:53:27 +0000
committerPeter Wu <peter@lekensteyn.nl>2017-10-19 23:53:27 +0000
commitcc28d36809ee131966e1bd25939748d9f7cc07a4 (patch)
tree7be759ba49de0955c38cf3493cee4e936f9cc209 /lib/Tooling/ArgumentsAdjusters.cpp
parent22b25a6d050b61a793c93450488a1a7c5e2b9e09 (diff)
downloadclang-cc28d36809ee131966e1bd25939748d9f7cc07a4.tar.gz
Try to shorten system header paths when using -MD depfiles
GCC tries to shorten system headers in depfiles using its real path (resolving components like ".." and following symlinks). Mimic this feature to ensure that the Ninja build tool detects the correct dependencies when a symlink changes directory levels, see https://github.com/ninja-build/ninja/issues/1330 An option to disable this feature is added in case "these changed header paths may conflict with some compilation environments", see https://gcc.gnu.org/ml/gcc-patches/2012-09/msg00287.html Note that the original feature request for GCC (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52974) also included paths preprocessed output (-E) and diagnostics. That is not implemented now since I am not sure if it breaks something else. Differential Revision: https://reviews.llvm.org/D37954 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316193 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Tooling/ArgumentsAdjusters.cpp')
-rw-r--r--lib/Tooling/ArgumentsAdjusters.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/Tooling/ArgumentsAdjusters.cpp b/lib/Tooling/ArgumentsAdjusters.cpp
index ac9fd3c5ca..8fcaa8afe4 100644
--- a/lib/Tooling/ArgumentsAdjusters.cpp
+++ b/lib/Tooling/ArgumentsAdjusters.cpp
@@ -58,7 +58,9 @@ ArgumentsAdjuster getClangStripDependencyFileAdjuster() {
StringRef Arg = Args[i];
// All dependency-file options begin with -M. These include -MM,
// -MF, -MG, -MP, -MT, -MQ, -MD, and -MMD.
- if (!Arg.startswith("-M"))
+ // The exception is -f[no-]canonical-system-headers.
+ if (!Arg.startswith("-M") && Arg != "-fno-canonical-system-headers" &&
+ Arg != "-fcanonical-system-headers")
AdjustedArgs.push_back(Args[i]);
if ((Arg == "-MF") || (Arg == "-MT") || (Arg == "-MQ") ||