From 53df1a5045c5c9471b0b4b00f8d64433d862699d Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 20 Oct 2017 00:25:07 +0000 Subject: [PATCH] Revert r316193. This patch breaks users using -fno-canonical-prefixes, for whom resolving symlinks is not acceptable. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316195 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/Options.td | 5 --- .../clang/Frontend/DependencyOutputOptions.h | 3 -- lib/Driver/Job.cpp | 4 +-- lib/Driver/ToolChains/Clang.cpp | 7 ---- lib/Frontend/CompilerInvocation.cpp | 1 - lib/Frontend/DependencyFile.cpp | 11 ------- lib/Tooling/ArgumentsAdjusters.cpp | 4 +-- test/Preprocessor/dependencies-realpath.c | 33 ------------------- 8 files changed, 3 insertions(+), 65 deletions(-) delete mode 100644 test/Preprocessor/dependencies-realpath.c diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index c87cac91bd..526b72f792 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -384,11 +384,6 @@ def MT : JoinedOrSeparate<["-"], "MT">, Group, Flags<[CC1Option]>, HelpText<"Specify name of main file output in depfile">; def MV : Flag<["-"], "MV">, Group, Flags<[CC1Option]>, HelpText<"Use NMake/Jom format for the depfile">; -def fno_canonical_system_headers : Flag<["-"], "fno-canonical-system-headers">, - Group, Flags<[CC1Option]>, - HelpText<"Do not shorten system header paths in depfiles">; -def fcanonical_system_headers : Flag<["-"], "fcanonical-system-headers">, - Group; def Mach : Flag<["-"], "Mach">, Group; def O0 : Flag<["-"], "O0">, Group, Flags<[CC1Option, HelpHidden]>; def O4 : Flag<["-"], "O4">, Group, Flags<[CC1Option, HelpHidden]>; diff --git a/include/clang/Frontend/DependencyOutputOptions.h b/include/clang/Frontend/DependencyOutputOptions.h index 47016a2548..0be36cd9aa 100644 --- a/include/clang/Frontend/DependencyOutputOptions.h +++ b/include/clang/Frontend/DependencyOutputOptions.h @@ -30,8 +30,6 @@ public: unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency list unsigned PrintShowIncludes : 1; ///< Print cl.exe style /showIncludes info. unsigned IncludeModuleFiles : 1; ///< Include module file dependencies. - unsigned CanonicalSystemHeaders : 1; ///< Try to output a shorter path for - /// system header dependencies. /// The format for the dependency file. DependencyOutputFormat OutputFormat; @@ -69,7 +67,6 @@ public: AddMissingHeaderDeps = 0; PrintShowIncludes = 0; IncludeModuleFiles = 0; - CanonicalSystemHeaders = 1; OutputFormat = DependencyOutputFormat::Make; } }; diff --git a/lib/Driver/Job.cpp b/lib/Driver/Job.cpp index 241c72a2e9..765c05752d 100644 --- a/lib/Driver/Job.cpp +++ b/lib/Driver/Job.cpp @@ -73,8 +73,8 @@ static bool skipArgs(const char *Flag, bool HaveCrashVFS, int &SkipNum, // These flags are all of the form -Flag and have no second argument. ShouldSkip = llvm::StringSwitch(Flag) - .Cases("-M", "-MM", "-MG", "-MP", "-MD", "-MMD", true) - .Cases("-fno-canonical-system-headers", "-fcanonical-system-headers", true) + .Cases("-M", "-MM", "-MG", "-MP", "-MD", true) + .Case("-MMD", true) .Default(false); // Match found. diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index 1304042c83..12713f8be2 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -964,13 +964,6 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA, Args.AddLastArg(CmdArgs, options::OPT_C); Args.AddLastArg(CmdArgs, options::OPT_CC); - if (Arg *A = Args.getLastArg(options::OPT_fno_canonical_system_headers, - options::OPT_fcanonical_system_headers)) { - if (A->getOption().matches(options::OPT_fno_canonical_system_headers)) { - CmdArgs.push_back("-fno-canonical-system-headers"); - } - } - // Handle dependency file generation. if ((A = Args.getLastArg(options::OPT_M, options::OPT_MM)) || (A = Args.getLastArg(options::OPT_MD)) || diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 42fd2a1331..19e26c18bf 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1002,7 +1002,6 @@ 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/lib/Frontend/DependencyFile.cpp b/lib/Frontend/DependencyFile.cpp index b6e4cfa338..561eb9c4a3 100644 --- a/lib/Frontend/DependencyFile.cpp +++ b/lib/Frontend/DependencyFile.cpp @@ -161,7 +161,6 @@ class DFGImpl : public PPCallbacks { bool AddMissingHeaderDeps; bool SeenMissingHeader; bool IncludeModuleFiles; - bool CanonicalSystemHeaders; DependencyOutputFormat OutputFormat; private: @@ -177,7 +176,6 @@ public: AddMissingHeaderDeps(Opts.AddMissingHeaderDeps), SeenMissingHeader(false), IncludeModuleFiles(Opts.IncludeModuleFiles), - CanonicalSystemHeaders(Opts.CanonicalSystemHeaders), OutputFormat(Opts.OutputFormat) { for (const auto &ExtraDep : Opts.ExtraDeps) { AddFilename(ExtraDep); @@ -290,15 +288,6 @@ 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)); } diff --git a/lib/Tooling/ArgumentsAdjusters.cpp b/lib/Tooling/ArgumentsAdjusters.cpp index 8fcaa8afe4..ac9fd3c5ca 100644 --- a/lib/Tooling/ArgumentsAdjusters.cpp +++ b/lib/Tooling/ArgumentsAdjusters.cpp @@ -58,9 +58,7 @@ ArgumentsAdjuster getClangStripDependencyFileAdjuster() { StringRef Arg = Args[i]; // All dependency-file options begin with -M. These include -MM, // -MF, -MG, -MP, -MT, -MQ, -MD, and -MMD. - // The exception is -f[no-]canonical-system-headers. - if (!Arg.startswith("-M") && Arg != "-fno-canonical-system-headers" && - Arg != "-fcanonical-system-headers") + if (!Arg.startswith("-M")) AdjustedArgs.push_back(Args[i]); if ((Arg == "-MF") || (Arg == "-MT") || (Arg == "-MQ") || diff --git a/test/Preprocessor/dependencies-realpath.c b/test/Preprocessor/dependencies-realpath.c deleted file mode 100644 index 555b79fc13..0000000000 --- a/test/Preprocessor/dependencies-realpath.c +++ /dev/null @@ -1,33 +0,0 @@ -// RUN: mkdir -p %t/sub/dir -// RUN: echo > %t/sub/empty.h - -// Test that system header paths are expanded -// -// RUN: %clang -fsyntax-only -MD -MF %t.d -MT foo %s -isystem %t/sub/dir/.. -// RUN: FileCheck -check-prefix=TEST1 %s < %t.d -// TEST1: foo: -// TEST1: sub{{/|\\}}empty.h - -// Test that system header paths are not expanded to a longer form -// -// RUN: cd %t && %clang -fsyntax-only -MD -MF %t.d -MT foo %s -isystem sub/dir/.. -// RUN: FileCheck -check-prefix=TEST2 %s < %t.d -// TEST2: foo: -// TEST2: sub/dir/..{{/|\\}}empty.h - -// Test that user header paths are not expanded -// -// RUN: %clang -fsyntax-only -MD -MF %t.d -MT foo %s -I %t/sub/dir/.. -// RUN: FileCheck -check-prefix=TEST3 %s < %t.d -// TEST3: foo: -// TEST3: sub/dir/..{{/|\\}}empty.h - -// Test that system header paths are not expanded with -fno-canonical-system-headers -// (and also that the -fsystem-system-headers option is accepted) -// -// RUN: %clang -fsyntax-only -MD -MF %t.d -MT foo %s -I %t/sub/dir/.. -fcanonical-system-headers -fno-canonical-system-headers -// RUN: FileCheck -check-prefix=TEST4 %s < %t.d -// TEST4: foo: -// TEST4: sub/dir/..{{/|\\}}empty.h - -#include -- 2.40.0