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 | ccbeaf5f94bbf0d7e270e61962bcdb3b8edda835 (patch) | |
tree | b75796c2b74154756318f51b9a737e4d0d74397f /llvm/unittests/Support | |
parent | 71d1d92d3728302dcd64a657bcded445eb3d9b77 (diff) | |
download | bcm5719-llvm-ccbeaf5f94bbf0d7e270e61962bcdb3b8edda835.tar.gz bcm5719-llvm-ccbeaf5f94bbf0d7e270e61962bcdb3b8edda835.zip |
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.
llvm-svn: 81316
Diffstat (limited to 'llvm/unittests/Support')
-rw-r--r-- | llvm/unittests/Support/TypeBuilderTest.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/unittests/Support/TypeBuilderTest.cpp b/llvm/unittests/Support/TypeBuilderTest.cpp index bd9f5d64a2c..fae8907cda6 100644 --- a/llvm/unittests/Support/TypeBuilderTest.cpp +++ b/llvm/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; |