summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp1
-rw-r--r--clang/lib/Frontend/DependencyFile.cpp11
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 19e26c18bfd..42fd2a13313 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1002,6 +1002,7 @@ static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
Opts.Targets = Args.getAllArgValues(OPT_MT);
Opts.IncludeSystemHeaders = Args.hasArg(OPT_sys_header_deps);
Opts.IncludeModuleFiles = Args.hasArg(OPT_module_file_deps);
+ Opts.CanonicalSystemHeaders = !Args.hasArg(OPT_fno_canonical_system_headers);
Opts.UsePhonyTargets = Args.hasArg(OPT_MP);
Opts.ShowHeaderIncludes = Args.hasArg(OPT_H);
Opts.HeaderIncludeOutputFile = Args.getLastArgValue(OPT_header_include_file);
diff --git a/clang/lib/Frontend/DependencyFile.cpp b/clang/lib/Frontend/DependencyFile.cpp
index 561eb9c4a31..b6e4cfa3385 100644
--- a/clang/lib/Frontend/DependencyFile.cpp
+++ b/clang/lib/Frontend/DependencyFile.cpp
@@ -161,6 +161,7 @@ class DFGImpl : public PPCallbacks {
bool AddMissingHeaderDeps;
bool SeenMissingHeader;
bool IncludeModuleFiles;
+ bool CanonicalSystemHeaders;
DependencyOutputFormat OutputFormat;
private:
@@ -176,6 +177,7 @@ public:
AddMissingHeaderDeps(Opts.AddMissingHeaderDeps),
SeenMissingHeader(false),
IncludeModuleFiles(Opts.IncludeModuleFiles),
+ CanonicalSystemHeaders(Opts.CanonicalSystemHeaders),
OutputFormat(Opts.OutputFormat) {
for (const auto &ExtraDep : Opts.ExtraDeps) {
AddFilename(ExtraDep);
@@ -288,6 +290,15 @@ void DFGImpl::FileChanged(SourceLocation Loc,
if (!FileMatchesDepCriteria(Filename.data(), FileType))
return;
+ // Try to shorten system header paths like GCC does (unless
+ // -fno-canonical-system-headers is given).
+ if (CanonicalSystemHeaders && isSystem(FileType)) {
+ StringRef RealPath = FE->tryGetRealPathName();
+ if (!RealPath.empty() && RealPath.size() < Filename.size()) {
+ Filename = RealPath;
+ }
+ }
+
AddFilename(llvm::sys::path::remove_leading_dotslash(Filename));
}
OpenPOWER on IntegriCloud