[PATCH] D66089: [llvm/Object] - Convert SectionRef::getName() to return Expected<>
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 12 23:38:32 PDT 2019
MaskRay accepted this revision.
MaskRay added inline comments.
================
Comment at: tools/llvm-cov/TestingSupport.cpp:52
for (const auto &Section : OF->sections()) {
- StringRef Name;
- if (Section.getName(Name))
+ Expected<StringRef> NameOrErr = Section.getName();
+ if (!NameOrErr) {
----------------
Something like:
if (Expected<StringRef> NameOrErr = Section.getName())
SectName = *NameOrErr;
else {
consumeError(NameOrErr.takeError());
return 1;
}
================
Comment at: tools/llvm-objdump/MachODump.cpp:7398
+ }
+ if ((*SecNameOrErr) != DisSectName)
continue;
----------------
superfluous parentheses
================
Comment at: tools/llvm-objdump/llvm-objdump.cpp:932
+ }
+ if ((*SecNameOrErr) == ".plt")
Plt = Section;
----------------
superfluous parentheses
================
Comment at: tools/llvm-readobj/Win64EHDumper.cpp:308
+ Expected<StringRef> NameOrErr = Section.getName();
+ if (NameOrErr)
+ Name = *NameOrErr;
----------------
`if (Expected<StringRef> NameOrErr = Section.getName())` (this is what you do in other files)
================
Comment at: tools/llvm-size/llvm-size.cpp:407
uint64_t addr = Section.getAddress();
- max_name_len = std::max(max_name_len, name.size());
+ max_name_len = std::max(max_name_len, (*name_or_err).size());
max_size_len = std::max(max_size_len, getNumLengthAsString(size));
----------------
name_or_err->size()
================
Comment at: tools/llvm-size/llvm-size.cpp:448
outs() << format(fmt.str().c_str(), namestr.c_str(), size, addr);
}
----------------
name_or_err->c_str() and delete `namestr`
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66089/new/
https://reviews.llvm.org/D66089
More information about the llvm-commits
mailing list