From 3f0a9af13bec64f3bc4bee06a57e18feeb766570 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 25 Feb 2014 22:23:04 +0000 Subject: 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 and the DataLayout itself could be immutable. Thanks to Philip Reames for pushing me in the right direction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202198 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/IR/IRBuilderTest.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'unittests') diff --git a/unittests/IR/IRBuilderTest.cpp b/unittests/IR/IRBuilderTest.cpp index a0a72e82ed..e6db8c66df 100644 --- a/unittests/IR/IRBuilderTest.cpp +++ b/unittests/IR/IRBuilderTest.cpp @@ -108,6 +108,14 @@ TEST_F(IRBuilderTest, LandingPadName) { EXPECT_EQ(LP->getName(), "LP"); } +TEST_F(IRBuilderTest, DataLayout) { + OwningPtr 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(); -- cgit v1.2.3