[PATCH] D82462: [llvm-readelf] - Report a warning instead of an error when dumping a broken section header.

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 25 01:03:16 PDT 2020


jhenderson accepted this revision.
jhenderson added a comment.

LGTM, with one suggestion. Thanks!



================
Comment at: llvm/tools/llvm-readobj/ELFDumper.cpp:3829-3834
+  Expected<StringRef> SecStrTableOrErr =
+      Obj->getSectionStringTable(Sections, this->dumper()->WarningHandler);
+  if (!SecStrTableOrErr)
+    this->reportUniqueWarning(SecStrTableOrErr.takeError());
+  else
+    SecStrTable = *SecStrTableOrErr;
----------------
Consider using the following instead to limit the scope of `SecStrTableOrErr`:
```
  if (Expected<StringRef> SecStrTableOrErr =
      Obj->getSectionStringTable(Sections, this->dumper()->WarningHandler);)
    SecStrTable = *SecStrTableOrErr;
  else
    this->reportUniqueWarning(SecStrTableOrErr.takeError());
```

(I don't mind if you don't want to do that though)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82462/new/

https://reviews.llvm.org/D82462





More information about the llvm-commits mailing list