Skip to content

Commit b1aea98

Browse files
authoredSep 25, 2024
[clang] Make deprecations of some FileManager APIs formal (#110014)
Some `FileManager` APIs still return `{File,Directory}Entry` instead of the preferred `{File,Directory}EntryRef`. These are documented to be deprecated, but don't have the attribute that warns on their usage. This PR marks them as such with `LLVM_DEPRECATED()` and replaces their usage with the recommended counterparts. NFCI.
1 parent abe0dd1 commit b1aea98

File tree

28 files changed

+135
-129
lines changed

28 files changed

+135
-129
lines changed
 

‎clang-tools-extra/clang-move/tool/ClangMove.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ int main(int argc, const char **argv) {
199199
for (auto I = Files.begin(), E = Files.end(); I != E; ++I) {
200200
OS << " {\n";
201201
OS << " \"FilePath\": \"" << *I << "\",\n";
202-
const auto Entry = FileMgr.getFile(*I);
202+
const auto Entry = FileMgr.getOptionalFileRef(*I);
203203
auto ID = SM.translateFile(*Entry);
204204
std::string Content;
205205
llvm::raw_string_ostream ContentStream(Content);

‎clang-tools-extra/clangd/SourceCode.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,8 @@ llvm::SmallVector<llvm::StringRef> ancestorNamespaces(llvm::StringRef NS) {
814814

815815
// Checks whether \p FileName is a valid spelling of main file.
816816
bool isMainFile(llvm::StringRef FileName, const SourceManager &SM) {
817-
auto FE = SM.getFileManager().getFile(FileName);
818-
return FE && *FE == SM.getFileEntryForID(SM.getMainFileID());
817+
auto FE = SM.getFileManager().getOptionalFileRef(FileName);
818+
return FE && FE == SM.getFileEntryRefForID(SM.getMainFileID());
819819
}
820820

821821
} // namespace

‎clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,10 @@ TEST(ParsedASTTest, PatchesAdditionalIncludes) {
397397
auto &FM = SM.getFileManager();
398398
// Copy so that we can use operator[] to get the children.
399399
IncludeStructure Includes = PatchedAST->getIncludeStructure();
400-
auto MainFE = FM.getFile(testPath("foo.cpp"));
400+
auto MainFE = FM.getOptionalFileRef(testPath("foo.cpp"));
401401
ASSERT_TRUE(MainFE);
402402
auto MainID = Includes.getID(*MainFE);
403-
auto AuxFE = FM.getFile(testPath("sub/aux.h"));
403+
auto AuxFE = FM.getOptionalFileRef(testPath("sub/aux.h"));
404404
ASSERT_TRUE(AuxFE);
405405
auto AuxID = Includes.getID(*AuxFE);
406406
EXPECT_THAT(Includes.IncludeChildren[*MainID], Contains(*AuxID));

‎clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class FindHeadersTest : public testing::Test {
6060
llvm::SmallVector<Hinted<Header>> findHeaders(llvm::StringRef FileName) {
6161
return include_cleaner::findHeaders(
6262
AST->sourceManager().translateFileLineCol(
63-
AST->fileManager().getFile(FileName).get(),
63+
*AST->fileManager().getOptionalFileRef(FileName),
6464
/*Line=*/1, /*Col=*/1),
6565
AST->sourceManager(), &PI);
6666
}

‎clang-tools-extra/include-cleaner/unittests/RecordTest.cpp

+42-42
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ TEST_F(RecordPPTest, CapturesMacroRefs) {
234234
const auto &SM = AST.sourceManager();
235235

236236
SourceLocation Def = SM.getComposedLoc(
237-
SM.translateFile(AST.fileManager().getFile("header.h").get()),
237+
SM.translateFile(*AST.fileManager().getOptionalFileRef("header.h")),
238238
Header.point("def"));
239239
ASSERT_THAT(Recorded.MacroReferences, Not(IsEmpty()));
240240
Symbol OrigX = Recorded.MacroReferences.front().Target;
@@ -368,29 +368,29 @@ TEST_F(PragmaIncludeTest, IWYUKeep) {
368368
TestAST Processed = build();
369369
auto &FM = Processed.fileManager();
370370

371-
EXPECT_FALSE(PI.shouldKeep(FM.getFile("normal.h").get()));
372-
EXPECT_FALSE(PI.shouldKeep(FM.getFile("std/vector").get()));
371+
EXPECT_FALSE(PI.shouldKeep(*FM.getOptionalFileRef("normal.h")));
372+
EXPECT_FALSE(PI.shouldKeep(*FM.getOptionalFileRef("std/vector")));
373373

374374
// Keep
375-
EXPECT_TRUE(PI.shouldKeep(FM.getFile("keep1.h").get()));
376-
EXPECT_TRUE(PI.shouldKeep(FM.getFile("keep2.h").get()));
377-
EXPECT_TRUE(PI.shouldKeep(FM.getFile("keep3.h").get()));
378-
EXPECT_TRUE(PI.shouldKeep(FM.getFile("keep4.h").get()));
379-
EXPECT_TRUE(PI.shouldKeep(FM.getFile("keep5.h").get()));
380-
EXPECT_TRUE(PI.shouldKeep(FM.getFile("keep6.h").get()));
381-
EXPECT_TRUE(PI.shouldKeep(FM.getFile("std/map").get()));
375+
EXPECT_TRUE(PI.shouldKeep(*FM.getOptionalFileRef("keep1.h")));
376+
EXPECT_TRUE(PI.shouldKeep(*FM.getOptionalFileRef("keep2.h")));
377+
EXPECT_TRUE(PI.shouldKeep(*FM.getOptionalFileRef("keep3.h")));
378+
EXPECT_TRUE(PI.shouldKeep(*FM.getOptionalFileRef("keep4.h")));
379+
EXPECT_TRUE(PI.shouldKeep(*FM.getOptionalFileRef("keep5.h")));
380+
EXPECT_TRUE(PI.shouldKeep(*FM.getOptionalFileRef("keep6.h")));
381+
EXPECT_TRUE(PI.shouldKeep(*FM.getOptionalFileRef("std/map")));
382382

383383
// Exports
384-
EXPECT_TRUE(PI.shouldKeep(FM.getFile("export1.h").get()));
385-
EXPECT_TRUE(PI.shouldKeep(FM.getFile("export2.h").get()));
386-
EXPECT_TRUE(PI.shouldKeep(FM.getFile("export3.h").get()));
387-
EXPECT_TRUE(PI.shouldKeep(FM.getFile("std/set").get()));
384+
EXPECT_TRUE(PI.shouldKeep(*FM.getOptionalFileRef("export1.h")));
385+
EXPECT_TRUE(PI.shouldKeep(*FM.getOptionalFileRef("export2.h")));
386+
EXPECT_TRUE(PI.shouldKeep(*FM.getOptionalFileRef("export3.h")));
387+
EXPECT_TRUE(PI.shouldKeep(*FM.getOptionalFileRef("std/set")));
388388
}
389389

390390
TEST_F(PragmaIncludeTest, AssociatedHeader) {
391391
createEmptyFiles({"foo/main.h", "bar/main.h", "bar/other.h", "std/vector"});
392392
auto IsKeep = [&](llvm::StringRef Name, TestAST &AST) {
393-
return PI.shouldKeep(AST.fileManager().getFile(Name).get());
393+
return PI.shouldKeep(*AST.fileManager().getOptionalFileRef(Name));
394394
};
395395

396396
Inputs.FileName = "main.cc";
@@ -452,19 +452,19 @@ TEST_F(PragmaIncludeTest, IWYUPrivate) {
452452
// IWYU pragma: private
453453
)cpp";
454454
TestAST Processed = build();
455-
auto PrivateFE = Processed.fileManager().getFile("private.h");
455+
auto PrivateFE = Processed.fileManager().getOptionalFileRef("private.h");
456456
assert(PrivateFE);
457-
EXPECT_TRUE(PI.isPrivate(PrivateFE.get()));
458-
EXPECT_EQ(PI.getPublic(PrivateFE.get()), "\"public2.h\"");
457+
EXPECT_TRUE(PI.isPrivate(*PrivateFE));
458+
EXPECT_EQ(PI.getPublic(*PrivateFE), "\"public2.h\"");
459459

460-
auto PublicFE = Processed.fileManager().getFile("public.h");
460+
auto PublicFE = Processed.fileManager().getOptionalFileRef("public.h");
461461
assert(PublicFE);
462-
EXPECT_EQ(PI.getPublic(PublicFE.get()), ""); // no mapping.
463-
EXPECT_FALSE(PI.isPrivate(PublicFE.get()));
462+
EXPECT_EQ(PI.getPublic(*PublicFE), ""); // no mapping.
463+
EXPECT_FALSE(PI.isPrivate(*PublicFE));
464464

465-
auto Private2FE = Processed.fileManager().getFile("private2.h");
465+
auto Private2FE = Processed.fileManager().getOptionalFileRef("private2.h");
466466
assert(Private2FE);
467-
EXPECT_TRUE(PI.isPrivate(Private2FE.get()));
467+
EXPECT_TRUE(PI.isPrivate(*Private2FE));
468468
}
469469

470470
TEST_F(PragmaIncludeTest, IWYUExport) {
@@ -486,13 +486,13 @@ TEST_F(PragmaIncludeTest, IWYUExport) {
486486
const auto &SM = Processed.sourceManager();
487487
auto &FM = Processed.fileManager();
488488

489-
EXPECT_THAT(PI.getExporters(FM.getFile("private.h").get(), FM),
489+
EXPECT_THAT(PI.getExporters(*FM.getOptionalFileRef("private.h"), FM),
490490
testing::UnorderedElementsAre(FileNamed("export1.h"),
491491
FileNamed("export3.h")));
492492

493-
EXPECT_TRUE(PI.getExporters(FM.getFile("export1.h").get(), FM).empty());
494-
EXPECT_TRUE(PI.getExporters(FM.getFile("export2.h").get(), FM).empty());
495-
EXPECT_TRUE(PI.getExporters(FM.getFile("export3.h").get(), FM).empty());
493+
EXPECT_TRUE(PI.getExporters(*FM.getOptionalFileRef("export1.h"), FM).empty());
494+
EXPECT_TRUE(PI.getExporters(*FM.getOptionalFileRef("export2.h"), FM).empty());
495+
EXPECT_TRUE(PI.getExporters(*FM.getOptionalFileRef("export3.h"), FM).empty());
496496
EXPECT_TRUE(
497497
PI.getExporters(SM.getFileEntryForID(SM.getMainFileID()), FM).empty());
498498
}
@@ -548,23 +548,23 @@ TEST_F(PragmaIncludeTest, IWYUExportBlock) {
548548
}
549549
return Result;
550550
};
551-
auto Exporters = PI.getExporters(FM.getFile("private1.h").get(), FM);
551+
auto Exporters = PI.getExporters(*FM.getOptionalFileRef("private1.h"), FM);
552552
EXPECT_THAT(Exporters, testing::UnorderedElementsAre(FileNamed("export1.h"),
553553
FileNamed("normal.h")))
554554
<< GetNames(Exporters);
555555

556-
Exporters = PI.getExporters(FM.getFile("private2.h").get(), FM);
556+
Exporters = PI.getExporters(*FM.getOptionalFileRef("private2.h"), FM);
557557
EXPECT_THAT(Exporters, testing::UnorderedElementsAre(FileNamed("export1.h")))
558558
<< GetNames(Exporters);
559559

560-
Exporters = PI.getExporters(FM.getFile("private3.h").get(), FM);
560+
Exporters = PI.getExporters(*FM.getOptionalFileRef("private3.h"), FM);
561561
EXPECT_THAT(Exporters, testing::UnorderedElementsAre(FileNamed("export1.h")))
562562
<< GetNames(Exporters);
563563

564-
Exporters = PI.getExporters(FM.getFile("foo.h").get(), FM);
564+
Exporters = PI.getExporters(*FM.getOptionalFileRef("foo.h"), FM);
565565
EXPECT_TRUE(Exporters.empty()) << GetNames(Exporters);
566566

567-
Exporters = PI.getExporters(FM.getFile("bar.h").get(), FM);
567+
Exporters = PI.getExporters(*FM.getOptionalFileRef("bar.h"), FM);
568568
EXPECT_TRUE(Exporters.empty()) << GetNames(Exporters);
569569
}
570570

@@ -580,8 +580,8 @@ TEST_F(PragmaIncludeTest, SelfContained) {
580580
Inputs.ExtraFiles["unguarded.h"] = "";
581581
TestAST Processed = build();
582582
auto &FM = Processed.fileManager();
583-
EXPECT_TRUE(PI.isSelfContained(FM.getFile("guarded.h").get()));
584-
EXPECT_FALSE(PI.isSelfContained(FM.getFile("unguarded.h").get()));
583+
EXPECT_TRUE(PI.isSelfContained(*FM.getOptionalFileRef("guarded.h")));
584+
EXPECT_FALSE(PI.isSelfContained(*FM.getOptionalFileRef("unguarded.h")));
585585
}
586586

587587
TEST_F(PragmaIncludeTest, AlwaysKeep) {
@@ -596,8 +596,8 @@ TEST_F(PragmaIncludeTest, AlwaysKeep) {
596596
Inputs.ExtraFiles["usual.h"] = "#pragma once";
597597
TestAST Processed = build();
598598
auto &FM = Processed.fileManager();
599-
EXPECT_TRUE(PI.shouldKeep(FM.getFile("always_keep.h").get()));
600-
EXPECT_FALSE(PI.shouldKeep(FM.getFile("usual.h").get()));
599+
EXPECT_TRUE(PI.shouldKeep(*FM.getOptionalFileRef("always_keep.h")));
600+
EXPECT_FALSE(PI.shouldKeep(*FM.getOptionalFileRef("usual.h")));
601601
}
602602

603603
TEST_F(PragmaIncludeTest, ExportInUnnamedBuffer) {
@@ -653,13 +653,13 @@ TEST_F(PragmaIncludeTest, OutlivesFMAndSM) {
653653
// Now this build gives us a new File&Source Manager.
654654
TestAST Processed = build(/*ResetPragmaIncludes=*/false);
655655
auto &FM = Processed.fileManager();
656-
auto PrivateFE = FM.getFile("private.h");
656+
auto PrivateFE = FM.getOptionalFileRef("private.h");
657657
assert(PrivateFE);
658-
EXPECT_EQ(PI.getPublic(PrivateFE.get()), "\"public.h\"");
658+
EXPECT_EQ(PI.getPublic(*PrivateFE), "\"public.h\"");
659659

660-
auto Private2FE = FM.getFile("private2.h");
660+
auto Private2FE = FM.getOptionalFileRef("private2.h");
661661
assert(Private2FE);
662-
EXPECT_THAT(PI.getExporters(Private2FE.get(), FM),
662+
EXPECT_THAT(PI.getExporters(*Private2FE, FM),
663663
testing::ElementsAre(llvm::cantFail(FM.getFileRef("public.h"))));
664664
}
665665

@@ -676,8 +676,8 @@ TEST_F(PragmaIncludeTest, CanRecordManyTimes) {
676676

677677
TestAST Processed = build();
678678
auto &FM = Processed.fileManager();
679-
auto PrivateFE = FM.getFile("private.h");
680-
llvm::StringRef Public = PI.getPublic(PrivateFE.get());
679+
auto PrivateFE = FM.getOptionalFileRef("private.h");
680+
llvm::StringRef Public = PI.getPublic(*PrivateFE);
681681
EXPECT_EQ(Public, "\"public.h\"");
682682

683683
// This build populates same PI during build, but this time we don't have

‎clang-tools-extra/unittests/include/common/VirtualFileHelper.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class VirtualFileHelper {
6060
I != E; ++I) {
6161
std::unique_ptr<llvm::MemoryBuffer> Buf =
6262
llvm::MemoryBuffer::getMemBuffer(I->Code);
63-
const FileEntry *Entry = SM.getFileManager().getVirtualFile(
63+
FileEntryRef Entry = SM.getFileManager().getVirtualFileRef(
6464
I->FileName, Buf->getBufferSize(), /*ModificationTime=*/0);
6565
SM.overrideFileContents(Entry, std::move(Buf));
6666
}

‎clang/include/clang/Basic/DiagnosticFrontendKinds.td

-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ def err_fe_expected_clang_command : Error<
109109
"expected a clang compiler command">;
110110
def err_fe_remap_missing_to_file : Error<
111111
"could not remap file '%0' to the contents of file '%1'">, DefaultFatal;
112-
def err_fe_remap_missing_from_file : Error<
113-
"could not remap from missing file '%0'">, DefaultFatal;
114112
def err_fe_unable_to_load_pch : Error<
115113
"unable to load PCH file">;
116114
def err_fe_unable_to_load_plugin : Error<

‎clang/include/clang/Basic/FileManager.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class FileManager : public RefCountedBase<FileManager> {
8484
/// VirtualDirectoryEntries/VirtualFileEntries above.
8585
///
8686
llvm::StringMap<llvm::ErrorOr<DirectoryEntry &>, llvm::BumpPtrAllocator>
87-
SeenDirEntries;
87+
SeenDirEntries;
8888

8989
/// A cache that maps paths to file entries (either real or
9090
/// virtual) we have looked up, or an error that occurred when we looked up
@@ -190,6 +190,8 @@ class FileManager : public RefCountedBase<FileManager> {
190190
///
191191
/// \param CacheFailure If true and the file does not exist, we'll cache
192192
/// the failure to find this file.
193+
LLVM_DEPRECATED("Functions returning DirectoryEntry are deprecated.",
194+
"getOptionalDirectoryRef()")
193195
llvm::ErrorOr<const DirectoryEntry *>
194196
getDirectory(StringRef DirName, bool CacheFailure = true);
195197

@@ -207,6 +209,8 @@ class FileManager : public RefCountedBase<FileManager> {
207209
///
208210
/// \param CacheFailure If true and the file does not exist, we'll cache
209211
/// the failure to find this file.
212+
LLVM_DEPRECATED("Functions returning FileEntry are deprecated.",
213+
"getOptionalFileRef()")
210214
llvm::ErrorOr<const FileEntry *>
211215
getFile(StringRef Filename, bool OpenFile = false, bool CacheFailure = true);
212216

@@ -269,6 +273,8 @@ class FileManager : public RefCountedBase<FileManager> {
269273
FileEntryRef getVirtualFileRef(StringRef Filename, off_t Size,
270274
time_t ModificationTime);
271275

276+
LLVM_DEPRECATED("Functions returning FileEntry are deprecated.",
277+
"getVirtualFileRef()")
272278
const FileEntry *getVirtualFile(StringRef Filename, off_t Size,
273279
time_t ModificationTime);
274280

‎clang/lib/AST/ASTImporter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -10020,8 +10020,8 @@ Expected<FileID> ASTImporter::Import(FileID FromID, bool IsBuiltin) {
1002010020
ToIncludeLocOrFakeLoc = ToSM.getLocForStartOfFile(ToSM.getMainFileID());
1002110021

1002210022
if (Cache->OrigEntry && Cache->OrigEntry->getDir()) {
10023-
// FIXME: We probably want to use getVirtualFile(), so we don't hit the
10024-
// disk again
10023+
// FIXME: We probably want to use getVirtualFileRef(), so we don't hit
10024+
// the disk again
1002510025
// FIXME: We definitely want to re-use the existing MemoryBuffer, rather
1002610026
// than mmap the files several times.
1002710027
auto Entry =

‎clang/lib/CodeGen/CodeGenAction.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,9 @@ const FullSourceLoc BackendConsumer::getBestLocationFromDebugLoc(
586586
if (D.isLocationAvailable()) {
587587
D.getLocation(Filename, Line, Column);
588588
if (Line > 0) {
589-
auto FE = FileMgr.getFile(Filename);
589+
auto FE = FileMgr.getOptionalFileRef(Filename);
590590
if (!FE)
591-
FE = FileMgr.getFile(D.getAbsolutePath());
591+
FE = FileMgr.getOptionalFileRef(D.getAbsolutePath());
592592
if (FE) {
593593
// If -gcolumn-info was not used, Column will be 0. This upsets the
594594
// source manager, so pass 1 if Column is not set.

‎clang/lib/ExtractAPI/ExtractAPIConsumer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ struct LocationFileChecker {
217217
SmallVector<std::pair<SmallString<32>, bool>> &KnownFiles)
218218
: CI(CI), KnownFiles(KnownFiles), ExternalFileEntries() {
219219
for (const auto &KnownFile : KnownFiles)
220-
if (auto FileEntry = CI.getFileManager().getFile(KnownFile.first))
221-
KnownFileEntries.insert(*FileEntry);
220+
if (auto FE = CI.getFileManager().getOptionalFileRef(KnownFile.first))
221+
KnownFileEntries.insert(*FE);
222222
}
223223

224224
private:

‎clang/lib/Frontend/ASTUnit.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2395,7 +2395,7 @@ void ASTUnit::TranslateStoredDiagnostics(
23952395
// Rebuild the StoredDiagnostic.
23962396
if (SD.Filename.empty())
23972397
continue;
2398-
auto FE = FileMgr.getFile(SD.Filename);
2398+
auto FE = FileMgr.getOptionalFileRef(SD.Filename);
23992399
if (!FE)
24002400
continue;
24012401
SourceLocation FileLoc;

‎clang/lib/Frontend/CompilerInstance.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,8 @@ static void InitializeFileRemapping(DiagnosticsEngine &Diags,
427427
}
428428

429429
// Create the file entry for the file that we're mapping from.
430-
const FileEntry *FromFile =
431-
FileMgr.getVirtualFile(RF.first, ToFile->getSize(), 0);
432-
if (!FromFile) {
433-
Diags.Report(diag::err_fe_remap_missing_from_file) << RF.first;
434-
continue;
435-
}
430+
FileEntryRef FromFile =
431+
FileMgr.getVirtualFileRef(RF.first, ToFile->getSize(), 0);
436432

437433
// Override the contents of the "from" file with the contents of
438434
// the "to" file.
@@ -1926,7 +1922,7 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST(
19261922

19271923
// Check whether M refers to the file in the prebuilt module path.
19281924
if (M && M->getASTFile())
1929-
if (auto ModuleFile = FileMgr->getFile(ModuleFilename))
1925+
if (auto ModuleFile = FileMgr->getOptionalFileRef(ModuleFilename))
19301926
if (*ModuleFile == M->getASTFile())
19311927
return M;
19321928

‎clang/lib/Frontend/Rewrite/FrontendActions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class RewriteIncludesAction::RewriteImportsListener : public ASTReaderListener {
213213

214214
void visitModuleFile(StringRef Filename,
215215
serialization::ModuleKind Kind) override {
216-
auto File = CI.getFileManager().getFile(Filename);
216+
auto File = CI.getFileManager().getOptionalFileRef(Filename);
217217
assert(File && "missing file for loaded module?");
218218

219219
// Only rewrite each module file once.

‎clang/lib/InstallAPI/Frontend.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ InstallAPIContext::findAndRecordFile(const FileEntry *FE,
107107
}
108108

109109
void InstallAPIContext::addKnownHeader(const HeaderFile &H) {
110-
auto FE = FM->getFile(H.getPath());
110+
auto FE = FM->getOptionalFileRef(H.getPath());
111111
if (!FE)
112112
return; // File does not exist.
113113
KnownFiles[*FE] = H.getType();

‎clang/lib/Lex/HeaderSearch.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ std::string HeaderSearch::getPrebuiltModuleFileName(StringRef ModuleName,
227227
".pcm");
228228
else
229229
llvm::sys::path::append(Result, ModuleName + ".pcm");
230-
if (getFileMgr().getFile(Result.str()))
230+
if (getFileMgr().getOptionalFileRef(Result))
231231
return std::string(Result);
232232
}
233233

@@ -246,7 +246,7 @@ std::string HeaderSearch::getPrebuiltImplicitModuleFileName(Module *Module) {
246246
llvm::sys::path::append(CachePath, ModuleCacheHash);
247247
std::string FileName =
248248
getCachedModuleFileNameImpl(ModuleName, ModuleMapPath, CachePath);
249-
if (!FileName.empty() && getFileMgr().getFile(FileName))
249+
if (!FileName.empty() && getFileMgr().getOptionalFileRef(FileName))
250250
return FileName;
251251
}
252252
return {};
@@ -655,7 +655,7 @@ OptionalFileEntryRef DirectoryLookup::DoFrameworkLookup(
655655
++NumFrameworkLookups;
656656

657657
// If the framework dir doesn't exist, we fail.
658-
auto Dir = FileMgr.getDirectory(FrameworkName);
658+
auto Dir = FileMgr.getOptionalDirectoryRef(FrameworkName);
659659
if (!Dir)
660660
return std::nullopt;
661661

@@ -718,7 +718,7 @@ OptionalFileEntryRef DirectoryLookup::DoFrameworkLookup(
718718
bool FoundFramework = false;
719719
do {
720720
// Determine whether this directory exists.
721-
auto Dir = FileMgr.getDirectory(FrameworkPath);
721+
auto Dir = FileMgr.getOptionalDirectoryRef(FrameworkPath);
722722
if (!Dir)
723723
break;
724724

0 commit comments

Comments
 (0)