[llvm] r226774 - DIBuilder: Extract header_begin() and header_end(), NFC

Duncan P. N. Exon Smith dexonsmith at apple.com
Wed Jan 21 19:17:43 PST 2015


Author: dexonsmith
Date: Wed Jan 21 21:17:43 2015
New Revision: 226774

URL: http://llvm.org/viewvc/llvm-project?rev=226774&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/IR/DebugInfo.h

Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=226774&r1=226773&r2=226774&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Wed Jan 21 21:17:43 2015
@@ -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();





More information about the llvm-commits mailing list