[PATCH] D26013: Change DWARF parser to use enumerations for DWARF tags, attributes and forms.

Greg Clayton via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 26 17:15:27 PDT 2016


clayborg added a comment.

Added clarification on the "where did this go" in inlined comments.



================
Comment at: lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp:41-45
-    uint16_t Attr = Data.getULEB128(OffsetPtr);
-    if (CurOffset == *OffsetPtr) {
+    const Attribute A = static_cast<Attribute>(Data.getULEB128(OffsetPtr));
+    const Form F = static_cast<Form>(Data.getULEB128(OffsetPtr));
+    if (A && F) {
+        AttributeSpecs.push_back(AttributeSpec(A, F));
+    } else if (A == 0 && F == 0) {
+      // Successfully parsed this abbreviation
+      break;
+    } else {
+      // Either the attribute or form was zero, but not both which is an error
       clear();
       return false;
     }
----------------
They are combined into the "else" clause on line 51 on the right. No need to check that nothing was parsed by comparing the offset. If there is no data, zero will be returned. So the changes on the right check the success case first:

```
if (A && F)
```

then check if both are zero, which is the success case in the middle:

```
} else if (A == 0 && F == 0) {
```

And then check of either A or F was zero which is the error case. 


Repository:
  rL LLVM

https://reviews.llvm.org/D26013





More information about the llvm-commits mailing list