From 4a38930a4595d94b1f379d6955c531c48e5c2aa0 Mon Sep 17 00:00:00 2001 From: Jeffrey Yasskin Date: Wed, 9 Sep 2009 05:04:01 +0000 Subject: 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/trunk@81316 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/Support/TypeBuilderTest.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'unittests') diff --git a/unittests/Support/TypeBuilderTest.cpp b/unittests/Support/TypeBuilderTest.cpp index bd9f5d6..fae8907 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, true>::get(context1))->getContext()); + LLVMContext context2; + EXPECT_EQ(&context2, + &(TypeBuilder, true>::get(context2))->getContext()); +} + class MyType { int a; int *b; -- cgit v1.1