std::vector<char>
emit_code(::llvm::Module &mod, const target &target,
- TargetMachine::CodeGenFileType ft,
+ compat::CodeGenFileType ft,
std::string &r_log) {
std::string err;
auto t = ::llvm::TargetRegistry::lookupTarget(target.triple, err);
mod.setDataLayout(tm->createDataLayout());
tm->Options.MCOptions.AsmVerbose =
- (ft == TargetMachine::CGFT_AssemblyFile);
+ (ft == compat::CGFT_AssemblyFile);
if (compat::add_passes_to_emit_file(*tm, pm, os, ft))
fail(r_log, build_error(), "TargetMachine can't emit this file");
const clang::CompilerInstance &c,
std::string &r_log) {
const auto code = emit_code(mod, target,
- TargetMachine::CGFT_ObjectFile, r_log);
+ compat::CGFT_ObjectFile, r_log);
return build_module_common(mod, code, get_symbol_offsets(code, r_log), c);
}
try {
std::unique_ptr< ::llvm::Module> cmod { compat::clone_module(mod) };
return as_string(emit_code(*cmod, target,
- TargetMachine::CGFT_AssemblyFile, log));
+ compat::CGFT_AssemblyFile, log));
} catch (...) {
return "Couldn't output native disassembly: " + log;
}
#include <clang/Frontend/CodeGenOptions.h>
#endif
+#if LLVM_VERSION_MAJOR >= 10
+#include <llvm/Support/CodeGen.h>
+#endif
+
namespace clover {
namespace llvm {
namespace compat {
+
+#if LLVM_VERSION_MAJOR >= 10
+ const auto CGFT_ObjectFile = ::llvm::CGFT_ObjectFile;
+ const auto CGFT_AssemblyFile = ::llvm::CGFT_AssemblyFile;
+ typedef ::llvm::CodeGenFileType CodeGenFileType;
+#else
+ const auto CGFT_ObjectFile = ::llvm::TargetMachine::CGFT_ObjectFile;
+ const auto CGFT_AssemblyFile =
+ ::llvm::TargetMachine::CGFT_AssemblyFile;
+ typedef ::llvm::TargetMachine::CodeGenFileType CodeGenFileType;
+#endif
+
template<typename T, typename AS>
unsigned target_address_space(const T &target, const AS lang_as) {
const auto &map = target.getAddressSpaceMap();