DIBuilder: Extract header_begin() and header_end(), NFC

Use begin/end functions so that users don't need to know how these weird
things work.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226774 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2015-01-22 03:17:43 +00:00
parent cc19b2fb2e
commit db5a7969ce

View File

@ -200,13 +200,16 @@ public:
DIHeaderFieldIterator()); DIHeaderFieldIterator());
} }
DIHeaderFieldIterator header_begin() const { return getHeader(); }
DIHeaderFieldIterator header_end() const { return StringRef(); }
DIHeaderFieldIterator getHeaderIterator(unsigned Index) const { DIHeaderFieldIterator getHeaderIterator(unsigned Index) const {
// Since callers expect an empty string for out-of-range accesses, we can't // Since callers expect an empty string for out-of-range accesses, we can't
// use std::advance() here. // use std::advance() here.
for (DIHeaderFieldIterator I(getHeader()), E; I != E; ++I, --Index) for (auto I = header_begin(), E = header_end(); I != E; ++I, --Index)
if (!Index) if (!Index)
return I; return I;
return StringRef(); return header_end();
} }
StringRef getHeaderField(unsigned Index) const { StringRef getHeaderField(unsigned Index) const {
@ -888,8 +891,7 @@ class DIExpressionIterator
DIExpressionIterator(DIHeaderFieldIterator I) : I(I) {} DIExpressionIterator(DIHeaderFieldIterator I) : I(I) {}
public: public:
DIExpressionIterator() {} DIExpressionIterator() {}
DIExpressionIterator(const DIExpression Expr) DIExpressionIterator(const DIExpression &Expr) : I(++Expr.header_begin()) {}
: I(Expr.getHeader()) { ++I; }
uint64_t operator*() const { return I.getNumber<uint64_t>(); } uint64_t operator*() const { return I.getNumber<uint64_t>(); }
DIExpressionIterator &operator++() { DIExpressionIterator &operator++() {
increment(); increment();