aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/IR/IRBuilderTest.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-02-25 22:23:04 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-02-25 22:23:04 +0000
commit248ac139752aa61eab97ce6b80bb4160da4bd5fa (patch)
tree4be9e42f9ec4c10ca79f375fefff618ffdd97877 /llvm/unittests/IR/IRBuilderTest.cpp
parentafc9eb33fd9c0708ada37a285b635b4f492eaaca (diff)
downloadllvm-248ac139752aa61eab97ce6b80bb4160da4bd5fa.zip
llvm-248ac139752aa61eab97ce6b80bb4160da4bd5fa.tar.gz
llvm-248ac139752aa61eab97ce6b80bb4160da4bd5fa.tar.bz2
Fix resetting the DataLayout in a Module.
No tool does this currently, but as everything else in a module we should be able to change its DataLayout. Most of the fix is in DataLayout to make sure it can be reset properly. The test uses Module::setDataLayout since the fact that we mutate a DataLayout is an implementation detail. The module could hold a OwningPtr<DataLayout> and the DataLayout itself could be immutable. Thanks to Philip Reames for pushing me in the right direction. llvm-svn: 202198
Diffstat (limited to 'llvm/unittests/IR/IRBuilderTest.cpp')
-rw-r--r--llvm/unittests/IR/IRBuilderTest.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/unittests/IR/IRBuilderTest.cpp b/llvm/unittests/IR/IRBuilderTest.cpp
index a0a72e8..e6db8c6 100644
--- a/llvm/unittests/IR/IRBuilderTest.cpp
+++ b/llvm/unittests/IR/IRBuilderTest.cpp
@@ -108,6 +108,14 @@ TEST_F(IRBuilderTest, LandingPadName) {
EXPECT_EQ(LP->getName(), "LP");
}
+TEST_F(IRBuilderTest, DataLayout) {
+ OwningPtr<Module> M(new Module("test", Ctx));
+ M->setDataLayout("e-n32");
+ EXPECT_TRUE(M->getDataLayout()->isLegalInteger(32));
+ M->setDataLayout("e");
+ EXPECT_FALSE(M->getDataLayout()->isLegalInteger(32));
+}
+
TEST_F(IRBuilderTest, GetIntTy) {
IRBuilder<> Builder(BB);
IntegerType *Ty1 = Builder.getInt1Ty();