diff options
author | Jeffrey Yasskin <jyasskin@google.com> | 2009-09-09 05:04:01 +0000 |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@google.com> | 2009-09-09 05:04:01 +0000 |
commit | 4a38930a4595d94b1f379d6955c531c48e5c2aa0 (patch) | |
tree | c8225ef9578297ee6afe1a1f170aef18e222384c /unittests | |
parent | 6be47fba53d3650ff9c1e4b7f8aea0e642186fc4 (diff) | |
download | external_llvm-4a38930a4595d94b1f379d6955c531c48e5c2aa0.zip external_llvm-4a38930a4595d94b1f379d6955c531c48e5c2aa0.tar.gz external_llvm-4a38930a4595d94b1f379d6955c531c48e5c2aa0.tar.bz2 |
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
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/Support/TypeBuilderTest.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
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<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; |