#include "llvm/IR/Constants.h"
#include "llvm-c/Core.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/ConstantFold.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/SourceMgr.h"
#include "gtest/gtest.h"
namespace llvm {
namespace {
TEST(ConstantsTest, Integer_i1) { … }
TEST(ConstantsTest, IntSigns) { … }
TEST(ConstantsTest, PointerCast) { … }
#define CHECK …
TEST(ConstantsTest, AsInstructionsTest) { … }
#ifdef GTEST_HAS_DEATH_TEST
#ifndef NDEBUG
TEST(ConstantsTest, ReplaceWithConstantTest) {
LLVMContext Context;
std::unique_ptr<Module> M(new Module("MyModule", Context));
Type *Int32Ty = Type::getInt32Ty(Context);
Constant *One = ConstantInt::get(Int32Ty, 1);
Constant *Global =
M->getOrInsertGlobal("dummy", PointerType::getUnqual(Int32Ty));
Constant *GEP = ConstantExpr::getGetElementPtr(
PointerType::getUnqual(Int32Ty), Global, One);
EXPECT_DEATH(Global->replaceAllUsesWith(GEP),
"this->replaceAllUsesWith\\(expr\\(this\\)\\) is NOT valid!");
}
#endif
#endif
#undef CHECK
TEST(ConstantsTest, ConstantArrayReplaceWithConstant) { … }
TEST(ConstantsTest, ConstantExprReplaceWithConstant) { … }
TEST(ConstantsTest, GEPReplaceWithConstant) { … }
TEST(ConstantsTest, AliasCAPI) { … }
static std::string getNameOfType(Type *T) { … }
TEST(ConstantsTest, BuildConstantDataArrays) { … }
TEST(ConstantsTest, BuildConstantDataVectors) { … }
TEST(ConstantsTest, BitcastToGEP) { … }
bool foldFuncPtrAndConstToNull(LLVMContext &Context, Module *TheModule,
uint64_t AndValue,
MaybeAlign FunctionAlign = std::nullopt) { … }
TEST(ConstantsTest, FoldFunctionPtrAlignUnknownAnd2) { … }
TEST(ConstantsTest, DontFoldFunctionPtrAlignUnknownAnd4) { … }
TEST(ConstantsTest, FoldFunctionPtrAlign4) { … }
TEST(ConstantsTest, DontFoldFunctionPtrAlign1) { … }
TEST(ConstantsTest, FoldFunctionAlign4PtrAlignMultiple) { … }
TEST(ConstantsTest, DontFoldFunctionAlign4PtrAlignIndependent) { … }
TEST(ConstantsTest, DontFoldFunctionPtrIfNoModule) { … }
TEST(ConstantsTest, FoldGlobalVariablePtr) { … }
TEST(ConstantsTest, containsUndefElemTest) { … }
TEST(ConstantsTest, isElementWiseEqual) { … }
TEST(ConstantsTest, CheckElementWiseUndefPoison) { … }
TEST(ConstantsTest, GetSplatValueRoundTrip) { … }
TEST(ConstantsTest, ComdatUserTracking) { … }
TEST(ConstantsTest, BlockAddressCAPITest) { … }
}
}