diff options
| author | Keno Fischer <keno@alumni.harvard.edu> | 2017-02-15 21:42:42 +0000 |
|---|---|---|
| committer | Keno Fischer <keno@alumni.harvard.edu> | 2017-02-15 21:42:42 +0000 |
| commit | 5e1e59180e7b9ac478208bacdaa129a5fa539a4f (patch) | |
| tree | 959b7b9e4d29f1647ad25d444b4f4635a4309f07 /llvm/unittests/IR | |
| parent | 845ea963aaf40e59e5e7e09393c2cb32898dace1 (diff) | |
| download | bcm5719-llvm-5e1e59180e7b9ac478208bacdaa129a5fa539a4f.tar.gz bcm5719-llvm-5e1e59180e7b9ac478208bacdaa129a5fa539a4f.zip | |
[GlobalObject] Fix setSection("")
Summary:
In rL291613, the section name was interned in LLVMContext. However,
this broke the ability to remove the section from a GlobalObject,
because it tried to intern empty strings, which is not allowed.
Fix that and add an appropriate regression test.
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D29795
llvm-svn: 295238
Diffstat (limited to 'llvm/unittests/IR')
| -rw-r--r-- | llvm/unittests/IR/FunctionTest.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/unittests/IR/FunctionTest.cpp b/llvm/unittests/IR/FunctionTest.cpp index fb458597c37..6838d7e2527 100644 --- a/llvm/unittests/IR/FunctionTest.cpp +++ b/llvm/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 |

