DIBuilder: Create a getHeaderIterator() helper, NFC
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 22 Jan 2015 03:00:01 +0000 (03:00 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 22 Jan 2015 03:00:01 +0000 (03:00 +0000)
Extract this so it can be reused.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226770 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/DebugInfo.h

index 459e15761930e9822be32ed7cf68a95284755947..13fa23c8fd6ce3732f5b2a99da7d6dacfec4ea1a 100644 (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))