clangd: Stop calling FileEntryRef::FileEntryRef

In `ReplayPreamble::replay`, use `getFileRef` instead of `getFile`, and
then use that `FileEntryRef` later to avoid needing
`FileEntryRef::FileEntryRef`. The latter is going to become private to
`FileManager` in a later commit.
This commit is contained in:
Duncan P. N. Exon Smith 2020-10-15 19:29:10 -04:00
parent 4bde9aa964
commit 434f3774f6
1 changed files with 5 additions and 7 deletions

View File

@ -170,10 +170,9 @@ private:
void replay() {
for (const auto &Inc : Includes) {
const FileEntry *File = nullptr;
llvm::Optional<FileEntryRef> File;
if (Inc.Resolved != "")
if (auto FE = SM.getFileManager().getFile(Inc.Resolved))
File = *FE;
File = expectedToOptional(SM.getFileManager().getFileRef(Inc.Resolved));
// Re-lex the #include directive to find its interesting parts.
auto HashLoc = SM.getComposedLoc(SM.getMainFileID(), Inc.HashOffset);
@ -211,17 +210,16 @@ private:
SynthesizedFilenameTok.setKind(tok::header_name);
SynthesizedFilenameTok.setLiteralData(Inc.Written.data());
const FileEntry *FE = File ? &File->getFileEntry() : nullptr;
llvm::StringRef WrittenFilename =
llvm::StringRef(Inc.Written).drop_front().drop_back();
Delegate->InclusionDirective(HashTok->location(), SynthesizedIncludeTok,
WrittenFilename, Inc.Written.front() == '<',
FileTok->range(SM).toCharRange(SM), File,
FileTok->range(SM).toCharRange(SM), FE,
"SearchPath", "RelPath",
/*Imported=*/nullptr, Inc.FileKind);
if (File)
// FIXME: Use correctly named FileEntryRef.
Delegate->FileSkipped(FileEntryRef(File->getName(), *File),
SynthesizedFilenameTok, Inc.FileKind);
Delegate->FileSkipped(*File, SynthesizedFilenameTok, Inc.FileKind);
else {
llvm::SmallString<1> UnusedRecovery;
Delegate->FileNotFound(WrittenFilename, UnusedRecovery);