diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-05-13 01:23:21 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-05-13 01:23:21 +0000 |
commit | e2b37447b715b1eaa507de117fcb18beea6a4601 (patch) | |
tree | 766fd323916778752ac2837f3bbbbf606fafd7cf /unittests | |
parent | 0449d522a66512af6e7b999d46445c7f7e4b8536 (diff) | |
download | llvm-e2b37447b715b1eaa507de117fcb18beea6a4601.tar.gz llvm-e2b37447b715b1eaa507de117fcb18beea6a4601.tar.bz2 llvm-e2b37447b715b1eaa507de117fcb18beea6a4601.tar.xz |
Assert that we don't RAUW a Constant with a ConstantExpr that contains it.
We already had an assert for foo->RAUW(foo), but not for something like
foo->RAUW(GEP(foo)) and would go in an infinite loop trying to apply
the replacement.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208663 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/IR/ConstantsTest.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/unittests/IR/ConstantsTest.cpp b/unittests/IR/ConstantsTest.cpp index b3aa8102b6..59c9652e2e 100644 --- a/unittests/IR/ConstantsTest.cpp +++ b/unittests/IR/ConstantsTest.cpp @@ -254,6 +254,23 @@ TEST(ConstantsTest, AsInstructionsTest) { P6STR ", i32 1"); } +#ifdef GTEST_HAS_DEATH_TEST +#ifndef NDEBUG +TEST(ConstantsTest, ReplaceWithConstantTest) { + std::unique_ptr<Module> M(new Module("MyModule", getGlobalContext())); + + Type *Int32Ty = Type::getInt32Ty(getGlobalContext()); + Constant *One = ConstantInt::get(Int32Ty, 1); + + Constant *Global = + M->getOrInsertGlobal("dummy", PointerType::getUnqual(Int32Ty)); + Constant *GEP = ConstantExpr::getGetElementPtr(Global, One); + EXPECT_DEATH(Global->replaceAllUsesWith(GEP), + "this->replaceAllUsesWith\\(expr\\(this\\)\\) is NOT valid!"); +} +#endif +#endif + #undef CHECK } // end anonymous namespace |