Skip to content

Commit f9fbda7

Browse files
committed
Revert "[clang] Canonicalize system headers in dependency file when -canonical-prefixes"
This reverts commit 8f0dd4e. Causes bot failures: https://lab.llvm.org/buildbot/#builders/139/builds/39964
1 parent 30cdb2a commit f9fbda7

File tree

8 files changed

+20
-80
lines changed

8 files changed

+20
-80
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5835,9 +5835,6 @@ let Flags = [CC1Option, NoDriverOption] in {
58355835
def sys_header_deps : Flag<["-"], "sys-header-deps">,
58365836
HelpText<"Include system headers in dependency output">,
58375837
MarshallingInfoFlag<DependencyOutputOpts<"IncludeSystemHeaders">>;
5838-
def canonical_system_headers : Flag<["-"], "canonical-system-headers">,
5839-
HelpText<"Canonicalize system headers in dependency output">,
5840-
MarshallingInfoFlag<DependencyOutputOpts<"CanonicalSystemHeaders">>;
58415838
def module_file_deps : Flag<["-"], "module-file-deps">,
58425839
HelpText<"Include module files in dependency output">,
58435840
MarshallingInfoFlag<DependencyOutputOpts<"IncludeModuleFiles">>;

clang/include/clang/Frontend/DependencyOutputOptions.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ enum ExtraDepKind {
3434
class DependencyOutputOptions {
3535
public:
3636
unsigned IncludeSystemHeaders : 1; ///< Include system header dependencies.
37-
unsigned
38-
CanonicalSystemHeaders : 1; ///< canonicalize system header dependencies.
3937
unsigned ShowHeaderIncludes : 1; ///< Show header inclusions (-H).
4038
unsigned UsePhonyTargets : 1; ///< Include phony targets for each
4139
/// dependency, which can avoid some 'make'
@@ -87,11 +85,10 @@ class DependencyOutputOptions {
8785

8886
public:
8987
DependencyOutputOptions()
90-
: IncludeSystemHeaders(0), CanonicalSystemHeaders(0),
91-
ShowHeaderIncludes(0), UsePhonyTargets(0), AddMissingHeaderDeps(0),
92-
IncludeModuleFiles(0), ShowSkippedHeaderIncludes(0),
93-
HeaderIncludeFormat(HIFMT_Textual), HeaderIncludeFiltering(HIFIL_None) {
94-
}
88+
: IncludeSystemHeaders(0), ShowHeaderIncludes(0), UsePhonyTargets(0),
89+
AddMissingHeaderDeps(0), IncludeModuleFiles(0),
90+
ShowSkippedHeaderIncludes(0), HeaderIncludeFormat(HIFMT_Textual),
91+
HeaderIncludeFiltering(HIFIL_None) {}
9592
};
9693

9794
} // end namespace clang

clang/include/clang/Frontend/Utils.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class ExternalSemaSource;
4141
class FrontendOptions;
4242
class PCHContainerReader;
4343
class Preprocessor;
44-
class FileManager;
4544
class PreprocessorOptions;
4645
class PreprocessorOutputOptions;
4746

@@ -80,14 +79,11 @@ class DependencyCollector {
8079
/// Return true if system files should be passed to sawDependency().
8180
virtual bool needSystemDependencies() { return false; }
8281

83-
/// Return true if system files should be canonicalized.
84-
virtual bool shouldCanonicalizeSystemDependencies() { return false; }
85-
8682
/// Add a dependency \p Filename if it has not been seen before and
8783
/// sawDependency() returns true.
8884
virtual void maybeAddDependency(StringRef Filename, bool FromModule,
8985
bool IsSystem, bool IsModuleFile,
90-
FileManager *FileMgr, bool IsMissing);
86+
bool IsMissing);
9187

9288
protected:
9389
/// Return true if the filename was added to the list of dependencies, false
@@ -116,10 +112,6 @@ class DependencyFileGenerator : public DependencyCollector {
116112
bool sawDependency(StringRef Filename, bool FromModule, bool IsSystem,
117113
bool IsModuleFile, bool IsMissing) final;
118114

119-
bool shouldCanonicalizeSystemDependencies() override {
120-
return CanonicalSystemHeaders;
121-
}
122-
123115
protected:
124116
void outputDependencyFile(llvm::raw_ostream &OS);
125117

@@ -129,7 +121,6 @@ class DependencyFileGenerator : public DependencyCollector {
129121
std::string OutputFile;
130122
std::vector<std::string> Targets;
131123
bool IncludeSystemHeaders;
132-
bool CanonicalSystemHeaders;
133124
bool PhonyTarget;
134125
bool AddMissingHeaderDeps;
135126
bool SeenMissingHeader;

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,9 +1139,6 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
11391139
if (ArgM->getOption().matches(options::OPT_M) ||
11401140
ArgM->getOption().matches(options::OPT_MD))
11411141
CmdArgs.push_back("-sys-header-deps");
1142-
if (Args.hasFlag(options::OPT_canonical_prefixes,
1143-
options::OPT_no_canonical_prefixes, true))
1144-
CmdArgs.push_back("-canonical-system-headers");
11451142
if ((isa<PrecompileJobAction>(JA) &&
11461143
!Args.hasArg(options::OPT_fno_module_file_deps)) ||
11471144
Args.hasArg(options::OPT_fmodule_file_deps))

clang/lib/Frontend/DependencyFile.cpp

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,16 @@ struct DepCollectorPPCallbacks : public PPCallbacks {
4949
DepCollector.maybeAddDependency(
5050
llvm::sys::path::remove_leading_dotslash(*Filename),
5151
/*FromModule*/ false, isSystem(FileType), /*IsModuleFile*/ false,
52-
&PP.getFileManager(),
5352
/*IsMissing*/ false);
5453
}
5554

5655
void FileSkipped(const FileEntryRef &SkippedFile, const Token &FilenameTok,
5756
SrcMgr::CharacteristicKind FileType) override {
5857
StringRef Filename =
5958
llvm::sys::path::remove_leading_dotslash(SkippedFile.getName());
60-
DepCollector.maybeAddDependency(Filename,
61-
/*FromModule=*/false,
59+
DepCollector.maybeAddDependency(Filename, /*FromModule=*/false,
6260
/*IsSystem=*/isSystem(FileType),
6361
/*IsModuleFile=*/false,
64-
&PP.getFileManager(),
6562
/*IsMissing=*/false);
6663
}
6764

@@ -72,12 +69,9 @@ struct DepCollectorPPCallbacks : public PPCallbacks {
7269
StringRef RelativePath, const Module *Imported,
7370
SrcMgr::CharacteristicKind FileType) override {
7471
if (!File)
75-
DepCollector.maybeAddDependency(FileName,
76-
/*FromModule*/ false,
77-
/*IsSystem*/ false,
78-
/*IsModuleFile*/ false,
79-
&PP.getFileManager(),
80-
/*IsMissing*/ true);
72+
DepCollector.maybeAddDependency(FileName, /*FromModule*/false,
73+
/*IsSystem*/false, /*IsModuleFile*/false,
74+
/*IsMissing*/true);
8175
// Files that actually exist are handled by FileChanged.
8276
}
8377

@@ -88,11 +82,9 @@ struct DepCollectorPPCallbacks : public PPCallbacks {
8882
return;
8983
StringRef Filename =
9084
llvm::sys::path::remove_leading_dotslash(File->getName());
91-
DepCollector.maybeAddDependency(Filename,
92-
/*FromModule=*/false,
85+
DepCollector.maybeAddDependency(Filename, /*FromModule=*/false,
9386
/*IsSystem=*/isSystem(FileType),
9487
/*IsModuleFile=*/false,
95-
&PP.getFileManager(),
9688
/*IsMissing=*/false);
9789
}
9890

@@ -108,12 +100,10 @@ struct DepCollectorMMCallbacks : public ModuleMapCallbacks {
108100
void moduleMapFileRead(SourceLocation Loc, const FileEntry &Entry,
109101
bool IsSystem) override {
110102
StringRef Filename = Entry.getName();
111-
DepCollector.maybeAddDependency(Filename,
112-
/*FromModule*/ false,
113-
/*IsSystem*/ IsSystem,
114-
/*IsModuleFile*/ false,
115-
/*FileMgr*/ nullptr,
116-
/*IsMissing*/ false);
103+
DepCollector.maybeAddDependency(Filename, /*FromModule*/false,
104+
/*IsSystem*/IsSystem,
105+
/*IsModuleFile*/false,
106+
/*IsMissing*/false);
117107
}
118108
};
119109

@@ -128,11 +118,9 @@ struct DepCollectorASTListener : public ASTReaderListener {
128118
}
129119
void visitModuleFile(StringRef Filename,
130120
serialization::ModuleKind Kind) override {
131-
DepCollector.maybeAddDependency(Filename,
132-
/*FromModule*/ true,
133-
/*IsSystem*/ false, /*IsModuleFile*/ true,
134-
/*FileMgr*/ nullptr,
135-
/*IsMissing*/ false);
121+
DepCollector.maybeAddDependency(Filename, /*FromModule*/true,
122+
/*IsSystem*/false, /*IsModuleFile*/true,
123+
/*IsMissing*/false);
136124
}
137125
bool visitInputFile(StringRef Filename, bool IsSystem,
138126
bool IsOverridden, bool IsExplicitModule) override {
@@ -144,9 +132,8 @@ struct DepCollectorASTListener : public ASTReaderListener {
144132
if (auto FE = FileMgr.getOptionalFileRef(Filename))
145133
Filename = FE->getName();
146134

147-
DepCollector.maybeAddDependency(Filename, /*FromModule*/ true, IsSystem,
148-
/*IsModuleFile*/ false, /*FileMgr*/ nullptr,
149-
/*IsMissing*/ false);
135+
DepCollector.maybeAddDependency(Filename, /*FromModule*/true, IsSystem,
136+
/*IsModuleFile*/false, /*IsMissing*/false);
150137
return true;
151138
}
152139
};
@@ -155,15 +142,9 @@ struct DepCollectorASTListener : public ASTReaderListener {
155142
void DependencyCollector::maybeAddDependency(StringRef Filename,
156143
bool FromModule, bool IsSystem,
157144
bool IsModuleFile,
158-
FileManager *FileMgr,
159145
bool IsMissing) {
160-
if (sawDependency(Filename, FromModule, IsSystem, IsModuleFile, IsMissing)) {
161-
if (IsSystem && FileMgr && shouldCanonicalizeSystemDependencies()) {
162-
if (auto F = FileMgr->getFile(Filename))
163-
Filename = FileMgr->getCanonicalName(*F);
164-
}
146+
if (sawDependency(Filename, FromModule, IsSystem, IsModuleFile, IsMissing))
165147
addDependency(Filename);
166-
}
167148
}
168149

169150
bool DependencyCollector::addDependency(StringRef Filename) {
@@ -211,7 +192,6 @@ DependencyFileGenerator::DependencyFileGenerator(
211192
const DependencyOutputOptions &Opts)
212193
: OutputFile(Opts.OutputFile), Targets(Opts.Targets),
213194
IncludeSystemHeaders(Opts.IncludeSystemHeaders),
214-
CanonicalSystemHeaders(Opts.CanonicalSystemHeaders),
215195
PhonyTarget(Opts.UsePhonyTargets),
216196
AddMissingHeaderDeps(Opts.AddMissingHeaderDeps), SeenMissingHeader(false),
217197
IncludeModuleFiles(Opts.IncludeModuleFiles),

clang/test/Driver/canonical-system-headers.c

Lines changed: 0 additions & 6 deletions
This file was deleted.

clang/test/Preprocessor/Inputs/canonical-system-headers/a.h

Whitespace-only changes.

clang/test/Preprocessor/canonical-system-headers.c

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)