diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp
index 5dff50d362f68388ed00828eecefcc3e13c9a061..da77c9bb6f98a668d466f6c1c532710756ec0b6c 100644 (file)
--- a/lib/IR/DebugInfo.cpp
+++ b/lib/IR/DebugInfo.cpp
return getElement(getNumElements()-1);
}
+DIExpression::iterator DIExpression::begin() const {
+ return DIExpression::iterator(*this);
+}
+
+DIExpression::iterator DIExpression::end() const {
+ return DIExpression::iterator();
+}
+
//===----------------------------------------------------------------------===//
// Predicates
//===----------------------------------------------------------------------===//
Scope = D.isLexicalBlockFile()
? D.getScope()
: DebugLoc::getFromDILexicalBlock(Scope).getScope();
- assert(Scope && "lexical block file has no scope");
+ if (!Scope)
+ return false;
}
if (!DISubprogram(Scope).describes(F))
return false;
if (!DbgNode)
return true;
- unsigned N = getNumElements();
- for (unsigned I = 0; I < N; ++I)
- switch (getElement(I)) {
+ if (!(isExpression() && DbgNode->getNumOperands() == 1))
+ return false;
+
+ for (auto E = end(), I = begin(); I != E; ++I)
+ switch (*I) {
case DW_OP_piece:
- // DW_OP_piece has to be the last element in the expression and take two
- // arguments.
- if (getElement(I) == DW_OP_piece && !isVariablePiece())
- return false;
- I += 2;
- break;
+ // Must be the last element of the expression.
+ return std::distance(I.getBase(), DIHeaderFieldIterator()) == 3;
case DW_OP_plus:
- // Takes one argument.
- if (I+1 == N)
+ if (std::distance(I.getBase(), DIHeaderFieldIterator()) < 2)
return false;
- I += 1;
break;
- default: break;
- }
- return isExpression() && DbgNode->getNumOperands() == 1;
+ case DW_OP_deref:
+ break;
+ default:
+ // Other operators are not yet supported by the backend.
+ return false;
+ }
+ return true;
}
bool DILocation::Verify() const {