aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/IR/VerifierTest.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2016-05-11 13:23:52 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2016-05-11 13:23:52 +0000
commitcc8900f66c3a4329b5038fad3324fa438ffae041 (patch)
tree66c126f089761ee2dea15b9f8378e16d6869dd08 /llvm/unittests/IR/VerifierTest.cpp
parent477eb42f854aaed920abae58f9dd4a9e7d66aad8 (diff)
downloadllvm-cc8900f66c3a4329b5038fad3324fa438ffae041.zip
llvm-cc8900f66c3a4329b5038fad3324fa438ffae041.tar.gz
llvm-cc8900f66c3a4329b5038fad3324fa438ffae041.tar.bz2
Delete duplicated verifier test.
Also add unittest to show we still detect the errors. llvm-svn: 269182
Diffstat (limited to 'llvm/unittests/IR/VerifierTest.cpp')
-rw-r--r--llvm/unittests/IR/VerifierTest.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/unittests/IR/VerifierTest.cpp b/llvm/unittests/IR/VerifierTest.cpp
index 8f28382..85148af 100644
--- a/llvm/unittests/IR/VerifierTest.cpp
+++ b/llvm/unittests/IR/VerifierTest.cpp
@@ -145,6 +145,33 @@ TEST(VerifierTest, CrossModuleMetadataRef) {
.startswith("Referencing global in another module!"));
}
+TEST(VerifierTest, InvalidVariableLinkage) {
+ LLVMContext C;
+ Module M("M", C);
+ new GlobalVariable(M, Type::getInt8Ty(C), false,
+ GlobalValue::LinkOnceODRLinkage, nullptr, "Some Global");
+ std::string Error;
+ raw_string_ostream ErrorOS(Error);
+ EXPECT_TRUE(verifyModule(M, &ErrorOS));
+ EXPECT_TRUE(
+ StringRef(ErrorOS.str()).startswith("Global is external, but doesn't "
+ "have external or weak linkage!"));
+}
+
+TEST(VerifierTest, InvalidFunctionLinkage) {
+ LLVMContext C;
+ Module M("M", C);
+
+ FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), /*isVarArg=*/false);
+ Function::Create(FTy, GlobalValue::LinkOnceODRLinkage, "foo", &M);
+ std::string Error;
+ raw_string_ostream ErrorOS(Error);
+ EXPECT_TRUE(verifyModule(M, &ErrorOS));
+ EXPECT_TRUE(
+ StringRef(ErrorOS.str()).startswith("Global is external, but doesn't "
+ "have external or weak linkage!"));
+}
+
#ifndef _MSC_VER
// FIXME: This test causes an ICE in MSVC 2013.
TEST(VerifierTest, StripInvalidDebugInfo) {