#include "llvm/IR/Value.h"
#include "llvm-c/Core.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ModuleSlotTracker.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/SourceMgr.h"
#include "gtest/gtest.h"
usingnamespacellvm;
extern cl::opt<bool> UseNewDbgInfoFormat;
namespace {
TEST(ValueTest, UsedInBasicBlock) { … }
TEST(GlobalTest, CreateAddressSpace) { … }
#ifdef GTEST_HAS_DEATH_TEST
#ifndef NDEBUG
TEST(GlobalTest, AlignDeath) {
LLVMContext Ctx;
std::unique_ptr<Module> M(new Module("TestModule", Ctx));
Type *Int32Ty = Type::getInt32Ty(Ctx);
GlobalVariable *Var =
new GlobalVariable(*M, Int32Ty, true, GlobalValue::ExternalLinkage,
Constant::getAllOnesValue(Int32Ty), "var", nullptr,
GlobalVariable::NotThreadLocal, 1);
EXPECT_DEATH(Var->setAlignment(Align(8589934592ULL)),
"Alignment is greater than MaximumAlignment");
}
#endif
#endif
TEST(ValueTest, printSlots) { … }
TEST(ValueTest, getLocalSlots) { … }
#if defined(GTEST_HAS_DEATH_TEST) && !defined(NDEBUG)
TEST(ValueTest, getLocalSlotDeath) {
LLVMContext C;
const char *ModuleString = "define void @f(i32 %x, i32 %y) {\n"
"entry:\n"
" %0 = add i32 %y, 1\n"
" %1 = add i32 %y, 1\n"
" br label %2\n"
"\n"
" ret void\n"
"}\n";
SMDiagnostic Err;
std::unique_ptr<Module> M = parseAssemblyString(ModuleString, Err, C);
Function *F = M->getFunction("f");
ASSERT_TRUE(F);
ASSERT_FALSE(F->empty());
BasicBlock *BB2 = &*++F->begin();
ASSERT_TRUE(BB2);
ModuleSlotTracker MST(M.get());
EXPECT_DEATH(MST.getLocalSlot(BB2), "No function incorporated");
}
#endif
TEST(ValueTest, replaceUsesOutsideBlock) { … }
TEST(ValueTest, replaceUsesOutsideBlockDbgVariableRecord) { … }
TEST(GlobalTest, Initializer) { … }
}