diff clang-tools-extra/clangd/GlobalCompilationDatabase.cpp @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 79ff65ed7e25
children 1f2b6ac9f198
line wrap: on
line diff
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp	Wed Jul 21 10:27:27 2021 +0900
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp	Wed Nov 09 17:45:10 2022 +0900
@@ -14,7 +14,6 @@
 #include "support/Path.h"
 #include "support/Threading.h"
 #include "support/ThreadsafeFS.h"
-#include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "clang/Tooling/CompilationDatabasePluginRegistry.h"
@@ -26,10 +25,7 @@
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/Program.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include <atomic>
 #include <chrono>
@@ -279,11 +275,10 @@
   struct CDBFile {
     CachedFile *File;
     // Wrapper for {Fixed,JSON}CompilationDatabase::loadFromBuffer.
-    llvm::function_ref<std::unique_ptr<tooling::CompilationDatabase>(
+    std::unique_ptr<tooling::CompilationDatabase> (*Parser)(
         PathRef,
         /*Data*/ llvm::StringRef,
-        /*ErrorMsg*/ std::string &)>
-        Parser;
+        /*ErrorMsg*/ std::string &);
   };
   for (const auto &Entry : {CDBFile{&CompileCommandsJson, parseJSON},
                             CDBFile{&BuildCompileCommandsJson, parseJSON},
@@ -412,7 +407,7 @@
   std::string Storage;
   std::vector<llvm::StringRef> SearchDirs;
   if (Opts.CompileCommandsDir) // FIXME: unify this case with config.
-    SearchDirs = {Opts.CompileCommandsDir.getValue()};
+    SearchDirs = {*Opts.CompileCommandsDir};
   else {
     WithContext WithProvidedContext(Opts.ContextProvider(Request.FileName));
     const auto &Spec = Config::current().CompileFlags.CDBSearch;
@@ -420,7 +415,7 @@
     case Config::CDBSearchSpec::NoCDBSearch:
       return llvm::None;
     case Config::CDBSearchSpec::FixedDir:
-      Storage = Spec.FixedCDBPath.getValue();
+      Storage = *Spec.FixedCDBPath;
       SearchDirs = {Storage};
       break;
     case Config::CDBSearchSpec::Ancestors:
@@ -535,7 +530,7 @@
   bool blockUntilIdle(Deadline Timeout) {
     std::unique_lock<std::mutex> Lock(Mu);
     return wait(Lock, CV, Timeout,
-                [&] { return Queue.empty() && !ActiveTask.hasValue(); });
+                [&] { return Queue.empty() && !ActiveTask; });
   }
 
   ~BroadcastThread() {
@@ -677,8 +672,7 @@
     std::vector<SearchPath> SearchPaths(AllFiles.size());
     for (unsigned I = 0; I < AllFiles.size(); ++I) {
       if (Parent.Opts.CompileCommandsDir) { // FIXME: unify with config
-        SearchPaths[I].setPointer(
-            &Dirs[Parent.Opts.CompileCommandsDir.getValue()]);
+        SearchPaths[I].setPointer(&Dirs[*Parent.Opts.CompileCommandsDir]);
         continue;
       }
       if (ExitEarly()) // loading config may be slow
@@ -694,7 +688,7 @@
         SearchPaths[I].setPointer(addParents(AllFiles[I]));
         break;
       case Config::CDBSearchSpec::FixedDir:
-        SearchPaths[I].setPointer(&Dirs[Spec.FixedCDBPath.getValue()]);
+        SearchPaths[I].setPointer(&Dirs[*Spec.FixedCDBPath]);
         break;
       }
     }
@@ -764,7 +758,7 @@
   if (!Cmd)
     return llvm::None;
   if (ArgsAdjuster)
-    Cmd->CommandLine = ArgsAdjuster(Cmd->CommandLine, Cmd->Filename);
+    Cmd->CommandLine = ArgsAdjuster(Cmd->CommandLine, File);
   return Cmd;
 }
 
@@ -774,7 +768,7 @@
   Cmd.CommandLine.insert(Cmd.CommandLine.end(), FallbackFlags.begin(),
                          FallbackFlags.end());
   if (ArgsAdjuster)
-    Cmd.CommandLine = ArgsAdjuster(Cmd.CommandLine, Cmd.Filename);
+    Cmd.CommandLine = ArgsAdjuster(Cmd.CommandLine, File);
   return Cmd;
 }