<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 13, 2014 at 7:43 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Thu, Mar 13, 2014 at 12:52 AM, Alexey Samsonov <<a href="mailto:samsonov@google.com">samsonov@google.com</a>> wrote:<br>

> Author: samsonov<br>
> Date: Thu Mar 13 02:52:54 2014<br>
> New Revision: 203766<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=203766&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=203766&view=rev</a><br>
> Log:<br>
> [C++11] Convert DWARF parser to range-based for loops<br>
<br>
</div>Thanks for the cleanup!<br>
<div><div class="h5"><br>
><br>
> Modified:<br>
>     llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.cpp<br>
>     llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.h<br>
>     llvm/trunk/lib/DebugInfo/DWARFContext.cpp<br>
>     llvm/trunk/lib/DebugInfo/DWARFContext.h<br>
>     llvm/trunk/lib/DebugInfo/DWARFDebugAbbrev.cpp<br>
>     llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.cpp<br>
>     llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.h<br>
>     llvm/trunk/lib/DebugInfo/DWARFDebugAranges.cpp<br>
>     llvm/trunk/lib/DebugInfo/DWARFDebugFrame.cpp<br>
>     llvm/trunk/lib/DebugInfo/DWARFDebugFrame.h<br>
>     llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp<br>
>     llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h<br>
>     llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp<br>
>     llvm/trunk/lib/DebugInfo/DWARFDebugLoc.cpp<br>
>     llvm/trunk/lib/DebugInfo/DWARFDebugRangeList.cpp<br>
>     llvm/trunk/lib/DebugInfo/DWARFUnit.cpp<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.cpp?rev=203766&r1=203765&r2=203766&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.cpp?rev=203766&r1=203765&r2=203766&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.cpp Thu Mar 13 02:52:54 2014<br>
> @@ -18,7 +18,7 @@ void DWARFAbbreviationDeclaration::clear<br>
>    Code = 0;<br>
>    Tag = 0;<br>
>    HasChildren = false;<br>
> -  Attributes.clear();<br>
> +  AttributeSpecs.clear();<br>
>  }<br>
><br>
>  DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration() {<br>
> @@ -51,7 +51,8 @@ DWARFAbbreviationDeclaration::extract(Da<br>
>      }<br>
>      if (Attr == 0 && Form == 0)<br>
>        break;<br>
> -    Attributes.push_back(AttributeSpec(Attr, Form));<br>
> +    AttributeSpec AS = {Attr, Form};<br>
> +    AttributeSpecs.push_back(AS);<br>
<br>
</div></div>Any particular reason for the rename (Attributes->AttributeSpecs?) and<br>
reformat (creating the named local AS rather than just a temporary)?<br></blockquote><div><br></div><div>Thanks for pointing this out, I've switched this to temporary in r203914.</div><div>No particular reason for rename, it just describes what the contents of this vector is "attribute specifications",</div>
<div>and matches the struct name.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
>    }<br>
><br>
>    if (Tag == 0) {<br>
> @@ -69,19 +70,19 @@ void DWARFAbbreviationDeclaration::dump(<br>
>    else<br>
>      OS << format("DW_TAG_Unknown_%x", getTag());<br>
>    OS << "\tDW_CHILDREN_" << (hasChildren() ? "yes" : "no") << '\n';<br>
> -  for (unsigned i = 0, e = Attributes.size(); i != e; ++i) {<br>
> +  for (const AttributeSpec &Spec : AttributeSpecs) {<br>
>      OS << '\t';<br>
> -    const char *attrString = AttributeString(Attributes[i].Attr);<br>
> +    const char *attrString = AttributeString(Spec.Attr);<br>
>      if (attrString)<br>
>        OS << attrString;<br>
>      else<br>
> -      OS << format("DW_AT_Unknown_%x", Attributes[i].Attr);<br>
> +      OS << format("DW_AT_Unknown_%x", Spec.Attr);<br>
>      OS << '\t';<br>
> -    const char *formString = FormEncodingString(Attributes[i].Form);<br>
> +    const char *formString = FormEncodingString(Spec.Form);<br>
>      if (formString)<br>
>        OS << formString;<br>
>      else<br>
> -      OS << format("DW_FORM_Unknown_%x", Attributes[i].Form);<br>
> +      OS << format("DW_FORM_Unknown_%x", Spec.Form);<br>
>      OS << '\n';<br>
>    }<br>
>    OS << '\n';<br>
> @@ -89,8 +90,8 @@ void DWARFAbbreviationDeclaration::dump(<br>
><br>
>  uint32_t<br>
>  DWARFAbbreviationDeclaration::findAttributeIndex(uint16_t attr) const {<br>
> -  for (uint32_t i = 0, e = Attributes.size(); i != e; ++i) {<br>
> -    if (Attributes[i].Attr == attr)<br>
> +  for (uint32_t i = 0, e = AttributeSpecs.size(); i != e; ++i) {<br>
> +    if (AttributeSpecs[i].Attr == attr)<br>
>        return i;<br>
>    }<br>
>    return -1U;<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.h?rev=203766&r1=203765&r2=203766&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.h?rev=203766&r1=203765&r2=203766&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.h (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.h Thu Mar 13 02:52:54 2014<br>
> @@ -23,23 +23,27 @@ class DWARFAbbreviationDeclaration {<br>
>    bool HasChildren;<br>
><br>
>    struct AttributeSpec {<br>
> -    AttributeSpec(uint16_t Attr, uint16_t Form) : Attr(Attr), Form(Form) {}<br>
>      uint16_t Attr;<br>
>      uint16_t Form;<br>
>    };<br>
> -  SmallVector<AttributeSpec, 8> Attributes;<br>
> +  typedef SmallVector<AttributeSpec, 8> AttributeSpecVector;<br>
> +  AttributeSpecVector AttributeSpecs;<br>
>  public:<br>
>    DWARFAbbreviationDeclaration();<br>
><br>
>    uint32_t getCode() const { return Code; }<br>
>    uint32_t getTag() const { return Tag; }<br>
>    bool hasChildren() const { return HasChildren; }<br>
> -  uint32_t getNumAttributes() const { return Attributes.size(); }<br>
> -  uint16_t getAttrByIndex(uint32_t idx) const {<br>
> -    return idx < Attributes.size() ? Attributes[idx].Attr : 0;<br>
> +<br>
> +  typedef iterator_range<AttributeSpecVector::const_iterator><br>
> +  attr_iterator_range;<br>
> +<br>
> +  attr_iterator_range attributes() const {<br>
> +    return attr_iterator_range(AttributeSpecs.begin(), AttributeSpecs.end());<br>
>    }<br>
> +<br>
>    uint16_t getFormByIndex(uint32_t idx) const {<br>
> -    return idx < Attributes.size() ? Attributes[idx].Form : 0;<br>
> +    return idx < AttributeSpecs.size() ? AttributeSpecs[idx].Form : 0;<br>
>    }<br>
><br>
>    uint32_t findAttributeIndex(uint16_t attr) const;<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFContext.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=203766&r1=203765&r2=203766&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=203766&r1=203765&r2=203766&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFContext.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp Thu Mar 13 02:52:54 2014<br>
> @@ -75,29 +75,29 @@ void DWARFContext::dump(raw_ostream &OS,<br>
><br>
>    if (DumpType == DIDT_All || DumpType == DIDT_Info) {<br>
>      OS << "\n.debug_info contents:\n";<br>
> -    for (unsigned i = 0, e = getNumCompileUnits(); i != e; ++i)<br>
> -      getCompileUnitAtIndex(i)->dump(OS);<br>
> +    for (const auto &CU : compile_units())<br>
> +      CU->dump(OS);<br>
>    }<br>
><br>
>    if ((DumpType == DIDT_All || DumpType == DIDT_InfoDwo) &&<br>
>        getNumDWOCompileUnits()) {<br>
>      OS << "\n.debug_info.dwo contents:\n";<br>
> -    for (unsigned i = 0, e = getNumDWOCompileUnits(); i != e; ++i)<br>
> -      getDWOCompileUnitAtIndex(i)->dump(OS);<br>
> +    for (const auto &DWOCU : dwo_compile_units())<br>
> +      DWOCU->dump(OS);<br>
>    }<br>
><br>
>    if ((DumpType == DIDT_All || DumpType == DIDT_Types) && getNumTypeUnits()) {<br>
>      OS << "\n.debug_types contents:\n";<br>
> -    for (unsigned i = 0, e = getNumTypeUnits(); i != e; ++i)<br>
> -      getTypeUnitAtIndex(i)->dump(OS);<br>
> +    for (const auto &TU : type_units())<br>
> +      TU->dump(OS);<br>
>    }<br>
><br>
> -  if (DumpType == DIDT_All || DumpType == DIDT_TypesDwo)<br>
> -    if (getNumDWOTypeUnits()) {<br>
> -      OS << "\n.debug_types.dwo contents:\n";<br>
> -      for (unsigned i = 0, e = getNumDWOTypeUnits(); i != e; ++i)<br>
> -        getDWOTypeUnitAtIndex(i)->dump(OS);<br>
> -    }<br>
> +  if ((DumpType == DIDT_All || DumpType == DIDT_TypesDwo) &&<br>
> +      getNumDWOTypeUnits()) {<br>
> +    OS << "\n.debug_types.dwo contents:\n";<br>
> +    for (const auto &DWOTU : dwo_type_units())<br>
> +      DWOTU->dump(OS);<br>
> +  }<br>
><br>
>    if (DumpType == DIDT_All || DumpType == DIDT_Loc) {<br>
>      OS << "\n.debug_loc contents:\n";<br>
> @@ -121,12 +121,11 @@ void DWARFContext::dump(raw_ostream &OS,<br>
>    uint8_t savedAddressByteSize = 0;<br>
>    if (DumpType == DIDT_All || DumpType == DIDT_Line) {<br>
>      OS << "\n.debug_line contents:\n";<br>
> -    for (unsigned i = 0, e = getNumCompileUnits(); i != e; ++i) {<br>
> -      DWARFCompileUnit *cu = getCompileUnitAtIndex(i);<br>
> -      savedAddressByteSize = cu->getAddressByteSize();<br>
> +    for (const auto &CU : compile_units()) {<br>
> +      savedAddressByteSize = CU->getAddressByteSize();<br>
>        unsigned stmtOffset =<br>
> -          cu->getCompileUnitDIE()->getAttributeValueAsSectionOffset(<br>
> -              cu, DW_AT_stmt_list, -1U);<br>
> +          CU->getCompileUnitDIE()->getAttributeValueAsSectionOffset(<br>
> +              CU, DW_AT_stmt_list, -1U);<br>
>        if (stmtOffset != -1U) {<br>
>          DataExtractor lineData(getLineSection().Data, isLittleEndian(),<br>
>                                 savedAddressByteSize);<br>
> @@ -297,6 +296,8 @@ DWARFContext::getLineTableForCompileUnit<br>
>  }<br>
><br>
>  void DWARFContext::parseCompileUnits() {<br>
> +  if (!CUs.empty())<br>
> +    return;<br>
>    uint32_t offset = 0;<br>
>    const DataExtractor &DIData = DataExtractor(getInfoSection().Data,<br>
>                                                isLittleEndian(), 0);<br>
> @@ -314,17 +315,17 @@ void DWARFContext::parseCompileUnits() {<br>
>  }<br>
><br>
>  void DWARFContext::parseTypeUnits() {<br>
> -  const TypeSectionMap &Sections = getTypesSections();<br>
> -  for (TypeSectionMap::const_iterator I = Sections.begin(), E = Sections.end();<br>
> -       I != E; ++I) {<br>
> +  if (!TUs.empty())<br>
> +    return;<br>
> +  for (const auto &I : getTypesSections()) {<br>
>      uint32_t offset = 0;<br>
>      const DataExtractor &DIData =<br>
> -        DataExtractor(I->second.Data, isLittleEndian(), 0);<br>
> +        DataExtractor(I.second.Data, isLittleEndian(), 0);<br>
>      while (DIData.isValidOffset(offset)) {<br>
>        std::unique_ptr<DWARFTypeUnit> TU(new DWARFTypeUnit(<br>
> -          getDebugAbbrev(), I->second.Data, getAbbrevSection(),<br>
> +          getDebugAbbrev(), I.second.Data, getAbbrevSection(),<br>
>            getRangeSection(), getStringSection(), StringRef(), getAddrSection(),<br>
> -          &I->second.Relocs, isLittleEndian()));<br>
> +          &I.second.Relocs, isLittleEndian()));<br>
>        if (!TU->extract(DIData, &offset))<br>
>          break;<br>
>        TUs.push_back(TU.release());<br>
> @@ -334,6 +335,8 @@ void DWARFContext::parseTypeUnits() {<br>
>  }<br>
><br>
>  void DWARFContext::parseDWOCompileUnits() {<br>
> +  if (!DWOCUs.empty())<br>
> +    return;<br>
>    uint32_t offset = 0;<br>
>    const DataExtractor &DIData =<br>
>        DataExtractor(getInfoDWOSection().Data, isLittleEndian(), 0);<br>
> @@ -352,17 +355,17 @@ void DWARFContext::parseDWOCompileUnits(<br>
>  }<br>
><br>
>  void DWARFContext::parseDWOTypeUnits() {<br>
> -  const TypeSectionMap &Sections = getTypesDWOSections();<br>
> -  for (TypeSectionMap::const_iterator I = Sections.begin(), E = Sections.end();<br>
> -       I != E; ++I) {<br>
> +  if (!DWOTUs.empty())<br>
> +    return;<br>
> +  for (const auto &I : getTypesDWOSections()) {<br>
>      uint32_t offset = 0;<br>
>      const DataExtractor &DIData =<br>
> -        DataExtractor(I->second.Data, isLittleEndian(), 0);<br>
> +        DataExtractor(I.second.Data, isLittleEndian(), 0);<br>
>      while (DIData.isValidOffset(offset)) {<br>
>        std::unique_ptr<DWARFTypeUnit> TU(new DWARFTypeUnit(<br>
> -          getDebugAbbrevDWO(), I->second.Data, getAbbrevDWOSection(),<br>
> +          getDebugAbbrevDWO(), I.second.Data, getAbbrevDWOSection(),<br>
>            getRangeDWOSection(), getStringDWOSection(),<br>
> -          getStringOffsetDWOSection(), getAddrSection(), &I->second.Relocs,<br>
> +          getStringOffsetDWOSection(), getAddrSection(), &I.second.Relocs,<br>
>            isLittleEndian()));<br>
>        if (!TU->extract(DIData, &offset))<br>
>          break;<br>
> @@ -388,8 +391,7 @@ namespace {<br>
>  }<br>
><br>
>  DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) {<br>
> -  if (CUs.empty())<br>
> -    parseCompileUnits();<br>
> +  parseCompileUnits();<br>
><br>
>    DWARFCompileUnit **CU =<br>
>        std::lower_bound(CUs.begin(), CUs.end(), Offset, OffsetComparator());<br>
> @@ -522,9 +524,7 @@ DILineInfoTable DWARFContext::getLineInf<br>
>    if (!LineTable->lookupAddressRange(Address, Size, RowVector))<br>
>      return Lines;<br>
><br>
> -  uint32_t NumRows = RowVector.size();<br>
> -  for (uint32_t i = 0; i < NumRows; ++i) {<br>
> -    uint32_t RowIndex = RowVector[i];<br>
> +  for (uint32_t RowIndex : RowVector) {<br>
>      // Take file number and line/column from the row.<br>
>      const DWARFDebugLine::Row &Row = LineTable->Rows[RowIndex];<br>
>      std::string FileName = "<invalid>";<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFContext.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.h?rev=203766&r1=203765&r2=203766&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.h?rev=203766&r1=203765&r2=203766&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFContext.h (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFContext.h Thu Mar 13 02:52:54 2014<br>
> @@ -28,33 +28,38 @@ namespace llvm {<br>
>  /// information parsing. The actual data is supplied through pure virtual<br>
>  /// methods that a concrete implementation provides.<br>
>  class DWARFContext : public DIContext {<br>
> -  SmallVector<DWARFCompileUnit *, 1> CUs;<br>
> -  SmallVector<DWARFTypeUnit *, 1> TUs;<br>
> +  typedef SmallVector<DWARFCompileUnit *, 1> CUVector;<br>
> +  typedef SmallVector<DWARFTypeUnit *, 1> TUVector;<br>
> +<br>
> +  CUVector CUs;<br>
> +  TUVector TUs;<br>
>    std::unique_ptr<DWARFDebugAbbrev> Abbrev;<br>
>    std::unique_ptr<DWARFDebugLoc> Loc;<br>
>    std::unique_ptr<DWARFDebugAranges> Aranges;<br>
>    std::unique_ptr<DWARFDebugLine> Line;<br>
>    std::unique_ptr<DWARFDebugFrame> DebugFrame;<br>
><br>
> -  SmallVector<DWARFCompileUnit *, 1> DWOCUs;<br>
> -  SmallVector<DWARFTypeUnit *, 1> DWOTUs;<br>
> +  CUVector DWOCUs;<br>
> +  TUVector DWOTUs;<br>
>    std::unique_ptr<DWARFDebugAbbrev> AbbrevDWO;<br>
><br>
>    DWARFContext(DWARFContext &) LLVM_DELETED_FUNCTION;<br>
>    DWARFContext &operator=(DWARFContext &) LLVM_DELETED_FUNCTION;<br>
><br>
> -  /// Read compile units from the debug_info section and store them in CUs.<br>
> +  /// Read compile units from the debug_info section (if necessary)<br>
> +  /// and store them in CUs.<br>
>    void parseCompileUnits();<br>
><br>
> -  /// Read type units from the debug_types sections and store them in CUs.<br>
> +  /// Read type units from the debug_types sections (if necessary)<br>
> +  /// and store them in TUs.<br>
>    void parseTypeUnits();<br>
><br>
> -  /// Read compile units from the debug_info.dwo section and store them in<br>
> -  /// DWOCUs.<br>
> +  /// Read compile units from the debug_info.dwo section (if necessary)<br>
> +  /// and store them in DWOCUs.<br>
>    void parseDWOCompileUnits();<br>
><br>
> -  /// Read type units from the debug_types.dwo section and store them in<br>
> -  /// DWOTUs.<br>
> +  /// Read type units from the debug_types.dwo section (if necessary)<br>
> +  /// and store them in DWOTUs.<br>
>    void parseDWOTypeUnits();<br>
><br>
>  public:<br>
> @@ -72,62 +77,69 @@ public:<br>
><br>
>    void dump(raw_ostream &OS, DIDumpType DumpType = DIDT_All) override;<br>
><br>
> +  typedef iterator_range<CUVector::iterator> cu_iterator_range;<br>
> +  typedef iterator_range<TUVector::iterator> tu_iterator_range;<br>
> +<br>
> +  /// Get compile units in this context.<br>
> +  cu_iterator_range compile_units() {<br>
> +    parseCompileUnits();<br>
> +    return cu_iterator_range(CUs.begin(), CUs.end());<br>
> +  }<br>
> +<br>
> +  /// Get type units in this context.<br>
> +  tu_iterator_range type_units() {<br>
> +    parseTypeUnits();<br>
> +    return tu_iterator_range(TUs.begin(), TUs.end());<br>
> +  }<br>
> +<br>
> +  /// Get compile units in the DWO context.<br>
> +  cu_iterator_range dwo_compile_units() {<br>
> +    parseDWOCompileUnits();<br>
> +    return cu_iterator_range(DWOCUs.begin(), DWOCUs.end());<br>
> +  }<br>
> +<br>
> +  /// Get type units in the DWO context.<br>
> +  tu_iterator_range dwo_type_units() {<br>
> +    parseDWOTypeUnits();<br>
> +    return tu_iterator_range(DWOTUs.begin(), DWOTUs.end());<br>
> +  }<br>
> +<br>
>    /// Get the number of compile units in this context.<br>
>    unsigned getNumCompileUnits() {<br>
> -    if (CUs.empty())<br>
> -      parseCompileUnits();<br>
> +    parseCompileUnits();<br>
>      return CUs.size();<br>
>    }<br>
><br>
>    /// Get the number of compile units in this context.<br>
>    unsigned getNumTypeUnits() {<br>
> -    if (TUs.empty())<br>
> -      parseTypeUnits();<br>
> +    parseTypeUnits();<br>
>      return TUs.size();<br>
>    }<br>
><br>
>    /// Get the number of compile units in the DWO context.<br>
>    unsigned getNumDWOCompileUnits() {<br>
> -    if (DWOCUs.empty())<br>
> -      parseDWOCompileUnits();<br>
> +    parseDWOCompileUnits();<br>
>      return DWOCUs.size();<br>
>    }<br>
><br>
>    /// Get the number of compile units in the DWO context.<br>
>    unsigned getNumDWOTypeUnits() {<br>
> -    if (DWOTUs.empty())<br>
> -      parseDWOTypeUnits();<br>
> +    parseDWOTypeUnits();<br>
>      return DWOTUs.size();<br>
>    }<br>
><br>
>    /// Get the compile unit at the specified index for this compile unit.<br>
>    DWARFCompileUnit *getCompileUnitAtIndex(unsigned index) {<br>
> -    if (CUs.empty())<br>
> -      parseCompileUnits();<br>
> +    parseCompileUnits();<br>
>      return CUs[index];<br>
>    }<br>
><br>
> -  /// Get the type unit at the specified index for this compile unit.<br>
> -  DWARFTypeUnit *getTypeUnitAtIndex(unsigned index) {<br>
> -    if (TUs.empty())<br>
> -      parseTypeUnits();<br>
> -    return TUs[index];<br>
> -  }<br>
> -<br>
>    /// Get the compile unit at the specified index for the DWO compile units.<br>
>    DWARFCompileUnit *getDWOCompileUnitAtIndex(unsigned index) {<br>
> -    if (DWOCUs.empty())<br>
> -      parseDWOCompileUnits();<br>
> +    parseDWOCompileUnits();<br>
>      return DWOCUs[index];<br>
>    }<br>
><br>
> -  /// Get the type unit at the specified index for the DWO type units.<br>
> -  DWARFTypeUnit *getDWOTypeUnitAtIndex(unsigned index) {<br>
> -    if (DWOTUs.empty())<br>
> -      parseDWOTypeUnits();<br>
> -    return DWOTUs[index];<br>
> -  }<br>
> -<br>
>    /// Get a pointer to the parsed DebugAbbrev object.<br>
>    const DWARFDebugAbbrev *getDebugAbbrev();<br>
><br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFDebugAbbrev.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugAbbrev.cpp?rev=203766&r1=203765&r2=203766&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugAbbrev.cpp?rev=203766&r1=203765&r2=203766&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFDebugAbbrev.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFDebugAbbrev.cpp Thu Mar 13 02:52:54 2014<br>
> @@ -33,19 +33,17 @@ bool DWARFAbbreviationDeclarationSet::ex<br>
>  }<br>
><br>
>  void DWARFAbbreviationDeclarationSet::dump(raw_ostream &OS) const {<br>
> -  for (unsigned i = 0, e = Decls.size(); i != e; ++i)<br>
> -    Decls[i].dump(OS);<br>
> +  for (const auto &Decl : Decls)<br>
> +    Decl.dump(OS);<br>
>  }<br>
><br>
>  const DWARFAbbreviationDeclaration*<br>
>  DWARFAbbreviationDeclarationSet::getAbbreviationDeclaration(uint32_t abbrCode)<br>
>    const {<br>
>    if (IdxOffset == UINT32_MAX) {<br>
> -    DWARFAbbreviationDeclarationCollConstIter pos;<br>
> -    DWARFAbbreviationDeclarationCollConstIter end = Decls.end();<br>
> -    for (pos = Decls.begin(); pos != end; ++pos) {<br>
> -      if (pos->getCode() == abbrCode)<br>
> -        return &(*pos);<br>
> +    for (const auto &Decl : Decls) {<br>
> +      if (Decl.getCode() == abbrCode)<br>
> +        return &Decl;<br>
>      }<br>
>    } else {<br>
>      uint32_t idx = abbrCode - IdxOffset;<br>
> @@ -81,10 +79,9 @@ void DWARFDebugAbbrev::dump(raw_ostream<br>
>      return;<br>
>    }<br>
><br>
> -  DWARFAbbreviationDeclarationCollMapConstIter pos;<br>
> -  for (pos = AbbrevCollMap.begin(); pos != AbbrevCollMap.end(); ++pos) {<br>
> -    OS << format("Abbrev table for offset: 0x%8.8" PRIx64 "\n", pos->first);<br>
> -    pos->second.dump(OS);<br>
> +  for (const auto &I : AbbrevCollMap) {<br>
> +    OS << format("Abbrev table for offset: 0x%8.8" PRIx64 "\n", I.first);<br>
> +    I.second.dump(OS);<br>
>    }<br>
>  }<br>
><br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.cpp?rev=203766&r1=203765&r2=203766&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.cpp?rev=203766&r1=203765&r2=203766&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.cpp Thu Mar 13 02:52:54 2014<br>
> @@ -94,9 +94,9 @@ void DWARFDebugArangeSet::dump(raw_ostre<br>
>                 HeaderData.CuOffset, HeaderData.AddrSize, HeaderData.SegSize);<br>
><br>
>    const uint32_t hex_width = HeaderData.AddrSize * 2;<br>
> -  for (DescriptorConstIter pos = ArangeDescriptors.begin(),<br>
> -       end = ArangeDescriptors.end(); pos != end; ++pos)<br>
> -    OS << format("[0x%*.*" PRIx64 " -", hex_width, hex_width, pos->Address)<br>
> +  for (const auto &Desc : ArangeDescriptors) {<br>
> +    OS << format("[0x%*.*" PRIx64 " -", hex_width, hex_width, Desc.Address)<br>
>         << format(" 0x%*.*" PRIx64 ")\n",<br>
> -                 hex_width, hex_width, pos->getEndAddress());<br>
> +                 hex_width, hex_width, Desc.getEndAddress());<br>
> +  }<br>
>  }<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.h?rev=203766&r1=203765&r2=203766&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.h?rev=203766&r1=203765&r2=203766&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.h (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.h Thu Mar 13 02:52:54 2014<br>
> @@ -10,6 +10,7 @@<br>
>  #ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H<br>
>  #define LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H<br>
><br>
> +#include "llvm/ADT/iterator_range.h"<br>
>  #include "llvm/Support/DataExtractor.h"<br>
>  #include <vector><br>
><br>
> @@ -44,7 +45,7 @@ public:<br>
><br>
>  private:<br>
>    typedef std::vector<Descriptor> DescriptorColl;<br>
> -  typedef DescriptorColl::const_iterator DescriptorConstIter;<br>
> +  typedef iterator_range<DescriptorColl::const_iterator> desc_iterator_range;<br>
><br>
>    uint32_t Offset;<br>
>    Header HeaderData;<br>
> @@ -57,12 +58,12 @@ public:<br>
>    void dump(raw_ostream &OS) const;<br>
><br>
>    uint32_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; }<br>
> -  uint32_t getNumDescriptors() const { return ArangeDescriptors.size(); }<br>
> -  const Descriptor *getDescriptor(uint32_t i) const {<br>
> -    if (i < ArangeDescriptors.size())<br>
> -      return &ArangeDescriptors[i];<br>
> -    return NULL;<br>
> +<br>
> +  desc_iterator_range descriptors() const {<br>
> +    return desc_iterator_range(ArangeDescriptors.begin(),<br>
> +                               ArangeDescriptors.end());<br>
>    }<br>
> +  uint32_t getNumDescriptors() const { return ArangeDescriptors.size(); }<br>
>  };<br>
><br>
>  }<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFDebugAranges.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugAranges.cpp?rev=203766&r1=203765&r2=203766&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugAranges.cpp?rev=203766&r1=203765&r2=203766&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFDebugAranges.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFDebugAranges.cpp Thu Mar 13 02:52:54 2014<br>
> @@ -33,15 +33,12 @@ void DWARFDebugAranges::extract(DataExtr<br>
>      return;<br>
><br>
>    Aranges.reserve(TotalRanges);<br>
> -  for (RangeSetColl::const_iterator I = Sets.begin(), E = Sets.end(); I != E;<br>
> -       ++I) {<br>
> -    uint32_t CUOffset = I->getCompileUnitDIEOffset();<br>
> -<br>
> -    for (uint32_t i = 0, n = I->getNumDescriptors(); i < n; ++i) {<br>
> -      const DWARFDebugArangeSet::Descriptor *ArangeDescPtr =<br>
> -          I->getDescriptor(i);<br>
> -      uint64_t LowPC = ArangeDescPtr->Address;<br>
> -      uint64_t HighPC = LowPC + ArangeDescPtr->Length;<br>
> +  for (const auto &I : Sets) {<br>
> +    uint32_t CUOffset = I.getCompileUnitDIEOffset();<br>
> +<br>
> +    for (const auto &Desc : I.descriptors()) {<br>
> +      uint64_t LowPC = Desc.Address;<br>
> +      uint64_t HighPC = Desc.getEndAddress();<br>
>        appendRange(CUOffset, LowPC, HighPC);<br>
>      }<br>
>    }<br>
> @@ -59,12 +56,10 @@ void DWARFDebugAranges::generate(DWARFCo<br>
>    // Generate aranges from DIEs: even if .debug_aranges section is present,<br>
>    // it may describe only a small subset of compilation units, so we need to<br>
>    // manually build aranges for the rest of them.<br>
> -  for (uint32_t i = 0, n = CTX->getNumCompileUnits(); i < n; ++i) {<br>
> -    if (DWARFCompileUnit *CU = CTX->getCompileUnitAtIndex(i)) {<br>
> -      uint32_t CUOffset = CU->getOffset();<br>
> -      if (ParsedCUOffsets.insert(CUOffset).second)<br>
> -        CU->buildAddressRangeTable(this, true, CUOffset);<br>
> -    }<br>
> +  for (const auto &CU : CTX->compile_units()) {<br>
> +    uint32_t CUOffset = CU->getOffset();<br>
> +    if (ParsedCUOffsets.insert(CUOffset).second)<br>
> +      CU->buildAddressRangeTable(this, true, CUOffset);<br>
>    }<br>
><br>
>    sortAndMinimize();<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFDebugFrame.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugFrame.cpp?rev=203766&r1=203765&r2=203766&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugFrame.cpp?rev=203766&r1=203765&r2=203766&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFDebugFrame.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFDebugFrame.cpp Thu Mar 13 02:52:54 2014<br>
> @@ -186,10 +186,8 @@ void FrameEntry::parseInstructions(uint3<br>
>  void FrameEntry::dumpInstructions(raw_ostream &OS) const {<br>
>    // TODO: at the moment only instruction names are dumped. Expand this to<br>
>    // dump operands as well.<br>
> -  for (std::vector<Instruction>::const_iterator I = Instructions.begin(),<br>
> -                                                E = Instructions.end();<br>
> -       I != E; ++I) {<br>
> -    uint8_t Opcode = I->Opcode;<br>
> +  for (const auto &Instr : Instructions) {<br>
> +    uint8_t Opcode = Instr.Opcode;<br>
>      if (Opcode & DWARF_CFI_PRIMARY_OPCODE_MASK)<br>
>        Opcode &= DWARF_CFI_PRIMARY_OPCODE_MASK;<br>
>      OS << "  " << CallFrameString(Opcode) << ":\n";<br>
> @@ -289,9 +287,8 @@ DWARFDebugFrame::DWARFDebugFrame() {<br>
><br>
><br>
>  DWARFDebugFrame::~DWARFDebugFrame() {<br>
> -  for (EntryVector::iterator I = Entries.begin(), E = Entries.end();<br>
> -       I != E; ++I) {<br>
> -    delete *I;<br>
> +  for (const auto &Entry : Entries) {<br>
> +    delete Entry;<br>
>    }<br>
>  }<br>
><br>
> @@ -381,9 +378,7 @@ void DWARFDebugFrame::parse(DataExtracto<br>
><br>
>  void DWARFDebugFrame::dump(raw_ostream &OS) const {<br>
>    OS << "\n";<br>
> -  for (EntryVector::const_iterator I = Entries.begin(), E = Entries.end();<br>
> -       I != E; ++I) {<br>
> -    FrameEntry *Entry = *I;<br>
> +  for (const auto &Entry : Entries) {<br>
>      Entry->dumpHeader(OS);<br>
>      Entry->dumpInstructions(OS);<br>
>      OS << "\n";<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFDebugFrame.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugFrame.h?rev=203766&r1=203765&r2=203766&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugFrame.h?rev=203766&r1=203765&r2=203766&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFDebugFrame.h (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFDebugFrame.h Thu Mar 13 02:52:54 2014<br>
> @@ -42,5 +42,4 @@ private:<br>
><br>
>  } // namespace llvm<br>
><br>
> -#endif<br>
> -<br>
> +#endif<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp?rev=203766&r1=203765&r2=203766&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp?rev=203766&r1=203765&r2=203766&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp Thu Mar 13 02:52:54 2014<br>
> @@ -40,11 +40,8 @@ void DWARFDebugInfoEntryMinimal::dump(ra<br>
>                       AbbrevDecl->hasChildren() ? '*' : ' ');<br>
><br>
>          // Dump all data in the DIE for the attributes.<br>
> -        const uint32_t numAttributes = AbbrevDecl->getNumAttributes();<br>
> -        for (uint32_t i = 0; i != numAttributes; ++i) {<br>
> -          uint16_t attr = AbbrevDecl->getAttrByIndex(i);<br>
> -          uint16_t form = AbbrevDecl->getFormByIndex(i);<br>
> -          dumpAttribute(OS, u, &offset, attr, form, indent);<br>
> +        for (const auto &AttrSpec : AbbrevDecl->attributes()) {<br>
> +          dumpAttribute(OS, u, &offset, AttrSpec.Attr, AttrSpec.Form, indent);<br>
>          }<br>
><br>
>          const DWARFDebugInfoEntryMinimal *child = getFirstChild();<br>
> @@ -116,8 +113,8 @@ bool DWARFDebugInfoEntryMinimal::extract<br>
>    assert(FixedFormSizes.size() > 0);<br>
><br>
>    // Skip all data in the .debug_info for the attributes<br>
> -  for (uint32_t i = 0, n = AbbrevDecl->getNumAttributes(); i < n; ++i) {<br>
> -    uint16_t Form = AbbrevDecl->getFormByIndex(i);<br>
> +  for (const auto &AttrSpec : AbbrevDecl->attributes()) {<br>
> +    uint16_t Form = AttrSpec.Form;<br>
><br>
>      uint8_t FixedFormSize =<br>
>          (Form < FixedFormSizes.size()) ? FixedFormSizes[Form] : 0;<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h?rev=203766&r1=203765&r2=203766&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h?rev=203766&r1=203765&r2=203766&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h Thu Mar 13 02:52:54 2014<br>
> @@ -60,9 +60,6 @@ public:<br>
>    bool isSubroutineDIE() const;<br>
><br>
>    uint32_t getOffset() const { return Offset; }<br>
> -  uint32_t getNumAttributes() const {<br>
> -    return !isNULL() ? AbbrevDecl->getNumAttributes() : 0;<br>
> -  }<br>
>    bool hasChildren() const { return !isNULL() && AbbrevDecl->hasChildren(); }<br>
><br>
>    // We know we are kept in a vector of contiguous entries, so we know<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp?rev=203766&r1=203765&r2=203766&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp?rev=203766&r1=203765&r2=203766&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp Thu Mar 13 02:52:54 2014<br>
> @@ -90,9 +90,9 @@ void DWARFDebugLine::LineTable::dump(raw<br>
>      OS << "Address            Line   Column File   ISA Discriminator Flags\n"<br>
>         << "------------------ ------ ------ ------ --- ------------- "<br>
>            "-------------\n";<br>
> -    for (std::vector<Row>::const_iterator pos = Rows.begin(),<br>
> -         end = Rows.end(); pos != end; ++pos)<br>
> -      pos->dump(OS);<br>
> +    for (const Row &R : Rows) {<br>
> +      R.dump(OS);<br>
> +    }<br>
>    }<br>
>  }<br>
><br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFDebugLoc.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugLoc.cpp?rev=203766&r1=203765&r2=203766&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugLoc.cpp?rev=203766&r1=203765&r2=203766&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFDebugLoc.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFDebugLoc.cpp Thu Mar 13 02:52:54 2014<br>
> @@ -15,19 +15,19 @@<br>
>  using namespace llvm;<br>
><br>
>  void DWARFDebugLoc::dump(raw_ostream &OS) const {<br>
> -  for (LocationLists::const_iterator I = Locations.begin(), E = Locations.end(); I != E; ++I) {<br>
> -    OS << format("0x%8.8x: ", I->Offset);<br>
> +  for (const LocationList &L : Locations) {<br>
> +    OS << format("0x%8.8x: ", L.Offset);<br>
>      const unsigned Indent = 12;<br>
> -    for (SmallVectorImpl<Entry>::const_iterator I2 = I->Entries.begin(), E2 = I->Entries.end(); I2 != E2; ++I2) {<br>
> -      if (I2 != I->Entries.begin())<br>
> +    for (const Entry &E : L.Entries) {<br>
> +      if (&E != L.Entries.begin())<br>
>          OS.indent(Indent);<br>
> -      OS << "Beginning address offset: " << format("0x%016" PRIx64, I2->Begin)<br>
> +      OS << "Beginning address offset: " << format("0x%016" PRIx64, E.Begin)<br>
>           << '\n';<br>
>        OS.indent(Indent) << "   Ending address offset: "<br>
> -                        << format("0x%016" PRIx64, I2->End) << '\n';<br>
> +                        << format("0x%016" PRIx64, E.End) << '\n';<br>
>        OS.indent(Indent) << "    Location description: ";<br>
> -      for (SmallVectorImpl<unsigned char>::const_iterator I3 = I2->Loc.begin(), E3 = I2->Loc.end(); I3 != E3; ++I3) {<br>
> -        OS << format("%2.2x ", *I3);<br>
> +      for (unsigned char Loc : E.Loc) {<br>
> +        OS << format("%2.2x ", Loc);<br>
>        }<br>
>        OS << "\n\n";<br>
>      }<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFDebugRangeList.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugRangeList.cpp?rev=203766&r1=203765&r2=203766&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugRangeList.cpp?rev=203766&r1=203765&r2=203766&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFDebugRangeList.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFDebugRangeList.cpp Thu Mar 13 02:52:54 2014<br>
> @@ -45,22 +45,21 @@ bool DWARFDebugRangeList::extract(DataEx<br>
>  }<br>
><br>
>  void DWARFDebugRangeList::dump(raw_ostream &OS) const {<br>
> -  for (int i = 0, n = Entries.size(); i != n; ++i) {<br>
> +  for (const RangeListEntry &RLE : Entries) {<br>
>      const char *format_str = (AddressSize == 4<br>
>                                ? "%08x %08"  PRIx64 " %08"  PRIx64 "\n"<br>
>                                : "%08x %016" PRIx64 " %016" PRIx64 "\n");<br>
> -    OS << format(format_str, Offset, Entries[i].StartAddress,<br>
> -                                     Entries[i].EndAddress);<br>
> +    OS << format(format_str, Offset, RLE.StartAddress, RLE.EndAddress);<br>
>    }<br>
>    OS << format("%08x <End of list>\n", Offset);<br>
>  }<br>
><br>
>  bool DWARFDebugRangeList::containsAddress(uint64_t BaseAddress,<br>
>                                            uint64_t Address) const {<br>
> -  for (int i = 0, n = Entries.size(); i != n; ++i) {<br>
> -    if (Entries[i].isBaseAddressSelectionEntry(AddressSize))<br>
> -      BaseAddress = Entries[i].EndAddress;<br>
> -    else if (Entries[i].containsAddress(BaseAddress, Address))<br>
> +  for (const RangeListEntry &RLE : Entries) {<br>
> +    if (RLE.isBaseAddressSelectionEntry(AddressSize))<br>
> +      BaseAddress = RLE.EndAddress;<br>
> +    else if (RLE.containsAddress(BaseAddress, Address))<br>
>        return true;<br>
>    }<br>
>    return false;<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFUnit.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFUnit.cpp?rev=203766&r1=203765&r2=203766&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFUnit.cpp?rev=203766&r1=203765&r2=203766&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFUnit.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFUnit.cpp Thu Mar 13 02:52:54 2014<br>
> @@ -331,11 +331,12 @@ DWARFUnit::buildAddressRangeTable(DWARFD<br>
>  const DWARFDebugInfoEntryMinimal *<br>
>  DWARFUnit::getSubprogramForAddress(uint64_t Address) {<br>
>    extractDIEsIfNeeded(false);<br>
> -  for (size_t i = 0, n = DieArray.size(); i != n; i++)<br>
> -    if (DieArray[i].isSubprogramDIE() &&<br>
> -        DieArray[i].addressRangeContainsAddress(this, Address)) {<br>
> -      return &DieArray[i];<br>
> +  for (const DWARFDebugInfoEntryMinimal &DIE : DieArray) {<br>
> +    if (DIE.isSubprogramDIE() &&<br>
> +        DIE.addressRangeContainsAddress(this, Address)) {<br>
> +      return &DIE;<br>
>      }<br>
> +  }<br>
>    return 0;<br>
>  }<br>
><br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div>
</div></div>