summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/VMCore
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-08-04 09:47:02 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-08-04 09:47:02 +0000
commit3849fcbe0e809e3f060aea7a94083a207061d88c (patch)
tree722ffc0f6aef91519d09cadd55c999c1b2c8a234 /llvm/unittests/VMCore
parentaa63610b098243617fb88e0fa9b89e34cb104915 (diff)
downloadbcm5719-llvm-3849fcbe0e809e3f060aea7a94083a207061d88c.tar.gz
bcm5719-llvm-3849fcbe0e809e3f060aea7a94083a207061d88c.zip
Postpone the deletion of the old name in StructType::setName to allow using a slice of the old name.
Fixes PR13522. Add a rudimentary unit test to exercise the behavior. llvm-svn: 161296
Diffstat (limited to 'llvm/unittests/VMCore')
-rw-r--r--llvm/unittests/VMCore/TypesTest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/unittests/VMCore/TypesTest.cpp b/llvm/unittests/VMCore/TypesTest.cpp
new file mode 100644
index 00000000000..0416643221e
--- /dev/null
+++ b/llvm/unittests/VMCore/TypesTest.cpp
@@ -0,0 +1,30 @@
+//===- llvm/unittest/VMCore/TypesTest.cpp - Type 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/DerivedTypes.h"
+#include "llvm/LLVMContext.h"
+#include "gtest/gtest.h"
+using namespace llvm;
+
+namespace {
+
+TEST(TypesTest, StructType) {
+ LLVMContext C;
+
+ // PR13522
+ StructType *Struct = StructType::create(C, "FooBar");
+ EXPECT_EQ("FooBar", Struct->getName());
+ Struct->setName(Struct->getName().substr(0, 3));
+ EXPECT_EQ("Foo", Struct->getName());
+ Struct->setName("");
+ EXPECT_TRUE(Struct->getName().empty());
+ EXPECT_FALSE(Struct->hasName());
+}
+
+} // end anonymous namespace
OpenPOWER on IntegriCloud