clover: Fix build after clang r370122.
authorHal Gentz <zegentzy@protonmail.com>
Sun, 1 Sep 2019 23:31:04 +0000 (17:31 -0600)
committerAaron Watry <awatry@gmail.com>
Thu, 5 Sep 2019 03:29:52 +0000 (22:29 -0500)
../mesa/src/gallium/state_trackers/clover/llvm/invocation.cpp: In function ‘std::unique_ptr<clang::CompilerInstance> {anonymous}::create_compiler_instance(const clover::device&, const std::vector<std::__cxx11::basic_string<char> >&, std::string&)’:
../mesa/src/gallium/state_trackers/clover/llvm/invocation.cpp:203:81: error: no matching function for call to ‘clang::CompilerInvocation::CreateFromArgs(clang::CompilerInvocation&, const char* const*, const char* const*, clang::DiagnosticsEngine&)’
  203 |              c->getInvocation(), copts.data(), copts.data() + copts.size(), diag))
      |                                                                                 ^
In file included from /opt/llvm64/include/clang/Frontend/CompilerInstance.h:15,
                 from ../mesa/src/gallium/state_trackers/clover/llvm/codegen.hpp:37,
                 from ../mesa/src/gallium/state_trackers/clover/llvm/invocation.cpp:49:
/opt/llvm64/include/clang/Frontend/CompilerInvocation.h:157:15: note: candidate: ‘static bool clang::CompilerInvocation::CreateFromArgs(clang::CompilerInvocation&, llvm::ArrayRef<const char*>, clang::DiagnosticsEngine&)’
  157 |   static bool CreateFromArgs(CompilerInvocation &Res,
      |               ^~~~~~~~~~~~~~
/opt/llvm64/include/clang/Frontend/CompilerInvocation.h:157:15: note:   candidate expects 3 arguments, 4 provided

Signed-off-by: Hal Gentz <zegentzy@protonmail.com>
Reviewed-by: Aaron Watry <awatry@gmail.com>
src/gallium/state_trackers/clover/llvm/compat.hpp
src/gallium/state_trackers/clover/llvm/invocation.cpp

index b040902..629a759 100644 (file)
@@ -167,6 +167,20 @@ namespace clover {
 #endif
          }
 
+         template<typename T> inline bool
+         create_compiler_invocation_from_args(clang::CompilerInvocation &cinv,
+                                              T copts,
+                                              clang::DiagnosticsEngine &diag)
+         {
+#if HAVE_LLVM >= 0x1000
+            return clang::CompilerInvocation::CreateFromArgs(
+               cinv, copts, diag);
+#else
+            return clang::CompilerInvocation::CreateFromArgs(
+               cinv, copts.data(), copts.data() + copts.size(), diag);
+#endif
+         }
+
          template<typename T, typename M>
          T get_abi_type(const T &arg_type, const M &mod) {
 #if HAVE_LLVM >= 0x0700
index 0a677ce..deaf1cc 100644 (file)
@@ -199,8 +199,8 @@ namespace {
       const target &target = dev.ir_target();
       const std::string &device_clc_version = dev.device_clc_version();
 
-      if (!clang::CompilerInvocation::CreateFromArgs(
-             c->getInvocation(), copts.data(), copts.data() + copts.size(), diag))
+      if (!compat::create_compiler_invocation_from_args(
+             c->getInvocation(), copts, diag))
          throw invalid_build_options_error();
 
       diag_buffer->FlushDiagnostics(diag);