Skip to content

Commit

Permalink
Fix compatibility with LLVM 16
Browse files Browse the repository at this point in the history
LLVM 16 uses std::optional in place of llvm::Optional. Since these have very similar interfaces, we use auto to maintain backwards compatibility.

Compiles successfully with LLVM 16 and LLVM 15.
  • Loading branch information
katrinafyi authored Nov 20, 2023
1 parent 511b64c commit 31477b6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/bap_llvm/llvm_disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,8 @@ 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 is llvm::Optional<std::string> or std::optional<std::string>
const auto& env_value = llvm::sys::Process::GetEnv(llvm::StringRef(env_var));
if (!env_value)
return;

Expand Down

0 comments on commit 31477b6

Please sign in to comment.