[clangd][NFC] Small tweak to combined provider
authorNathan James <n.james93@hotmail.co.uk>
Tue, 8 Dec 2020 17:12:55 +0000 (17:12 +0000)
committerNathan James <n.james93@hotmail.co.uk>
Tue, 8 Dec 2020 17:12:56 +0000 (17:12 +0000)
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

clang-tools-extra/clangd/ConfigProvider.cpp

index 0933e7e..05b2ba5 100644 (file)
@@ -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 {