clover: Fix build with llvm-12.

Fix build error after LLVM commit c495dfe0268b ("[clang][cli] NFC:
Decrease the scope of ParseLangArgs parameters").

../src/gallium/frontends/clover/llvm/invocation.cpp: In function ‘std::unique_ptr<clang::CompilerInstance> {anonymous}::create_compiler_instance(const clover::device&, const string&, const std::vector<std::__cxx11::basic_string<char> >&, std::string&)’:
../src/gallium/frontends/clover/llvm/invocation.cpp:252:55: error: cannot convert ‘clang::PreprocessorOptions’ to ‘std::vector<std::__cxx11::basic_string<char> >&’
  252 |                                 c->getPreprocessorOpts(),
      |                                 ~~~~~~~~~~~~~~~~~~~~~~^~
      |                                                       |
      |                                                       clang::PreprocessorOptions

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4114
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8543>
This commit is contained in:
Karol Herbst
2021-02-24 12:44:41 +01:00
committed by Marge Bot
parent 05f8efbc2c
commit d1eab2b1eb
2 changed files with 20 additions and 7 deletions

View File

@@ -38,14 +38,14 @@
#include <llvm/Config/llvm-config.h>
#include <llvm/ADT/Triple.h>
#include <llvm/Analysis/TargetLibraryInfo.h>
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/Linker/Linker.h>
#include <llvm/Target/TargetMachine.h>
#include <llvm/Transforms/IPO.h>
#include <llvm/Transforms/Utils/Cloning.h>
#include <llvm/Target/TargetMachine.h>
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/Analysis/TargetLibraryInfo.h>
#include <clang/Basic/TargetInfo.h>
#include <clang/Frontend/CompilerInstance.h>
@@ -88,6 +88,20 @@ namespace clover {
cinv, copts.data(), copts.data() + copts.size(), diag);
#endif
}
static inline void
compiler_set_lang_defaults(std::unique_ptr<clang::CompilerInstance> &c,
clang::InputKind ik, const ::llvm::Triple& triple,
clang::LangStandard::Kind d)
{
c->getInvocation().setLangDefaults(c->getLangOpts(), ik, triple,
#if LLVM_VERSION_MAJOR >= 12
c->getPreprocessorOpts().Includes,
#else
c->getPreprocessorOpts(),
#endif
d);
}
}
}
}

View File

@@ -247,9 +247,8 @@ namespace {
// http://www.llvm.org/bugs/show_bug.cgi?id=19735
c->getDiagnosticOpts().ShowCarets = false;
c->getInvocation().setLangDefaults(c->getLangOpts(),
compat::ik_opencl, ::llvm::Triple(target.triple),
c->getPreprocessorOpts(),
compat::compiler_set_lang_defaults(c, compat::ik_opencl,
::llvm::Triple(target.triple),
get_language_version(opts, device_clc_version));
c->createDiagnostics(new clang::TextDiagnosticPrinter(