llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-llvm-support Author: Ryan Saunders (jediry) <details> <summary>Changes</summary> At present, the ```BasedOnStyle``` directive can reference a predefined style name, or ```InheritFromParent```, instructing clang-format to search upward in the directory hierarchy for a .clang-format file. This works fine when variations in codebase formatting align with the directory hierarchy, but becomes problematic when it is desired to share formatting across portions of a repository with no common parent directory. For example, consider the case of a large, multi-team repository containing many projects as sub-directories of the repository root, where each of the various engineering teams owns multiple of these projects, and wants a common coding style across all of its owned projects. In this PR, I'm extending ```BasedOnStyle``` to allow referencing an arbitrary file. While this could be an absolute path, that's not typically useful across machines. In typical usage, this will be a relative path (e.g., ```BasedOnStyle: format/team1.clang-format```). For resolving relative paths, I've mimicked the "include path" model of C/C++ (and, in fact, I'm able to leverage ```SourceMgr```'s "include paths" mechanism to implement this). The list of style search paths is specified on the command-line via one or more ```--style-search-path <path>``` parameters. The interesting stuff is in Format.cpp...most of the rest of this change is plumbing to get the StyleSearchPaths from the command-line to the call to ```getStyle()```. Unfinished aspects of this change: * No unit tests. I am happy to write some, but I'm unsure how to do this in a harmonious way, seeing as my change inherently relies on external files on the filesystem. Most of the unit tests I've seen in Clang rely on in-code strings. * ```--style-search-path .``` does not seem to work for specifying the current directory as a search path. Evidently the ```SourceMgr``` include paths mechanism does not handle this natively. Can someone point me to the proper "Clang" way to resolve paths like . or .. into paths that ```SourceMgr``` can handle? --- Patch is 80.87 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/107312.diff 39 Files Affected: - (modified) clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp (+19) - (modified) clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp (+4-3) - (modified) clang-tools-extra/clang-change-namespace/ChangeNamespace.h (+5-1) - (modified) clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp (+17-1) - (modified) clang-tools-extra/clang-include-fixer/tool/ClangIncludeFixer.cpp (+20-2) - (modified) clang-tools-extra/clang-move/Move.cpp (+1) - (modified) clang-tools-extra/clang-move/Move.h (+3) - (modified) clang-tools-extra/clang-move/tool/ClangMove.cpp (+19-3) - (modified) clang-tools-extra/clang-tidy/ClangTidy.cpp (+2-1) - (modified) clang-tools-extra/clang-tidy/ClangTidyOptions.h (+4) - (modified) clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp (+3-2) - (modified) clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h (+1) - (modified) clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp (+15) - (modified) clang-tools-extra/clangd/ClangdLSPServer.cpp (+1-1) - (modified) clang-tools-extra/clangd/ClangdServer.cpp (+9-4) - (modified) clang-tools-extra/clangd/ClangdServer.h (+10-1) - (modified) clang-tools-extra/clangd/Config.h (+4) - (modified) clang-tools-extra/clangd/IncludeCleaner.cpp (+1) - (modified) clang-tools-extra/clangd/SourceCode.cpp (+3) - (modified) clang-tools-extra/clangd/tool/Check.cpp (+1-1) - (modified) clang-tools-extra/clangd/tool/ClangdMain.cpp (+23) - (modified) clang-tools-extra/clangd/unittests/ClangdTests.cpp (+1-1) - (modified) clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp (+14-1) - (modified) clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp (+1-1) - (modified) clang-tools-extra/unittests/clang-move/ClangMoveTests.cpp (+2-2) - (modified) clang/include/clang/Format/Format.h (+27-2) - (modified) clang/include/clang/Tooling/Refactoring.h (+3-1) - (modified) clang/lib/Format/Format.cpp (+41-10) - (modified) clang/lib/Tooling/Refactoring.cpp (+2-2) - (modified) clang/tools/clang-format/ClangFormat.cpp (+20-1) - (modified) clang/unittests/Format/ConfigParseTest.cpp (+57-49) - (modified) clang/unittests/Format/FormatTestObjC.cpp (+28-28) - (modified) clang/unittests/Format/FormatTestRawStrings.cpp (+1-1) - (modified) clang/unittests/Format/ObjCPropertyAttributeOrderFixerTest.cpp (+4-2) - (modified) clang/unittests/Format/QualifierFixerTest.cpp (+4-2) - (modified) clang/unittests/Rename/ClangRenameTest.h (+1-1) - (modified) clang/unittests/Tooling/RefactoringTest.cpp (+2-1) - (modified) llvm/include/llvm/Support/YAMLTraits.h (+6) - (modified) llvm/lib/Support/YAMLTraits.cpp (+12) ``````````diff diff --git a/clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp b/clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp index 68b5743c6540f8..52e1251cb1482a 100644 --- a/clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp +++ b/clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp @@ -69,6 +69,24 @@ static cl::opt<std::string> FormatStyleOpt("style", cl::desc(format::StyleOptionHelpDescription), cl::init("LLVM"), cl::cat(FormattingCategory)); +static cl::list<std::string> +StyleSearchPaths( + "style-search-path", + cl::desc("Directory to search for BasedOnStyle files, when the value of the\n" + "BasedOnStyle directive is not one of the predefined styles, nor\n" + "InheritFromParent. Multiple style search paths may be specified,\n" + "and will be searched in order, stopping at the first file found."), + cl::value_desc("directory"), + cl::cat(FormattingCategory)); + +static cl::alias +StyleSearchPathShort( + "S", + cl::desc("Alias for --style-search-path"), + cl::cat(FormattingCategory), + cl::aliasopt(StyleSearchPaths), + cl::NotHidden); + namespace { // Helper object to remove the TUReplacement and TUDiagnostic (triggered by // "remove-change-desc-files" command line option) when exiting current scope. @@ -102,6 +120,7 @@ int main(int argc, char **argv) { // Determine a formatting style from options. auto FormatStyleOrError = format::getStyle(FormatStyleOpt, FormatStyleConfig, + StyleSearchPaths, format::DefaultFallbackStyle); if (!FormatStyleOrError) { llvm::errs() << llvm::toString(FormatStyleOrError.takeError()) << "\n"; diff --git a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp index 879c0d26d472a8..f1a4716e2c45ea 100644 --- a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp +++ b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp @@ -339,8 +339,9 @@ ChangeNamespaceTool::ChangeNamespaceTool( llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern, llvm::ArrayRef<std::string> AllowedSymbolPatterns, std::map<std::string, tooling::Replacements> *FileToReplacements, - llvm::StringRef FallbackStyle) - : FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements), + llvm::StringRef FallbackStyle, const std::vector<std::string>& StyleSearchPaths) + : FallbackStyle(FallbackStyle), StyleSearchPaths(StyleSearchPaths), + FileToReplacements(*FileToReplacements), OldNamespace(OldNs.ltrim(':')), NewNamespace(NewNs.ltrim(':')), FilePattern(FilePattern), FilePatternRE(FilePattern) { FileToReplacements->clear(); @@ -1004,7 +1005,7 @@ void ChangeNamespaceTool::onEndOfTranslationUnit() { // which refers to the original code. Replaces = Replaces.merge(NewReplacements); auto Style = - format::getStyle(format::DefaultFormatStyle, FilePath, FallbackStyle); + format::getStyle(format::DefaultFormatStyle, FilePath, StyleSearchPaths, FallbackStyle); if (!Style) { llvm::errs() << llvm::toString(Style.takeError()) << "\n"; continue; diff --git a/clang-tools-extra/clang-change-namespace/ChangeNamespace.h b/clang-tools-extra/clang-change-namespace/ChangeNamespace.h index d35119b70a69c4..969d983681ebd5 100644 --- a/clang-tools-extra/clang-change-namespace/ChangeNamespace.h +++ b/clang-tools-extra/clang-change-namespace/ChangeNamespace.h @@ -51,7 +51,8 @@ class ChangeNamespaceTool : public ast_matchers::MatchFinder::MatchCallback { llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern, llvm::ArrayRef<std::string> AllowedSymbolPatterns, std::map<std::string, tooling::Replacements> *FileToReplacements, - llvm::StringRef FallbackStyle = "LLVM"); + llvm::StringRef FallbackStyle = "LLVM", + const std::vector<std::string>& StyleSearchPaths = {}); void registerMatchers(ast_matchers::MatchFinder *Finder); @@ -109,6 +110,9 @@ class ChangeNamespaceTool : public ast_matchers::MatchFinder::MatchCallback { }; std::string FallbackStyle; + // Specifies the list of paths to be searched when FormatStyle or a BasedOnStyle + // in a .clang-format file specifies an arbitrary file to include + std::vector<std::string> StyleSearchPaths; // In match callbacks, this contains replacements for replacing `typeLoc`s in // and deleting forward declarations in the moved namespace blocks. // In `onEndOfTranslationUnit` callback, the previous added replacements are diff --git a/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp b/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp index 22d26db0c11bcf..b78dcfc713a037 100644 --- a/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp +++ b/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp @@ -72,6 +72,22 @@ cl::opt<std::string> Style("style", cl::desc("The style name used for reformatting."), cl::init("LLVM"), cl::cat(ChangeNamespaceCategory)); +cl::list<std::string> StyleSearchPaths( + "style-search-path", + cl::desc("Directory to search for BasedOnStyle files, when the value of the\n" + "BasedOnStyle directive is not one of the predefined styles, nor\n" + "InheritFromParent. Multiple style search paths may be specified,\n" + "and will be searched in order, stopping at the first file found."), + cl::value_desc("directory"), + cl::cat(ChangeNamespaceCategory)); + +cl::alias StyleSearchPathShort( + "S", + cl::desc("Alias for --style-search-path"), + cl::cat(ChangeNamespaceCategory), + cl::aliasopt(StyleSearchPaths), + cl::NotHidden); + cl::opt<std::string> AllowedFile( "allowed_file", cl::desc("A file containing regexes of symbol names that are not expected " @@ -135,7 +151,7 @@ int main(int argc, const char **argv) { SourceManager Sources(Diagnostics, FileMgr); Rewriter Rewrite(Sources, DefaultLangOptions); - if (!formatAndApplyAllReplacements(Tool.getReplacements(), Rewrite, Style)) { + if (!formatAndApplyAllReplacements(Tool.getReplacements(), Rewrite, Style, StyleSearchPaths)) { llvm::errs() << "Failed applying all replacements.\n"; return 1; } diff --git a/clang-tools-extra/clang-include-fixer/tool/ClangIncludeFixer.cpp b/clang-tools-extra/clang-include-fixer/tool/ClangIncludeFixer.cpp index 3a11a22def1946..febbd4021ac4b7 100644 --- a/clang-tools-extra/clang-include-fixer/tool/ClangIncludeFixer.cpp +++ b/clang-tools-extra/clang-include-fixer/tool/ClangIncludeFixer.cpp @@ -157,6 +157,24 @@ cl::opt<std::string> "headers if there is no clang-format config file found."), cl::init("llvm"), cl::cat(IncludeFixerCategory)); +static cl::list<std::string> +StyleSearchPaths( + "style-search-path", + cl::desc("Directory to search for BasedOnStyle files, when the value of the\n" + "BasedOnStyle directive is not one of the predefined styles, nor\n" + "InheritFromParent. Multiple style search paths may be specified,\n" + "and will be searched in order, stopping at the first file found."), + cl::value_desc("directory"), + cl::cat(IncludeFixerCategory)); + +static cl::alias +StyleSearchPathShort( + "S", + cl::desc("Alias for --style-search-path"), + cl::cat(IncludeFixerCategory), + cl::aliasopt(StyleSearchPaths), + cl::NotHidden ); + std::unique_ptr<include_fixer::SymbolIndexManager> createSymbolIndexManager(StringRef FilePath) { using find_all_symbols::SymbolInfo; @@ -330,7 +348,7 @@ int includeFixerMain(int argc, const char **argv) { return LHS.QualifiedName == RHS.QualifiedName; }); auto InsertStyle = format::getStyle(format::DefaultFormatStyle, - Context.getFilePath(), Style); + Context.getFilePath(), StyleSearchPaths, Style); if (!InsertStyle) { llvm::errs() << llvm::toString(InsertStyle.takeError()) << "\n"; return 1; @@ -410,7 +428,7 @@ int includeFixerMain(int argc, const char **argv) { for (const auto &Context : Contexts) { StringRef FilePath = Context.getFilePath(); auto InsertStyle = - format::getStyle(format::DefaultFormatStyle, FilePath, Style); + format::getStyle(format::DefaultFormatStyle, FilePath, StyleSearchPaths, Style); if (!InsertStyle) { llvm::errs() << llvm::toString(InsertStyle.takeError()) << "\n"; return 1; diff --git a/clang-tools-extra/clang-move/Move.cpp b/clang-tools-extra/clang-move/Move.cpp index ac16803b46783e..d5068d3087b44f 100644 --- a/clang-tools-extra/clang-move/Move.cpp +++ b/clang-tools-extra/clang-move/Move.cpp @@ -781,6 +781,7 @@ void ClangMoveTool::removeDeclsInOldFiles() { if (SI == FilePathToFileID.end()) continue; llvm::StringRef Code = SM.getBufferData(SI->second); auto Style = format::getStyle(format::DefaultFormatStyle, FilePath, + Context->StyleSearchPaths, Context->FallbackStyle); if (!Style) { llvm::errs() << llvm::toString(Style.takeError()) << "\n"; diff --git a/clang-tools-extra/clang-move/Move.h b/clang-tools-extra/clang-move/Move.h index ea241bbbc4f8a0..a368fac3645dbf 100644 --- a/clang-tools-extra/clang-move/Move.h +++ b/clang-tools-extra/clang-move/Move.h @@ -89,6 +89,9 @@ struct ClangMoveContext { // directory when analyzing the source file. We save the original working // directory in order to get the absolute file path for the fields in Spec. std::string OriginalRunningDirectory; + // Specifies the list of paths to be searched when BasedOnStyle + // in a .clang-format file specifies an arbitrary file to include + std::vector<std::string> StyleSearchPaths; // The name of a predefined code style. std::string FallbackStyle; // Whether dump all declarations in old header. diff --git a/clang-tools-extra/clang-move/tool/ClangMove.cpp b/clang-tools-extra/clang-move/tool/ClangMove.cpp index 1560dcaad67793..5ea3ef218ed0f3 100644 --- a/clang-tools-extra/clang-move/tool/ClangMove.cpp +++ b/clang-tools-extra/clang-move/tool/ClangMove.cpp @@ -76,6 +76,22 @@ cl::opt<bool> "add #include of old header to new header."), cl::init(false), cl::cat(ClangMoveCategory)); +cl::list<std::string> + StyleSearchPaths("style-search-path", + cl::desc("Directory to search for BasedOnStyle files, when the value of the\n" + "BasedOnStyle directive is not one of the predefined styles, nor\n" + "InheritFromParent. Multiple style search paths may be specified,\n" + "and will be searched in order, stopping at the first file found."), + cl::value_desc("directory"), + cl::cat(ClangMoveCategory)); + +cl::alias + StyleSearchPathShort("S", + cl::desc("Alias for --style-search-path"), + cl::cat(ClangMoveCategory), + cl::aliasopt(StyleSearchPaths), + cl::NotHidden); + cl::opt<std::string> Style("style", cl::desc("The style name used for reformatting. Default is \"llvm\""), @@ -131,8 +147,8 @@ int main(int argc, const char **argv) { Twine(EC.message())); move::ClangMoveContext Context{Spec, Tool.getReplacements(), - std::string(InitialDirectory), Style, - DumpDecls}; + std::string(InitialDirectory), StyleSearchPaths, + Style, DumpDecls}; move::DeclarationReporter Reporter; move::ClangMoveActionFactory Factory(&Context, &Reporter); @@ -185,7 +201,7 @@ int main(int argc, const char **argv) { SourceManager SM(Diagnostics, FileMgr); Rewriter Rewrite(SM, LangOptions()); - if (!formatAndApplyAllReplacements(Tool.getReplacements(), Rewrite, Style)) { + if (!formatAndApplyAllReplacements(Tool.getReplacements(), Rewrite, Style, StyleSearchPaths)) { llvm::errs() << "Failed applying all replacements.\n"; return 1; } diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp index 1cd7cdd10bc25f..32b0de29291ce4 100644 --- a/clang-tools-extra/clang-tidy/ClangTidy.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp @@ -209,7 +209,8 @@ class ErrorReporter { } StringRef Code = Buffer.get()->getBuffer(); auto Style = format::getStyle( - *Context.getOptionsForFile(File).FormatStyle, File, "none"); + *Context.getOptionsForFile(File).FormatStyle, File, + Context.getGlobalOptions().StyleSearchPaths, "none"); if (!Style) { llvm::errs() << llvm::toString(Style.takeError()) << "\n"; continue; diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h b/clang-tools-extra/clang-tidy/ClangTidyOptions.h index 85d5a02ebbc1bc..e71299c3278361 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyOptions.h +++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.h @@ -42,6 +42,10 @@ struct ClangTidyGlobalOptions { /// Output warnings from certain line ranges of certain files only. /// If empty, no warnings will be filtered. std::vector<FileFilter> LineFilter; + + /// Specifies the list of paths to be searched when BasedOnStyle + /// in a .clang-format file specifies an arbitrary file to include + std::vector<std::string> StyleSearchPaths; }; /// Contains options for clang-tidy. These options may be read from diff --git a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp index 5e7a0e65690b7a..7d76b13f0735f4 100644 --- a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp @@ -60,7 +60,8 @@ IncludeCleanerCheck::IncludeCleanerCheck(StringRef Name, IgnoreHeaders(utils::options::parseStringList( Options.getLocalOrGlobal("IgnoreHeaders", ""))), DeduplicateFindings( - Options.getLocalOrGlobal("DeduplicateFindings", true)) { + Options.getLocalOrGlobal("DeduplicateFindings", true)), + StyleSearchPaths(Context->getGlobalOptions().StyleSearchPaths) { for (const auto &Header : IgnoreHeaders) { if (!llvm::Regex{Header}.isValid()) configurationDiag("Invalid ignore headers regex '%0'") << Header; @@ -196,7 +197,7 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) { llvm::StringRef Code = SM->getBufferData(SM->getMainFileID()); auto FileStyle = format::getStyle(format::DefaultFormatStyle, getCurrentMainFile(), - format::DefaultFallbackStyle, Code, + StyleSearchPaths, format::DefaultFallbackStyle, Code, &SM->getFileManager().getVirtualFileSystem()); if (!FileStyle) FileStyle = format::getLLVMStyle(); diff --git a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h index b46e409bd6f6a0..229c8b7127cbc9 100644 --- a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h +++ b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h @@ -47,6 +47,7 @@ class IncludeCleanerCheck : public ClangTidyCheck { std::vector<StringRef> IgnoreHeaders; // Whether emit only one finding per usage of a symbol. const bool DeduplicateFindings; + std::vector<std::string> StyleSearchPaths; llvm::SmallVector<llvm::Regex> IgnoreHeadersRegex; bool shouldIgnore(const include_cleaner::Header &H); }; diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp index d42dafa8ffc362..4148c3a8d9d514 100644 --- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp +++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp @@ -208,6 +208,20 @@ This option overrides the 'FormatStyle` option in cl::init("none"), cl::cat(ClangTidyCategory)); +static cl::list<std::string> StyleSearchPaths("style-search-path", desc(R"( +Directory to search for BasedOnStyle files, when the value of the +BasedOnStyle directive is not one of the predefined styles, nor +InheritFromParent. Multiple style search paths may be specified, +and will be searched in order, stopping at the first file found. +)"), + cl::value_desc("directory"), + cl::cat(ClangTidyCategory)); + +static cl::alias StyleSearchPathShort("S", cl::desc("Alias for --style-search-path"), + cl::cat(ClangTidyCategory), + cl::aliasopt(StyleSearchPaths), + cl::NotHidden); + static cl::opt<bool> ListChecks("list-checks", desc(R"( List all enabled checks and exit. Use with -checks=* to list all available checks. @@ -366,6 +380,7 @@ static void printStats(const ClangTidyStats &Stats) { static std::unique_ptr<ClangTidyOptionsProvider> createOptionsProvider( llvm::IntrusiveRefCntPtr<vfs::FileSystem> FS) { ClangTidyGlobalOptions GlobalOptions; + GlobalOptions.StyleSearchPaths = StyleSearchPaths; if (std::error_code Err = parseLineFilter(LineFilter, GlobalOptions)) { llvm::errs() << "Invalid LineFilter: " << Err.message() << "\n\nUsage:\n"; llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true); diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp index 06573a57554245..a169a7885c0679 100644 --- a/clang-tools-extra/clangd/ClangdLSPServer.cpp +++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp @@ -1650,7 +1650,7 @@ ClangdLSPServer::ClangdLSPServer(Transport &Transp, const ThreadsafeFS &TFS, assert(!Opts.ContextProvider && "Only one of ConfigProvider and ContextProvider allowed!"); this->Opts.ContextProvider = ClangdServer::createConfiguredContextProvider( - Opts.ConfigProvider, this); + Opts.ConfigProvider, this, Opts.StyleSearchPaths); } LSPBinder Bind(this->Handlers, *this); Bind.method("initialize", this, &ClangdLSPServer::onInitialize); diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp index e910a80ba0bae9..cfd60bb8279077 100644 --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -223,6 +223,7 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB, PreambleParseForwardingFunctions(Opts.PreambleParseForwardingFunctions), ImportInsertions(Opts.ImportInsertions), PublishInactiveRegions(Opts.PublishInactiveRegions), + StyleSearchPaths(Opts.StyleSearchPaths), WorkspaceRoot(Opts.WorkspaceRoot), Transient(Opts.ImplicitCancellation ? TUScheduler::InvalidateOnUpdate : TUScheduler::NoInvalidation), @@ -335,17 +336,20 @@ std::shared_ptr<const std::string> ClangdServer::getDraft(PathRef File) const { std::function<Context(PathRef)> ClangdServer::createConfiguredContextProvider(const config::Provider *Provider, - Callbacks *Publish) { + Callbacks *Publish, + const std::vector<std::string> &StyleSearchPaths) { if (!Provider) return [](llvm::StringRef) { return Context::current().clone(); }; struct Impl { const config::Provider *Provider; ClangdServer::Callbacks *Publish; + std::vector<std::string> StyleSearchPaths; std::mutex PublishMu; - Impl(const config::Provider *Provider, ClangdServer::Callbacks *Publish) - : Provider(Provider), Publish(Publish) {} + Impl(const config::Provider *Provide... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/107312 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits