aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/IR/VerifierTest.cpp
diff options
context:
space:
mode:
authorKeno Fischer <kfischer@college.harvard.edu>2016-01-14 22:20:56 +0000
committerKeno Fischer <kfischer@college.harvard.edu>2016-01-14 22:20:56 +0000
commit60f82a269f975c7cd45b1dfd2721b28db75e905e (patch)
tree8bb1933b8a60930c39a9fd4c181a5d1734009317 /llvm/unittests/IR/VerifierTest.cpp
parent565b30138032d23efb95887dfc2a49ceac4f2d9c (diff)
downloadllvm-60f82a269f975c7cd45b1dfd2721b28db75e905e.zip
llvm-60f82a269f975c7cd45b1dfd2721b28db75e905e.tar.gz
llvm-60f82a269f975c7cd45b1dfd2721b28db75e905e.tar.bz2
[Verifier] Verify that a GlobalValue is only used in this Module
Summary: We already have the inverse verification that we only use globals that are defined in this module. This essentially catches the same mistake, but when verifying the module that contains the definition. Reviewers: rafael Differential Revision: http://reviews.llvm.org/D15272 llvm-svn: 257823
Diffstat (limited to 'llvm/unittests/IR/VerifierTest.cpp')
-rw-r--r--llvm/unittests/IR/VerifierTest.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/llvm/unittests/IR/VerifierTest.cpp b/llvm/unittests/IR/VerifierTest.cpp
index 4e94b43..7ae346d 100644
--- a/llvm/unittests/IR/VerifierTest.cpp
+++ b/llvm/unittests/IR/VerifierTest.cpp
@@ -64,7 +64,7 @@ TEST(VerifierTest, CrossModuleRef) {
LLVMContext &C = getGlobalContext();
Module M1("M1", C);
Module M2("M2", C);
- Module M3("M2", C);
+ Module M3("M3", C);
FunctionType *FTy = FunctionType::get(Type::getInt32Ty(C), /*isVarArg=*/false);
Function *F1 = cast<Function>(M1.getOrInsertFunction("foo1", FTy));
Function *F2 = cast<Function>(M2.getOrInsertFunction("foo2", FTy));
@@ -86,7 +86,21 @@ TEST(VerifierTest, CrossModuleRef) {
std::string Error;
raw_string_ostream ErrorOS(Error);
- EXPECT_FALSE(verifyModule(M2, &ErrorOS));
+ EXPECT_TRUE(verifyModule(M2, &ErrorOS));
+ EXPECT_TRUE(StringRef(ErrorOS.str())
+ .equals("Global is used by function in a different module\n"
+ "i32 ()* @foo2\n"
+ "; ModuleID = 'M2'\n"
+ "i32 ()* @foo3\n"
+ "; ModuleID = 'M3'\n"
+ "Global is referenced in a different module!\n"
+ "i32 ()* @foo2\n"
+ "; ModuleID = 'M2'\n"
+ " %call = call i32 @foo2()\n"
+ "i32 ()* @foo1\n"
+ "; ModuleID = 'M1'\n"));
+
+ Error.clear();
EXPECT_TRUE(verifyModule(M1, &ErrorOS));
EXPECT_TRUE(StringRef(ErrorOS.str()).equals(
"Referencing function in another module!\n"