[llvm] r232442 - AsmWriter: Assert on unresolved metadata nodes

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Mar 16 17:16:35 PDT 2015

Author: dexonsmith
Date: Mon Mar 16 19:16:35 2015
New Revision: 232442

URL: http://llvm.org/viewvc/llvm-project?rev=232442&view=rev
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.


Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=232442&r1=232441&r2=232442&view=diff
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Mon Mar 16 19:16:35 2015
@@ -1205,6 +1205,8 @@ static void WriteModuleMetadata(const Mo
   SmallVector<uint64_t, 64> Record;
   for (const Metadata *MD : MDs) {
     if (const MDNode *N = dyn_cast<MDNode>(MD)) {
+      assert(N->isResolved() && "Expected forward references to be resolved");
       switch (N->getMetadataID()) {
         llvm_unreachable("Invalid MDNode subclass");

More information about the llvm-commits mailing list