aboutsummaryrefslogtreecommitdiff
path: root/unittests/Support
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2009-09-13 19:02:05 +0000
committerTanya Lattner <tonic@nondot.org>2009-09-13 19:02:05 +0000
commitbb16ea96ac99afc79ebcbc4557b7ba4f617ca066 (patch)
treedf1d103e8e417cb5ade7ec4a833043330ba5854f /unittests/Support
parentac591b8155ae4ab2a65ca78c2e79987104e85f13 (diff)
Merge 81316 from mainline.
Make TypeBuilder's result depend on the LLVMContext it's passed. TypeBuilder was using a local static variable to cache its result. This made it ignore changes in its LLVMContext argument and always return a type constructed from the argument to the first call. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_26@81694 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Support')
-rw-r--r--unittests/Support/TypeBuilderTest.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/unittests/Support/TypeBuilderTest.cpp b/unittests/Support/TypeBuilderTest.cpp
index bd9f5d64a2..fae8907cda 100644
--- a/unittests/Support/TypeBuilderTest.cpp
+++ b/unittests/Support/TypeBuilderTest.cpp
@@ -147,6 +147,18 @@ TEST(TypeBuilderTest, Functions) {
false>::get(getGlobalContext())));
}
+TEST(TypeBuilderTest, Context) {
+ // We used to cache TypeBuilder results in static local variables. This
+ // produced the same type for different contexts, which of course broke
+ // things.
+ LLVMContext context1;
+ EXPECT_EQ(&context1,
+ &(TypeBuilder<types::i<1>, true>::get(context1))->getContext());
+ LLVMContext context2;
+ EXPECT_EQ(&context2,
+ &(TypeBuilder<types::i<1>, true>::get(context2))->getContext());
+}
+
class MyType {
int a;
int *b;