This revision was automatically updated to reflect the committed changes. Closed by commit rCTE345973: [clangd] Add fallbackFlags initialization extension. (authored by sammccall, committed by ).
Changed prior to commit: https://reviews.llvm.org/D53688?vs=171036&id=172351#toc Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53688 Files: clangd/ClangdLSPServer.cpp clangd/Protocol.cpp clangd/Protocol.h Index: clangd/Protocol.cpp =================================================================== --- clangd/Protocol.cpp +++ clangd/Protocol.cpp @@ -669,6 +669,7 @@ fromJSON(Params, Opts.ConfigSettings); O.map("compilationDatabasePath", Opts.compilationDatabasePath); + O.map("fallbackFlags", Opts.fallbackFlags); return true; } Index: clangd/Protocol.h =================================================================== --- clangd/Protocol.h +++ clangd/Protocol.h @@ -368,6 +368,10 @@ ConfigurationSettings ConfigSettings; llvm::Optional<std::string> compilationDatabasePath; + // Additional flags to be included in the "fallback command" used when + // the compilation database doesn't describe an opened file. + // The command used will be approximately `clang $FILE $fallbackFlags`. + std::vector<std::string> fallbackFlags; }; bool fromJSON(const llvm::json::Value &, InitializationOptions &); Index: clangd/ClangdLSPServer.cpp =================================================================== --- clangd/ClangdLSPServer.cpp +++ clangd/ClangdLSPServer.cpp @@ -308,7 +308,7 @@ if (UseDirBasedCDB) BaseCDB = llvm::make_unique<DirectoryBasedGlobalCompilationDatabase>( CompileCommandsDir); - CDB.emplace(BaseCDB.get()); + CDB.emplace(BaseCDB.get(), Params.initializationOptions.fallbackFlags); Server.emplace(*CDB, FSProvider, static_cast<DiagnosticsConsumer &>(*this), ClangdServerOpts); applyConfiguration(Params.initializationOptions.ConfigSettings); @@ -664,9 +664,10 @@ tooling::CompileCommand(std::move(Entry.second.workingDirectory), File, std::move(Entry.second.compilationCommand), /*Output=*/""); - if (Old != New) + if (Old != New) { CDB->setCompileCommand(File, std::move(New)); - ShouldReparseOpenFiles = true; + ShouldReparseOpenFiles = true; + } } if (ShouldReparseOpenFiles) reparseOpenedFiles();
Index: clangd/Protocol.cpp =================================================================== --- clangd/Protocol.cpp +++ clangd/Protocol.cpp @@ -669,6 +669,7 @@ fromJSON(Params, Opts.ConfigSettings); O.map("compilationDatabasePath", Opts.compilationDatabasePath); + O.map("fallbackFlags", Opts.fallbackFlags); return true; } Index: clangd/Protocol.h =================================================================== --- clangd/Protocol.h +++ clangd/Protocol.h @@ -368,6 +368,10 @@ ConfigurationSettings ConfigSettings; llvm::Optional<std::string> compilationDatabasePath; + // Additional flags to be included in the "fallback command" used when + // the compilation database doesn't describe an opened file. + // The command used will be approximately `clang $FILE $fallbackFlags`. + std::vector<std::string> fallbackFlags; }; bool fromJSON(const llvm::json::Value &, InitializationOptions &); Index: clangd/ClangdLSPServer.cpp =================================================================== --- clangd/ClangdLSPServer.cpp +++ clangd/ClangdLSPServer.cpp @@ -308,7 +308,7 @@ if (UseDirBasedCDB) BaseCDB = llvm::make_unique<DirectoryBasedGlobalCompilationDatabase>( CompileCommandsDir); - CDB.emplace(BaseCDB.get()); + CDB.emplace(BaseCDB.get(), Params.initializationOptions.fallbackFlags); Server.emplace(*CDB, FSProvider, static_cast<DiagnosticsConsumer &>(*this), ClangdServerOpts); applyConfiguration(Params.initializationOptions.ConfigSettings); @@ -664,9 +664,10 @@ tooling::CompileCommand(std::move(Entry.second.workingDirectory), File, std::move(Entry.second.compilationCommand), /*Output=*/""); - if (Old != New) + if (Old != New) { CDB->setCompileCommand(File, std::move(New)); - ShouldReparseOpenFiles = true; + ShouldReparseOpenFiles = true; + } } if (ShouldReparseOpenFiles) reparseOpenedFiles();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits