Loading clang-tools-extra/clangd/ConfigProvider.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -193,9 +193,9 @@ Provider::fromAncestorRelativeYAMLFiles(llvm::StringRef RelPath, } std::unique_ptr<Provider> Provider::combine(std::vector<std::unique_ptr<Provider>> Providers) { Provider::combine(std::vector<const Provider *> Providers) { struct CombinedProvider : Provider { std::vector<std::unique_ptr<Provider>> Providers; std::vector<const Provider *> Providers; std::vector<CompiledFragment> getFragments(const Params &P, DiagnosticCallback DC) const override { Loading clang-tools-extra/clangd/ConfigProvider.h +1 −2 Original line number Diff line number Diff line Loading @@ -76,8 +76,7 @@ public: /// A provider that includes fragments from all the supplied providers. /// Order is preserved; later providers take precedence over earlier ones. static std::unique_ptr<Provider> combine(std::vector<std::unique_ptr<Provider>>); static std::unique_ptr<Provider> combine(std::vector<const Provider *>); /// Build a config based on this provider. Config getConfig(const Params &, DiagnosticCallback) const; Loading clang-tools-extra/clangd/tool/ClangdMain.cpp +5 −2 Original line number Diff line number Diff line Loading @@ -703,9 +703,9 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var CCOpts.RunParser = CodeCompletionParse; RealThreadsafeFS TFS; std::vector<std::unique_ptr<config::Provider>> ProviderStack; std::unique_ptr<config::Provider> Config; if (EnableConfig) { std::vector<std::unique_ptr<config::Provider>> ProviderStack; ProviderStack.push_back( config::Provider::fromAncestorRelativeYAMLFiles(".clangd", TFS)); llvm::SmallString<256> UserConfig; Loading @@ -716,7 +716,10 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var } else { elog("Couldn't determine user config file, not loading"); } Config = config::Provider::combine(std::move(ProviderStack)); std::vector<const config::Provider *> ProviderPointers; for (const auto& P : ProviderStack) ProviderPointers.push_back(P.get()); Config = config::Provider::combine(std::move(ProviderPointers)); Opts.ConfigProvider = Config.get(); } Loading clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -57,10 +57,9 @@ std::vector<std::string> getAddedArgs(Config &C) { // cache their results. TEST(ProviderTest, Combine) { CapturedDiags Diags; std::vector<std::unique_ptr<Provider>> Providers; Providers.push_back(std::make_unique<FakeProvider>("foo")); Providers.push_back(std::make_unique<FakeProvider>("bar")); auto Combined = Provider::combine(std::move(Providers)); FakeProvider Foo("foo"); FakeProvider Bar("bar"); auto Combined = Provider::combine({&Foo, &Bar}); Config Cfg = Combined->getConfig(Params(), Diags.callback()); EXPECT_THAT(Diags.Diagnostics, ElementsAre(DiagMessage("foo"), DiagMessage("bar"))); Loading Loading
clang-tools-extra/clangd/ConfigProvider.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -193,9 +193,9 @@ Provider::fromAncestorRelativeYAMLFiles(llvm::StringRef RelPath, } std::unique_ptr<Provider> Provider::combine(std::vector<std::unique_ptr<Provider>> Providers) { Provider::combine(std::vector<const Provider *> Providers) { struct CombinedProvider : Provider { std::vector<std::unique_ptr<Provider>> Providers; std::vector<const Provider *> Providers; std::vector<CompiledFragment> getFragments(const Params &P, DiagnosticCallback DC) const override { Loading
clang-tools-extra/clangd/ConfigProvider.h +1 −2 Original line number Diff line number Diff line Loading @@ -76,8 +76,7 @@ public: /// A provider that includes fragments from all the supplied providers. /// Order is preserved; later providers take precedence over earlier ones. static std::unique_ptr<Provider> combine(std::vector<std::unique_ptr<Provider>>); static std::unique_ptr<Provider> combine(std::vector<const Provider *>); /// Build a config based on this provider. Config getConfig(const Params &, DiagnosticCallback) const; Loading
clang-tools-extra/clangd/tool/ClangdMain.cpp +5 −2 Original line number Diff line number Diff line Loading @@ -703,9 +703,9 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var CCOpts.RunParser = CodeCompletionParse; RealThreadsafeFS TFS; std::vector<std::unique_ptr<config::Provider>> ProviderStack; std::unique_ptr<config::Provider> Config; if (EnableConfig) { std::vector<std::unique_ptr<config::Provider>> ProviderStack; ProviderStack.push_back( config::Provider::fromAncestorRelativeYAMLFiles(".clangd", TFS)); llvm::SmallString<256> UserConfig; Loading @@ -716,7 +716,10 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var } else { elog("Couldn't determine user config file, not loading"); } Config = config::Provider::combine(std::move(ProviderStack)); std::vector<const config::Provider *> ProviderPointers; for (const auto& P : ProviderStack) ProviderPointers.push_back(P.get()); Config = config::Provider::combine(std::move(ProviderPointers)); Opts.ConfigProvider = Config.get(); } Loading
clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -57,10 +57,9 @@ std::vector<std::string> getAddedArgs(Config &C) { // cache their results. TEST(ProviderTest, Combine) { CapturedDiags Diags; std::vector<std::unique_ptr<Provider>> Providers; Providers.push_back(std::make_unique<FakeProvider>("foo")); Providers.push_back(std::make_unique<FakeProvider>("bar")); auto Combined = Provider::combine(std::move(Providers)); FakeProvider Foo("foo"); FakeProvider Bar("bar"); auto Combined = Provider::combine({&Foo, &Bar}); Config Cfg = Combined->getConfig(Params(), Diags.callback()); EXPECT_THAT(Diags.Diagnostics, ElementsAre(DiagMessage("foo"), DiagMessage("bar"))); Loading