bool DISubprogram::Verify() const { auto *N = getRaw(); if (!N) return false; if (!isScopeRef(N->getScope())) return false; if (auto *Op = N->getType()) if (!isa<MDNode>(Op)) return false; if (!isTypeRef(getContainingType())) return false; if (isLValueReference() && isRValueReference()) return false; // If a DISubprogram has an llvm::Function*, then scope chains from all // instructions within the function should lead to this DISubprogram. if (auto *F = getFunction()) { for (auto &BB : *F) { for (auto &I : BB) { DebugLoc DL = I.getDebugLoc(); if (DL.isUnknown()) continue; MDNode *Scope = nullptr; MDNode *IA = nullptr; // walk the inlined-at scopes while ((IA = DL.getInlinedAt())) DL = DebugLoc::getFromDILocation(IA); DL.getScopeAndInlinedAt(Scope, IA); if (!Scope) return false; assert(!IA); while (!DIDescriptor(Scope).isSubprogram()) { DILexicalBlockFile D(Scope); Scope = D.isLexicalBlockFile() ? D.getScope() : DebugLoc::getFromDILexicalBlock(Scope).getScope(); if (!Scope) return false; } if (!DISubprogram(Scope).describes(F)) return false; } } } return true; }
bool DISubprogram::Verify() const { if (!isSubprogram()) return false; // Make sure context @ field 2 is a ScopeRef and type @ field 3 is a MDNode. if (!fieldIsScopeRef(DbgNode, 2)) return false; if (!fieldIsMDNode(DbgNode, 3)) return false; // Containing type @ field 4. if (!fieldIsTypeRef(DbgNode, 4)) return false; // A subprogram can't be both & and &&. if (isLValueReference() && isRValueReference()) return false; // If a DISubprogram has an llvm::Function*, then scope chains from all // instructions within the function should lead to this DISubprogram. if (auto *F = getFunction()) { for (auto &BB : *F) { for (auto &I : BB) { DebugLoc DL = I.getDebugLoc(); if (DL.isUnknown()) continue; MDNode *Scope = nullptr; MDNode *IA = nullptr; // walk the inlined-at scopes while ((IA = DL.getInlinedAt())) DL = DebugLoc::getFromDILocation(IA); DL.getScopeAndInlinedAt(Scope, IA); if (!Scope) return false; assert(!IA); while (!DIDescriptor(Scope).isSubprogram()) { DILexicalBlockFile D(Scope); Scope = D.isLexicalBlockFile() ? D.getScope() : DebugLoc::getFromDILexicalBlock(Scope).getScope(); if (!Scope) return false; } if (!DISubprogram(Scope).describes(F)) return false; } } } return DbgNode->getNumOperands() == 9 && getNumHeaderFields() == 12; }