[clangd][NFC] Silence some buildbot warnings after 0250b053
authorNathan James <n.james93@hotmail.co.uk>
Tue, 9 Mar 2021 14:55:55 +0000 (14:55 +0000)
committerNathan James <n.james93@hotmail.co.uk>
Tue, 9 Mar 2021 14:55:55 +0000 (14:55 +0000)
https://reviews.llvm.org/D94554 introduced code which wont compile with some build flags due to a field having the same identifier as a type.

clang-tools-extra/clangd/DraftStore.h:55:11: error: declaration of ‘clang::clangd::DraftStore::Draft clang::clangd::DraftStore::DraftAndTime::Draft’ changes meaning of ‘Draft’ [-fpermissive]
   55 |     Draft Draft;
      |           ^~~~~
clang-tools-extra/clangd/DraftStore.h:30:10: note: ‘Draft’ declared here as ‘struct clang::clangd::DraftStore::Draft’
   30 |   struct Draft {
         |          ^~~~~

clang-tools-extra/clangd/DraftStore.cpp
clang-tools-extra/clangd/DraftStore.h

index b640f88..e040d1e 100644 (file)
@@ -24,7 +24,7 @@ llvm::Optional<DraftStore::Draft> DraftStore::getDraft(PathRef File) const {
   if (It == Drafts.end())
     return None;
 
-  return It->second.Draft;
+  return It->second.D;
 }
 
 std::vector<Path> DraftStore::getActiveFiles() const {
@@ -78,10 +78,10 @@ std::string DraftStore::addDraft(PathRef File, llvm::StringRef Version,
   std::lock_guard<std::mutex> Lock(Mutex);
 
   auto &D = Drafts[File];
-  updateVersion(D.Draft, Version);
+  updateVersion(D.D, Version);
   std::time(&D.MTime);
-  D.Draft.Contents = std::make_shared<std::string>(Contents);
-  return D.Draft.Version;
+  D.D.Contents = std::make_shared<std::string>(Contents);
+  return D.D.Version;
 }
 
 void DraftStore::removeDraft(PathRef File) {
@@ -121,7 +121,7 @@ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> DraftStore::asVFS() const {
   for (const auto &Draft : Drafts)
     MemFS->addFile(Draft.getKey(), Draft.getValue().MTime,
                    std::make_unique<SharedStringBuffer>(
-                       Draft.getValue().Draft.Contents, Draft.getKey()));
+                       Draft.getValue().D.Contents, Draft.getKey()));
   return MemFS;
 }
 } // namespace clangd
index ff3056e..6b50b23 100644 (file)
@@ -52,7 +52,7 @@ public:
 
 private:
   struct DraftAndTime {
-    Draft Draft;
+    Draft D;
     std::time_t MTime;
   };
   mutable std::mutex Mutex;