@@ -150,6 +150,8 @@ DWARFAbbreviationDeclaration::findAttributeIndex(dwarf::Attribute Attr) const {
150
150
Optional<DWARFFormValue> DWARFAbbreviationDeclaration::getAttributeValue (
151
151
const uint64_t DIEOffset, const dwarf::Attribute Attr,
152
152
const DWARFUnit &U) const {
153
+ // Check if this abbreviation has this attribute without needing to skip
154
+ // any data so we can return quickly if it doesn't.
153
155
Optional<uint32_t > MatchAttrIndex = findAttributeIndex (Attr);
154
156
if (!MatchAttrIndex)
155
157
return None;
@@ -159,26 +161,24 @@ Optional<DWARFFormValue> DWARFAbbreviationDeclaration::getAttributeValue(
159
161
// Add the byte size of ULEB that for the abbrev Code so we can start
160
162
// skipping the attribute data.
161
163
uint64_t Offset = DIEOffset + CodeByteSize;
162
- uint32_t AttrIndex = 0 ;
163
- for (const auto &Spec : AttributeSpecs) {
164
- if (*MatchAttrIndex == AttrIndex) {
165
- // We have arrived at the attribute to extract, extract if from Offset.
166
- if (Spec.isImplicitConst ())
167
- return DWARFFormValue::createFromSValue (Spec.Form ,
168
- Spec.getImplicitConstValue ());
169
-
170
- DWARFFormValue FormValue (Spec.Form );
171
- if (FormValue.extractValue (DebugInfoData, &Offset, U.getFormParams (), &U))
172
- return FormValue;
173
- }
174
- // March Offset along until we get to the attribute we want.
175
- if (auto FixedSize = Spec.getByteSize (U))
164
+ for (uint32_t CurAttrIdx = 0 ; CurAttrIdx != *MatchAttrIndex; ++CurAttrIdx)
165
+ // Match Offset along until we get to the attribute we want.
166
+ if (auto FixedSize = AttributeSpecs[CurAttrIdx].getByteSize (U))
176
167
Offset += *FixedSize;
177
168
else
178
- DWARFFormValue::skipValue (Spec.Form , DebugInfoData, &Offset,
179
- U.getFormParams ());
180
- ++AttrIndex;
181
- }
169
+ DWARFFormValue::skipValue (AttributeSpecs[CurAttrIdx].Form , DebugInfoData,
170
+ &Offset, U.getFormParams ());
171
+
172
+ // We have arrived at the attribute to extract, extract if from Offset.
173
+ const AttributeSpec &Spec = AttributeSpecs[*MatchAttrIndex];
174
+ if (Spec.isImplicitConst ())
175
+ return DWARFFormValue::createFromSValue (Spec.Form ,
176
+ Spec.getImplicitConstValue ());
177
+
178
+ DWARFFormValue FormValue (Spec.Form );
179
+ if (FormValue.extractValue (DebugInfoData, &Offset, U.getFormParams (), &U))
180
+ return FormValue;
181
+
182
182
return None;
183
183
}
184
184
0 commit comments