Skip to content

Commit d79ad2f

Browse files
committed
[clang][lex] NFCI: Use FileEntryRef in PPCallbacks::InclusionDirective()
This patch changes type of the `File` parameter in `PPCallbacks::InclusionDirective()` from `const FileEntry *` to `Optional<FileEntryRef>`. With the API change in place, this patch then removes some uses of the deprecated `FileEntry::getName()` (e.g. in `DependencyGraph.cpp` and `ModuleDependencyCollector.cpp`). Reviewed By: dexonsmith, bnbarham Differential Revision: https://reviews.llvm.org/D123574
1 parent defce20 commit d79ad2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+171
-155
lines changed

clang-tools-extra/clang-move/Move.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class FindAllIncludes : public PPCallbacks {
131131
void InclusionDirective(SourceLocation HashLoc, const Token & /*IncludeTok*/,
132132
StringRef FileName, bool IsAngled,
133133
CharSourceRange FilenameRange,
134-
const FileEntry * /*File*/, StringRef SearchPath,
134+
Optional<FileEntryRef> /*File*/, StringRef SearchPath,
135135
StringRef /*RelativePath*/,
136136
const Module * /*Imported*/,
137137
SrcMgr::CharacteristicKind /*FileType*/) override {

clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@ void ExpandModularHeadersPPCallbacks::FileChanged(
162162
void ExpandModularHeadersPPCallbacks::InclusionDirective(
163163
SourceLocation DirectiveLoc, const Token &IncludeToken,
164164
StringRef IncludedFilename, bool IsAngled, CharSourceRange FilenameRange,
165-
const FileEntry *IncludedFile, StringRef SearchPath, StringRef RelativePath,
166-
const Module *Imported, SrcMgr::CharacteristicKind FileType) {
165+
Optional<FileEntryRef> IncludedFile, StringRef SearchPath,
166+
StringRef RelativePath, const Module *Imported,
167+
SrcMgr::CharacteristicKind FileType) {
167168
if (Imported) {
168169
serialization::ModuleFile *MF =
169170
Compiler.getASTReader()->getModuleManager().lookup(

clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ class ExpandModularHeadersPPCallbacks : public PPCallbacks {
6969
void InclusionDirective(SourceLocation DirectiveLoc,
7070
const Token &IncludeToken, StringRef IncludedFilename,
7171
bool IsAngled, CharSourceRange FilenameRange,
72-
const FileEntry *IncludedFile, StringRef SearchPath,
73-
StringRef RelativePath, const Module *Imported,
72+
Optional<FileEntryRef> IncludedFile,
73+
StringRef SearchPath, StringRef RelativePath,
74+
const Module *Imported,
7475
SrcMgr::CharacteristicKind FileType) override;
7576

7677
void EndOfMainFile() override;

clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class KernelNameRestrictionPPCallbacks : public PPCallbacks {
2929

3030
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
3131
StringRef FileName, bool IsAngled,
32-
CharSourceRange FileNameRange, const FileEntry *File,
33-
StringRef SearchPath, StringRef RelativePath,
34-
const Module *Imported,
32+
CharSourceRange FileNameRange,
33+
Optional<FileEntryRef> File, StringRef SearchPath,
34+
StringRef RelativePath, const Module *Imported,
3535
SrcMgr::CharacteristicKind FileType) override;
3636

3737
void EndOfMainFile() override;
@@ -62,8 +62,8 @@ void KernelNameRestrictionCheck::registerPPCallbacks(const SourceManager &SM,
6262

6363
void KernelNameRestrictionPPCallbacks::InclusionDirective(
6464
SourceLocation HashLoc, const Token &, StringRef FileName, bool,
65-
CharSourceRange, const FileEntry *, StringRef, StringRef, const Module *,
66-
SrcMgr::CharacteristicKind) {
65+
CharSourceRange, Optional<FileEntryRef>, StringRef, StringRef,
66+
const Module *, SrcMgr::CharacteristicKind) {
6767
IncludeDirective ID = {HashLoc, FileName};
6868
IncludeDirectives.push_back(std::move(ID));
6969
}

clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ class SuspiciousIncludePPCallbacks : public PPCallbacks {
2424

2525
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
2626
StringRef FileName, bool IsAngled,
27-
CharSourceRange FilenameRange, const FileEntry *File,
28-
StringRef SearchPath, StringRef RelativePath,
29-
const Module *Imported,
27+
CharSourceRange FilenameRange,
28+
Optional<FileEntryRef> File, StringRef SearchPath,
29+
StringRef RelativePath, const Module *Imported,
3030
SrcMgr::CharacteristicKind FileType) override;
3131

3232
private:
@@ -72,7 +72,7 @@ void SuspiciousIncludeCheck::registerPPCallbacks(
7272

7373
void SuspiciousIncludePPCallbacks::InclusionDirective(
7474
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
75-
bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File,
75+
bool IsAngled, CharSourceRange FilenameRange, Optional<FileEntryRef> File,
7676
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
7777
SrcMgr::CharacteristicKind FileType) {
7878
if (IncludeTok.getIdentifierInfo()->getPPKeywordID() == tok::pp_import)

clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class IncludeOrderPPCallbacks : public PPCallbacks {
2626

2727
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
2828
StringRef FileName, bool IsAngled,
29-
CharSourceRange FilenameRange, const FileEntry *File,
30-
StringRef SearchPath, StringRef RelativePath,
31-
const Module *Imported,
29+
CharSourceRange FilenameRange,
30+
Optional<FileEntryRef> File, StringRef SearchPath,
31+
StringRef RelativePath, const Module *Imported,
3232
SrcMgr::CharacteristicKind FileType) override;
3333
void EndOfMainFile() override;
3434

@@ -81,7 +81,7 @@ static int getPriority(StringRef Filename, bool IsAngled, bool IsMainModule) {
8181

8282
void IncludeOrderPPCallbacks::InclusionDirective(
8383
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
84-
bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File,
84+
bool IsAngled, CharSourceRange FilenameRange, Optional<FileEntryRef> File,
8585
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
8686
SrcMgr::CharacteristicKind FileType) {
8787
// We recognize the first include as a special main module header and want

clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class RestrictedIncludesPPCallbacks
3333

3434
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
3535
StringRef FileName, bool IsAngled,
36-
CharSourceRange FilenameRange, const FileEntry *File,
37-
StringRef SearchPath, StringRef RelativePath,
38-
const Module *Imported,
36+
CharSourceRange FilenameRange,
37+
Optional<FileEntryRef> File, StringRef SearchPath,
38+
StringRef RelativePath, const Module *Imported,
3939
SrcMgr::CharacteristicKind FileType) override;
4040

4141
private:
@@ -46,7 +46,7 @@ class RestrictedIncludesPPCallbacks
4646

4747
void RestrictedIncludesPPCallbacks::InclusionDirective(
4848
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
49-
bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File,
49+
bool IsAngled, CharSourceRange FilenameRange, Optional<FileEntryRef> File,
5050
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
5151
SrcMgr::CharacteristicKind FileType) {
5252
// Compiler provided headers are allowed (e.g stddef.h).

clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class IncludeModernizePPCallbacks : public PPCallbacks {
2727

2828
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
2929
StringRef FileName, bool IsAngled,
30-
CharSourceRange FilenameRange, const FileEntry *File,
31-
StringRef SearchPath, StringRef RelativePath,
32-
const Module *Imported,
30+
CharSourceRange FilenameRange,
31+
Optional<FileEntryRef> File, StringRef SearchPath,
32+
StringRef RelativePath, const Module *Imported,
3333
SrcMgr::CharacteristicKind FileType) override;
3434

3535
private:
@@ -91,7 +91,7 @@ IncludeModernizePPCallbacks::IncludeModernizePPCallbacks(ClangTidyCheck &Check,
9191

9292
void IncludeModernizePPCallbacks::InclusionDirective(
9393
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
94-
bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File,
94+
bool IsAngled, CharSourceRange FilenameRange, Optional<FileEntryRef> File,
9595
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
9696
SrcMgr::CharacteristicKind FileType) {
9797
// FIXME: Take care of library symbols from the global namespace.

clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ class MacroToEnumCallbacks : public PPCallbacks {
133133

134134
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
135135
StringRef FileName, bool IsAngled,
136-
CharSourceRange FilenameRange, const FileEntry *File,
137-
StringRef SearchPath, StringRef RelativePath,
138-
const Module *Imported,
136+
CharSourceRange FilenameRange,
137+
Optional<FileEntryRef> File, StringRef SearchPath,
138+
StringRef RelativePath, const Module *Imported,
139139
SrcMgr::CharacteristicKind FileType) override {
140140
clearCurrentEnum(HashLoc);
141141
}

clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace portability {
2222

2323
void RestrictedIncludesPPCallbacks::InclusionDirective(
2424
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
25-
bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File,
25+
bool IsAngled, CharSourceRange FilenameRange, Optional<FileEntryRef> File,
2626
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
2727
SrcMgr::CharacteristicKind FileType) {
2828
if (!Check.contains(FileName) && SrcMgr::isSystem(FileType)) {

0 commit comments

Comments
 (0)