From 79f8d11d5af9d75154177352dbb03993246bf191 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Tue, 17 Mar 2015 00:16:35 +0000 Subject: AsmWriter: Assert on unresolved metadata nodes Assert that `MDNode::isResolved()`. While in theory the `Verifier` should catch this, it doesn't descend into all debug info, and the `DebugInfoVerifier` doesn't call into the `Verifier`. Besides, this helps to catch bugs when `-disable-verify=true`. Note that I haven't come across a place where this fails with clang today, so no testcase. llvm-svn: 232442 --- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp') diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index d2417acc689b..0123fb263fc6 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -1205,6 +1205,8 @@ static void WriteModuleMetadata(const Module *M, SmallVector Record; for (const Metadata *MD : MDs) { if (const MDNode *N = dyn_cast(MD)) { + assert(N->isResolved() && "Expected forward references to be resolved"); + switch (N->getMetadataID()) { default: llvm_unreachable("Invalid MDNode subclass"); -- cgit v1.2.3