From: Adrian Prantl Date: Mon, 13 Oct 2014 20:44:58 +0000 (+0000) Subject: Add an assertion about the integrity of the iterator. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=049d21caea4cb66bfda771fa8f4e21b88dfd1364;p=platform%2Fupstream%2Fllvm.git Add an assertion about the integrity of the iterator. Broken parent scope pointers in inlined DIVariables can cause ensureAbstractVariableIsCreated to insert new abstract scopes, thus invalidating the iterator in this loop and leading to hard-to-debug crashes. Useful when manually reducing IR for testcases. llvm-svn: 219628 --- diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 491681a..6e64188 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1365,6 +1365,9 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { return; } +#ifndef NDEBUG + size_t NumAbstractScopes = LScopes.getAbstractScopesList().size(); +#endif // Construct abstract scopes. for (LexicalScope *AScope : LScopes.getAbstractScopesList()) { DISubprogram SP(AScope->getScopeNode()); @@ -1377,6 +1380,8 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { if (!ProcessedVars.insert(DV)) continue; ensureAbstractVariableIsCreated(DV, DV.getContext()); + assert(LScopes.getAbstractScopesList().size() == NumAbstractScopes + && "ensureAbstractVariableIsCreated inserted abstract scopes"); } constructAbstractSubprogramScopeDIE(AScope); }