DIBuilder: Create a getHeaderIterator() helper, NFC

Extract this so it can be reused.

llvm-svn: 226770
This commit is contained in:
Duncan P. N. Exon Smith 2015-01-22 03:00:01 +00:00
parent 42fb49cc52
commit 2e4db3d00c
1 changed files with 6 additions and 2 deletions

View File

@ -190,15 +190,19 @@ public:
DIHeaderFieldIterator());
}
StringRef getHeaderField(unsigned Index) const {
DIHeaderFieldIterator getHeaderIterator(unsigned Index) const {
// Since callers expect an empty string for out-of-range accesses, we can't
// use std::advance() here.
for (DIHeaderFieldIterator I(getHeader()), E; I != E; ++I, --Index)
if (!Index)
return *I;
return I;
return StringRef();
}
StringRef getHeaderField(unsigned Index) const {
return *getHeaderIterator(Index);
}
template <class T> T getHeaderFieldAs(unsigned Index) const {
T Int;
if (getHeaderField(Index).getAsInteger(0, Int))