aboutsummaryrefslogtreecommitdiff
path: root/unittests/IR/FunctionTest.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-04-16 16:01:22 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-04-16 16:01:22 +0000
commit71d5a2540a98c81f5bcaeb48805e0e2881f530ef (patch)
tree5343938942df402b49ec7300a1c25a2d4ccd5821 /unittests/IR/FunctionTest.cpp
parent31bbf64f3a4974a2d6c8b3b27ad2f519caf74057 (diff)
Diffstat (limited to 'unittests/IR/FunctionTest.cpp')
-rw-r--r--unittests/IR/FunctionTest.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/unittests/IR/FunctionTest.cpp b/unittests/IR/FunctionTest.cpp
index fb458597c37a..6838d7e2527f 100644
--- a/unittests/IR/FunctionTest.cpp
+++ b/unittests/IR/FunctionTest.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/IR/Function.h"
+#include "llvm/IR/Module.h"
#include "gtest/gtest.h"
using namespace llvm;
@@ -109,4 +110,24 @@ TEST(FunctionTest, stealArgumentListFrom) {
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