Skip to content

Commit

Permalink
Test addition.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluescarni committed Aug 22, 2023
1 parent 3d0559a commit 74a3b02
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/llvm_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@

#include <initializer_list>
#include <iostream>
#include <iterator>
#include <limits>
#include <sstream>
#include <stdexcept>
#include <utility>
#include <vector>

#include <llvm/IR/BasicBlock.h>
#include <llvm/IR/DerivedTypes.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Module.h>

#if defined(HEYOKA_HAVE_REAL128)

#include <mp++/real128.hpp>
Expand Down Expand Up @@ -338,3 +346,24 @@ TEST_CASE("force_avx512")
REQUIRE(s5.force_avx512());
}
}

TEST_CASE("existing trigger")
{
using Catch::Matchers::Message;

llvm_state s;

auto &bld = s.builder();

auto *ft = llvm::FunctionType::get(bld.getVoidTy(), {}, false);
auto *f = llvm::Function::Create(ft, llvm::Function::ExternalLinkage, "heyoka.obj_trigger", &s.module());

bld.SetInsertPoint(llvm::BasicBlock::Create(s.context(), "entry", f));
bld.CreateRetVoid();

REQUIRE_THROWS_MATCHES(s.compile(), std::invalid_argument,
Message("Unable to create an LLVM function with name 'heyoka.obj_trigger'"));

// Check that the second function was properly cleaned up.
REQUIRE(std::distance(s.module().begin(), s.module().end()) == 1);
}

0 comments on commit 74a3b02

Please sign in to comment.