[PATCH] D32609: Update llvm-readobj -coff-resources to display tree structure.

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 4 14:29:04 PDT 2017


zturner added inline comments.


================
Comment at: llvm/tools/llvm-readobj/COFFDumper.cpp:1628-1631
+  if (Index >= (Table.NumberOfNameEntries + Table.NumberOfIDEntries))
+    return object_error::parse_failed;
+  return *(reinterpret_cast<const coff_resource_dir_entry *>(&Table + 1) +
+           Index);
----------------
zturner wrote:
> ruiu wrote:
> > This is a comment about the style, but for operators who's precedences are "obvious", we don't use that many parentheses.
> > 
> > Everyone knows that + has lower precedence than >=.
> > 
> > *(reinterpret_cast<foo>(bar)) is the same as *reinterpret_cast<foo>(bar).
> > 
> > `(&Table + 1) + Index` is the same as &Table + 1 + Index.
> Although both are ugly IMO :)  How about
> 
> ```
> auto TablePtr = reinterpret_cast<const coff_resource_dir_entry *>(&Table);
> return TablePtr[1 + Index];
> ```
Correction:
```
auto TablePtr = reinterpret_cast<const coff_resource_dir_entry *>(&Table + 1);
return TablePtr[Index];
```


https://reviews.llvm.org/D32609





More information about the llvm-commits mailing list