Skip to content

Commit 8278922

Browse files
committed
Frontend: Migrate to FileEntryRef in VerifyDiagnosticConsumer.cpp, NFC
Add a `FileEntryRef` overload of `SourceManager::translateFile`, and migrate `ParseDirective` in VerifyDiagnosticConsumer.cpp to use it and the corresponding overload of `createFileID`. No functionality change here. Differential Revision: https://reviews.llvm.org/D92699
1 parent e5a28e1 commit 8278922

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

clang/include/clang/Basic/SourceManager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,9 @@ class SourceManager : public RefCountedBase<SourceManager> {
15821582
/// If the source file is included multiple times, the FileID will be the
15831583
/// first inclusion.
15841584
FileID translateFile(const FileEntry *SourceFile) const;
1585+
FileID translateFile(FileEntryRef SourceFile) const {
1586+
return translateFile(&SourceFile.getFileEntry());
1587+
}
15851588

15861589
/// Get the source location in \p FID for the given line:col.
15871590
/// Returns null location if \p FID is not a file SLocEntry.

clang/lib/Frontend/VerifyDiagnosticConsumer.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,10 +554,9 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM,
554554
continue;
555555
}
556556

557-
const FileEntry *FE = &File->getFileEntry();
558-
FileID FID = SM.translateFile(FE);
557+
FileID FID = SM.translateFile(*File);
559558
if (FID.isInvalid())
560-
FID = SM.createFileID(FE, Pos, SrcMgr::C_User);
559+
FID = SM.createFileID(*File, Pos, SrcMgr::C_User);
561560

562561
if (PH.Next(Line) && Line > 0)
563562
ExpectedLoc = SM.translateLineCol(FID, Line, 1);

0 commit comments

Comments
 (0)