File tree Expand file tree Collapse file tree 4 files changed +8
-10
lines changed Expand file tree Collapse file tree 4 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -390,7 +390,7 @@ IncludeCleanerFindings computeIncludeCleanerFindings(ParsedAST &AST) {
390
390
const auto &SM = AST.getSourceManager ();
391
391
include_cleaner::Includes ConvertedIncludes = convertIncludes (AST);
392
392
const FileEntry *MainFile = SM.getFileEntryForID (SM.getMainFileID ());
393
- auto * PreamblePatch = PreamblePatch::getPatchEntry (AST.tuPath (), SM);
393
+ auto PreamblePatch = PreamblePatch::getPatchEntry (AST.tuPath (), SM);
394
394
395
395
std::vector<include_cleaner::SymbolReference> Macros =
396
396
collectMacroReferences (AST);
Original file line number Diff line number Diff line change @@ -953,12 +953,10 @@ const MainFileMacros &PreamblePatch::mainFileMacros() const {
953
953
return PatchedMacros;
954
954
}
955
955
956
- const FileEntry * PreamblePatch::getPatchEntry (llvm::StringRef MainFilePath,
957
- const SourceManager &SM) {
956
+ OptionalFileEntryRef PreamblePatch::getPatchEntry (llvm::StringRef MainFilePath,
957
+ const SourceManager &SM) {
958
958
auto PatchFilePath = getPatchName (MainFilePath);
959
- if (auto File = SM.getFileManager ().getFile (PatchFilePath))
960
- return *File;
961
- return nullptr ;
959
+ return SM.getFileManager ().getOptionalFileRef (PatchFilePath);
962
960
}
963
961
} // namespace clangd
964
962
} // namespace clang
Original file line number Diff line number Diff line change @@ -180,8 +180,8 @@ class PreamblePatch {
180
180
const PreambleData &Baseline);
181
181
// / Returns the FileEntry for the preamble patch of MainFilePath in SM, if
182
182
// / any.
183
- static const FileEntry * getPatchEntry (llvm::StringRef MainFilePath,
184
- const SourceManager &SM);
183
+ static OptionalFileEntryRef getPatchEntry (llvm::StringRef MainFilePath,
184
+ const SourceManager &SM);
185
185
186
186
// / Adjusts CI (which compiles the modified inputs) to be used with the
187
187
// / baseline preamble. This is done by inserting an artificial include to the
Original file line number Diff line number Diff line change @@ -892,9 +892,9 @@ TEST(PreamblePatch, PatchFileEntry) {
892
892
}
893
893
{
894
894
auto AST = createPatchedAST (Code.code (), NewCode.code ());
895
- auto * FE =
895
+ auto FE =
896
896
PreamblePatch::getPatchEntry (AST->tuPath (), AST->getSourceManager ());
897
- ASSERT_NE (FE, nullptr );
897
+ ASSERT_NE (FE, std::nullopt );
898
898
EXPECT_THAT (FE->getName ().str (),
899
899
testing::EndsWith (PreamblePatch::HeaderName.str ()));
900
900
}
You can’t perform that action at this time.
0 commit comments