summaryrefslogtreecommitdiff
path: root/unittests/IR/ConstantsTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/IR/ConstantsTest.cpp')
-rw-r--r--unittests/IR/ConstantsTest.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/unittests/IR/ConstantsTest.cpp b/unittests/IR/ConstantsTest.cpp
index 59c9652e2e..b225ba923b 100644
--- a/unittests/IR/ConstantsTest.cpp
+++ b/unittests/IR/ConstantsTest.cpp
@@ -268,6 +268,18 @@ TEST(ConstantsTest, ReplaceWithConstantTest) {
EXPECT_DEATH(Global->replaceAllUsesWith(GEP),
"this->replaceAllUsesWith\\(expr\\(this\\)\\) is NOT valid!");
}
+
+TEST(ConstantsTest, ReplaceInAliasTest) {
+ std::unique_ptr<Module> M(new Module("MyModule", getGlobalContext()));
+
+ Type *Int32Ty = Type::getInt32Ty(getGlobalContext());
+ auto *Global = cast<GlobalObject>(M->getOrInsertGlobal("dummy", Int32Ty));
+ auto *GA = new GlobalAlias(Int32Ty, GlobalValue::ExternalLinkage, "alias",
+ Global, M.get());
+ EXPECT_DEATH(Global->replaceAllUsesWith(GA),
+ "replaceAliasUseWith cannot form an alias cycle");
+}
+
#endif
#endif