Skip to content

Commit

Permalink
Fixes for LLVM 17
Browse files Browse the repository at this point in the history
  • Loading branch information
bmourad01 committed Feb 15, 2024
1 parent 511b64c commit 18fcdc1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/bap_llvm/llvm_disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
#include <llvm/MC/MCDisassembler/MCDisassembler.h>

#include <llvm/ADT/ArrayRef.h>
#if LLVM_VERSION_MAJOR >= 17
#include <llvm/TargetParser/Triple.h>
#else
#include <llvm/ADT/Triple.h>
#endif
#include <llvm/ADT/Twine.h>

template <typename T>
Expand Down Expand Up @@ -464,7 +468,12 @@ class llvm_disassembler : public disassembler_interface {
} else if (p == is_true) {
return true;
} else {
#if LLVM_VERSION_MAJOR >= 17
// MCInstrDesc needs to know its own address to access some implicit tables.
auto &d = ins_info->get(current.code);
#else
auto d = ins_info->get(current.code);
#endif
if (p == may_affect_control_flow) {
return d.mayAffectControlFlow(mcinst, *reg_info);
} else if (auto check = fun_of_pred(p)) {
Expand Down Expand Up @@ -652,7 +661,7 @@ struct create_llvm_disassembler : disasm_factory {

static void parse_environment_options(const char *prog_name, const char *env_var) {
#if LLVM_VERSION_MAJOR >= 12
llvm::Optional<std::string> env_value = llvm::sys::Process::GetEnv(llvm::StringRef(env_var));
auto env_value = llvm::sys::Process::GetEnv(llvm::StringRef(env_var));
if (!env_value)
return;

Expand Down
4 changes: 4 additions & 0 deletions lib/bap_llvm/llvm_loader_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#include <iomanip>
#include <iostream>

#if LLVM_VERSION_MAJOR >= 17
#include <llvm/TargetParser/Triple.h>
#else
#include <llvm/ADT/Triple.h>
#endif

#include "llvm_error_or.hpp"

Expand Down
5 changes: 5 additions & 0 deletions lib/bap_llvm/llvm_primitives.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#include <iostream>

#include <llvm/Config/llvm-config.h>
#if LLVM_VERSION_MAJOR >= 17
#include <llvm/TargetParser/Triple.h>
#else
#include <llvm/ADT/Triple.h>
#endif

#include "llvm_primitives.hpp"

Expand Down

0 comments on commit 18fcdc1

Please sign in to comment.