[clang-tools-extra] 434f377 - clangd: Stop calling FileEntryRef::FileEntryRef

Duncan P. N. Exon Smith via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 23 18:28:19 PDT 2020


Author: Duncan P. N. Exon Smith
Date: 2020-10-23T21:28:09-04:00
New Revision: 434f3774f629f5896614e9efb4eda82d813402ed

URL: https://github.com/llvm/llvm-project/commit/434f3774f629f5896614e9efb4eda82d813402ed
DIFF: https://github.com/llvm/llvm-project/commit/434f3774f629f5896614e9efb4eda82d813402ed.diff

LOG: 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.

Added: 
    

Modified: 
    clang-tools-extra/clangd/ParsedAST.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp
index c8096017b50a..6ca9c4f93d16 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -170,10 +170,9 @@ class ReplayPreamble : private PPCallbacks {
 
   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 @@ class ReplayPreamble : private PPCallbacks {
       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);


        


More information about the cfe-commits mailing list