aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/PrecompiledPreamble.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2023-09-06 10:35:54 -0700
committerJan Svoboda <jan@svoboda.ai>2023-09-06 10:49:48 -0700
commitddbcc10b9e26b18f6a70e23d0611b9da75ffa52f (patch)
treed7441ec31d0e7477dcb61534db69c066289db9ac /clang/lib/Frontend/PrecompiledPreamble.cpp
parent827171398116e1902acc57d5559636cec2e42858 (diff)
downloadllvm-ddbcc10b9e26b18f6a70e23d0611b9da75ffa52f.zip
llvm-ddbcc10b9e26b18f6a70e23d0611b9da75ffa52f.tar.gz
llvm-ddbcc10b9e26b18f6a70e23d0611b9da75ffa52f.tar.bz2
[clang] NFCI: Adopt `SourceManager::getFileEntryRefForID()`
This commit replaces some calls to the deprecated `FileEntry::getName()` with `FileEntryRef::getName()` by swapping current usages of `SourceManager::getFileEntryForID()` with `SourceManager::getFileEntryRefForID()`. This lowers the number of usages of the deprecated `FileEntry::getName()` from 95 to 50.
Diffstat (limited to 'clang/lib/Frontend/PrecompiledPreamble.cpp')
-rw-r--r--clang/lib/Frontend/PrecompiledPreamble.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/clang/lib/Frontend/PrecompiledPreamble.cpp b/clang/lib/Frontend/PrecompiledPreamble.cpp
index b768c53..62373b2 100644
--- a/clang/lib/Frontend/PrecompiledPreamble.cpp
+++ b/clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -550,19 +550,19 @@ llvm::ErrorOr<PrecompiledPreamble> PrecompiledPreamble::Build(
SourceManager &SourceMgr = Clang->getSourceManager();
for (auto &Filename : PreambleDepCollector->getDependencies()) {
- auto FileOrErr = Clang->getFileManager().getFile(Filename);
- if (!FileOrErr ||
- *FileOrErr == SourceMgr.getFileEntryForID(SourceMgr.getMainFileID()))
+ auto MaybeFile = Clang->getFileManager().getOptionalFileRef(Filename);
+ if (!MaybeFile ||
+ MaybeFile == SourceMgr.getFileEntryRefForID(SourceMgr.getMainFileID()))
continue;
- auto File = *FileOrErr;
- if (time_t ModTime = File->getModificationTime()) {
- FilesInPreamble[File->getName()] =
- PrecompiledPreamble::PreambleFileHash::createForFile(File->getSize(),
+ auto File = *MaybeFile;
+ if (time_t ModTime = File.getModificationTime()) {
+ FilesInPreamble[File.getName()] =
+ PrecompiledPreamble::PreambleFileHash::createForFile(File.getSize(),
ModTime);
} else {
llvm::MemoryBufferRef Buffer =
SourceMgr.getMemoryBufferForFileOrFake(File);
- FilesInPreamble[File->getName()] =
+ FilesInPreamble[File.getName()] =
PrecompiledPreamble::PreambleFileHash::createForMemoryBuffer(Buffer);
}
}