[llvm-branch-commits] [clang-tools-extra] 4a0528e - [clangd][NFC] Small tweak to combined provider

Nathan James via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Dec 8 09:17:46 PST 2020


Author: Nathan James
Date: 2020-12-08T17:12:56Z
New Revision: 4a0528e4a0e3e4504db8650bf2bf7d6977ffa018

URL: https://github.com/llvm/llvm-project/commit/4a0528e4a0e3e4504db8650bf2bf7d6977ffa018
DIFF: https://github.com/llvm/llvm-project/commit/4a0528e4a0e3e4504db8650bf2bf7d6977ffa018.diff

LOG: [clangd][NFC] Small tweak to combined provider

This should address the FIXME about clang3.9 dervied to base unique_ptr constructor not working.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D91925

Added: 
    

Modified: 
    clang-tools-extra/clangd/ConfigProvider.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/ConfigProvider.cpp b/clang-tools-extra/clangd/ConfigProvider.cpp
index 0933e7e2c283..05b2ba50566d 100644
--- a/clang-tools-extra/clangd/ConfigProvider.cpp
+++ b/clang-tools-extra/clangd/ConfigProvider.cpp
@@ -144,7 +144,7 @@ Provider::fromAncestorRelativeYAMLFiles(llvm::StringRef RelPath,
 
 std::unique_ptr<Provider>
 Provider::combine(std::vector<const Provider *> Providers) {
-  struct CombinedProvider : Provider {
+  class CombinedProvider : public Provider {
     std::vector<const Provider *> Providers;
 
     std::vector<CompiledFragment>
@@ -156,14 +156,13 @@ Provider::combine(std::vector<const Provider *> Providers) {
       }
       return Result;
     }
+
+  public:
+    CombinedProvider(std::vector<const Provider *> Providers)
+        : Providers(std::move(Providers)) {}
   };
-  auto Result = std::make_unique<CombinedProvider>();
-  Result->Providers = std::move(Providers);
-  // FIXME: This is a workaround for a bug in older versions of clang (< 3.9)
-  //   The constructor that is supposed to allow for Derived to Base
-  //   conversion does not work. Remove this if we drop support for such
-  //   configurations.
-  return std::unique_ptr<Provider>(Result.release());
+
+  return std::make_unique<CombinedProvider>(std::move(Providers));
 }
 
 Config Provider::getConfig(const Params &P, DiagnosticCallback DC) const {


        


More information about the llvm-branch-commits mailing list