diff options
| author | 2020-08-03 15:06:44 +0000 | |
|---|---|---|
| committer | 2020-08-03 15:06:44 +0000 | |
| commit | b64793999546ed8adebaeebd9d8345d18db8927d (patch) | |
| tree | 4357c27b561d73b0e089727c6ed659f2ceff5f47 /gnu/llvm/unittests/IR/FunctionTest.cpp | |
| parent | Add support for UTF-8 DISPLAY-HINTs with octet length. For now only (diff) | |
| download | wireguard-openbsd-b64793999546ed8adebaeebd9d8345d18db8927d.tar.xz wireguard-openbsd-b64793999546ed8adebaeebd9d8345d18db8927d.zip | |
Remove LLVM 8.0.1 files.
Diffstat (limited to 'gnu/llvm/unittests/IR/FunctionTest.cpp')
| -rw-r--r-- | gnu/llvm/unittests/IR/FunctionTest.cpp | 133 |
1 files changed, 0 insertions, 133 deletions
diff --git a/gnu/llvm/unittests/IR/FunctionTest.cpp b/gnu/llvm/unittests/IR/FunctionTest.cpp deleted file mode 100644 index 6838d7e2527..00000000000 --- a/gnu/llvm/unittests/IR/FunctionTest.cpp +++ /dev/null @@ -1,133 +0,0 @@ -//===- FunctionTest.cpp - Function unit tests -----------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm/IR/Function.h" -#include "llvm/IR/Module.h" -#include "gtest/gtest.h" -using namespace llvm; - -namespace { - -TEST(FunctionTest, hasLazyArguments) { - LLVMContext C; - - Type *ArgTypes[] = {Type::getInt8Ty(C), Type::getInt32Ty(C)}; - FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), ArgTypes, false); - - // Functions start out with lazy arguments. - std::unique_ptr<Function> F( - Function::Create(FTy, GlobalValue::ExternalLinkage, "F")); - EXPECT_TRUE(F->hasLazyArguments()); - - // Checking for empty or size shouldn't force arguments to be instantiated. - EXPECT_FALSE(F->arg_empty()); - EXPECT_TRUE(F->hasLazyArguments()); - EXPECT_EQ(2u, F->arg_size()); - EXPECT_TRUE(F->hasLazyArguments()); - - // The argument list should be populated at first access. - (void)F->arg_begin(); - EXPECT_FALSE(F->hasLazyArguments()); -} - -TEST(FunctionTest, stealArgumentListFrom) { - LLVMContext C; - - Type *ArgTypes[] = {Type::getInt8Ty(C), Type::getInt32Ty(C)}; - FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), ArgTypes, false); - std::unique_ptr<Function> F1( - Function::Create(FTy, GlobalValue::ExternalLinkage, "F1")); - std::unique_ptr<Function> F2( - Function::Create(FTy, GlobalValue::ExternalLinkage, "F1")); - EXPECT_TRUE(F1->hasLazyArguments()); - EXPECT_TRUE(F2->hasLazyArguments()); - - // Steal arguments before they've been accessed. Nothing should change; both - // functions should still have lazy arguments. - // - // steal(empty); drop (empty) - F1->stealArgumentListFrom(*F2); - EXPECT_TRUE(F1->hasLazyArguments()); - EXPECT_TRUE(F2->hasLazyArguments()); - - // Save arguments from F1 for later assertions. F1 won't have lazy arguments - // anymore. - SmallVector<Argument *, 4> Args; - for (Argument &A : F1->args()) - Args.push_back(&A); - EXPECT_EQ(2u, Args.size()); - EXPECT_FALSE(F1->hasLazyArguments()); - - // Steal arguments from F1 to F2. F1's arguments should be lazy again. - // - // steal(real); drop (empty) - F2->stealArgumentListFrom(*F1); - EXPECT_TRUE(F1->hasLazyArguments()); - EXPECT_FALSE(F2->hasLazyArguments()); - unsigned I = 0; - for (Argument &A : F2->args()) { - EXPECT_EQ(Args[I], &A); - I++; - } - EXPECT_EQ(2u, I); - - // Check that arguments in F1 don't have pointer equality with the saved ones. - // This also instantiates F1's arguments. - I = 0; - for (Argument &A : F1->args()) { - EXPECT_NE(Args[I], &A); - I++; - } - EXPECT_EQ(2u, I); - EXPECT_FALSE(F1->hasLazyArguments()); - EXPECT_FALSE(F2->hasLazyArguments()); - - // Steal back from F2. F2's arguments should be lazy again. - // - // steal(real); drop (real) - F1->stealArgumentListFrom(*F2); - EXPECT_FALSE(F1->hasLazyArguments()); - EXPECT_TRUE(F2->hasLazyArguments()); - I = 0; - for (Argument &A : F1->args()) { - EXPECT_EQ(Args[I], &A); - I++; - } - EXPECT_EQ(2u, I); - - // Steal from F2 a second time. Now both functions should have lazy - // arguments. - // - // steal(empty); drop (real) - F1->stealArgumentListFrom(*F2); - EXPECT_TRUE(F1->hasLazyArguments()); - EXPECT_TRUE(F2->hasLazyArguments()); -} - -// Test setting and removing section information -TEST(FunctionTest, setSection) { - LLVMContext C; - Module M("test", C); - - llvm::Function *F = - Function::Create(llvm::FunctionType::get(llvm::Type::getVoidTy(C), false), - llvm::GlobalValue::ExternalLinkage, "F", &M); - - F->setSection(".text.test"); - EXPECT_TRUE(F->getSection() == ".text.test"); - EXPECT_TRUE(F->hasSection()); - F->setSection(""); - EXPECT_FALSE(F->hasSection()); - F->setSection(".text.test"); - F->setSection(".text.test2"); - EXPECT_TRUE(F->getSection() == ".text.test2"); - EXPECT_TRUE(F->hasSection()); -} - -} // end namespace |
