[PATCH] D89514: clangd: Stop calling FileEntryRef::FileEntryRef
Duncan P. N. Exon Smith via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 15 16:34:31 PDT 2020
dexonsmith created this revision.
dexonsmith added a reviewer: arphaman.
Herald added subscribers: usaxena95, ributzka, kadircet.
dexonsmith requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
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.
https://reviews.llvm.org/D89514
Files:
clang-tools-extra/clangd/ParsedAST.cpp
Index: clang-tools-extra/clangd/ParsedAST.cpp
===================================================================
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -170,10 +170,9 @@
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,17 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89514.298515.patch
Type: text/x-patch
Size: 1900 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201015/d65ef6e3/attachment-0001.bin>
More information about the cfe-commits
mailing list