summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/IR/VerifierTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/IR/VerifierTest.cpp')
-rw-r--r--llvm/unittests/IR/VerifierTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/unittests/IR/VerifierTest.cpp b/llvm/unittests/IR/VerifierTest.cpp
index 8b951739e47..1fc50da16a9 100644
--- a/llvm/unittests/IR/VerifierTest.cpp
+++ b/llvm/unittests/IR/VerifierTest.cpp
@@ -144,5 +144,30 @@ TEST(VerifierTest, CrossModuleMetadataRef) {
EXPECT_TRUE(StringRef(ErrorOS.str())
.startswith("Referencing global in another module!"));
}
+
+TEST(VerifierTest, StripInvalidDebugInfo) {
+ LLVMContext C;
+ Module M("M", C);
+ DIBuilder DIB(M);
+ DIB.createCompileUnit(dwarf::DW_LANG_C89, "broken.c", "/",
+ "unittest", false, "", 0);
+ DIB.finalize();
+ EXPECT_FALSE(verifyModule(M));
+
+ // Now break it.
+ auto *File = DIB.createFile("not-a-CU.f", ".");
+ NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
+ NMD->addOperand(File);
+ EXPECT_TRUE(verifyModule(M));
+
+ ModulePassManager MPM(true);
+ MPM.addPass(VerifierPass(false));
+ ModuleAnalysisManager MAM(true);
+ MAM.registerPass([&] { return VerifierAnalysis(); });
+ MPM.run(M, MAM);
+ EXPECT_FALSE(verifyModule(M));
+}
+
+
} // end anonymous namespace
} // end namespace llvm
OpenPOWER on IntegriCloud