DIBuilder: Extract header_begin() and header_end(), NFC
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 22 Jan 2015 03:17:43 +0000 (03:17 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 22 Jan 2015 03:17:43 +0000 (03:17 +0000)
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

include/llvm/IR/DebugInfo.h

index f42a8ebd8842f5aafc70d1449eb3ce30cd276e10..68d86d72a7d1249d38ff57b9cb7bacf751fdd30c 100644 (file)
@@ -200,13 +200,16 @@ public:
                          DIHeaderFieldIterator());
   }
 
+  DIHeaderFieldIterator header_begin() const { return getHeader(); }
+  DIHeaderFieldIterator header_end() const { return StringRef(); }
+
   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)
+    for (auto I = header_begin(), E = header_end(); I != E; ++I, --Index)
       if (!Index)
         return I;
-    return StringRef();
+    return header_end();
   }
 
   StringRef getHeaderField(unsigned Index) const {
@@ -888,8 +891,7 @@ class DIExpressionIterator
   DIExpressionIterator(DIHeaderFieldIterator I) : I(I) {}
 public:
   DIExpressionIterator() {}
-  DIExpressionIterator(const DIExpression Expr)
-    : I(Expr.getHeader()) { ++I; }
+  DIExpressionIterator(const DIExpression &Expr) : I(++Expr.header_begin()) {}
   uint64_t operator*() const { return I.getNumber<uint64_t>(); }
   DIExpressionIterator &operator++() {
     increment();