aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/HeaderSearch.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2023-09-09 08:43:26 -0700
committerJan Svoboda <jan_svoboda@apple.com>2023-09-09 09:12:35 -0700
commitc23d65b90fb7fb07cb12e2d70d0c34376b8fcdad (patch)
tree90c72fed3b88a1a1f8fb14463899c6526567f7cf /clang/lib/Lex/HeaderSearch.cpp
parentef996175a7d38f7b4a0b60264dc861ab36376a47 (diff)
downloadllvm-c23d65b90fb7fb07cb12e2d70d0c34376b8fcdad.zip
llvm-c23d65b90fb7fb07cb12e2d70d0c34376b8fcdad.tar.gz
llvm-c23d65b90fb7fb07cb12e2d70d0c34376b8fcdad.tar.bz2
[clang] NFCI: Use `FileEntryRef` in `ModuleMapParser`
Diffstat (limited to 'clang/lib/Lex/HeaderSearch.cpp')
-rw-r--r--clang/lib/Lex/HeaderSearch.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index ec7cb58..699cd9ae 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1660,8 +1660,8 @@ bool HeaderSearch::findUsableModuleForFrameworkHeader(
return true;
}
-static const FileEntry *getPrivateModuleMap(FileEntryRef File,
- FileManager &FileMgr) {
+static OptionalFileEntryRef getPrivateModuleMap(FileEntryRef File,
+ FileManager &FileMgr) {
StringRef Filename = llvm::sys::path::filename(File.getName());
SmallString<128> PrivateFilename(File.getDir().getName());
if (Filename == "module.map")
@@ -1669,10 +1669,8 @@ static const FileEntry *getPrivateModuleMap(FileEntryRef File,
else if (Filename == "module.modulemap")
llvm::sys::path::append(PrivateFilename, "module.private.modulemap");
else
- return nullptr;
- if (auto File = FileMgr.getFile(PrivateFilename))
- return *File;
- return nullptr;
+ return std::nullopt;
+ return FileMgr.getOptionalFileRef(PrivateFilename);
}
bool HeaderSearch::loadModuleMapFile(FileEntryRef File, bool IsSystem,
@@ -1738,8 +1736,8 @@ HeaderSearch::loadModuleMapFileImpl(FileEntryRef File, bool IsSystem,
}
// Try to load a corresponding private module map.
- if (const FileEntry *PMMFile = getPrivateModuleMap(File, FileMgr)) {
- if (ModMap.parseModuleMapFile(PMMFile, IsSystem, Dir)) {
+ if (OptionalFileEntryRef PMMFile = getPrivateModuleMap(File, FileMgr)) {
+ if (ModMap.parseModuleMapFile(*PMMFile, IsSystem, Dir)) {
LoadedModuleMaps[File] = false;
return LMM_InvalidModuleMap;
}