[PATCH] D85821: [MachOYAML] Simplify the section data emitting function. NFC.
Xing GUO via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 12 06:47:07 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG386d5af04b65: [MachOYAML] Simplify the section data emitting function. NFC. (authored by Higuoxing).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85821/new/
https://reviews.llvm.org/D85821
Files:
llvm/lib/ObjectYAML/MachOEmitter.cpp
Index: llvm/lib/ObjectYAML/MachOEmitter.cpp
===================================================================
--- llvm/lib/ObjectYAML/MachOEmitter.cpp
+++ llvm/lib/ObjectYAML/MachOEmitter.cpp
@@ -285,32 +285,14 @@
return createStringError(
errc::invalid_argument,
"wrote too much data somewhere, section offsets don't line up");
- if (0 == strncmp(&Sec.segname[0], "__DWARF", 16)) {
- Error Err = Error::success();
- cantFail(std::move(Err));
-
- if (0 == strncmp(&Sec.sectname[0], "__debug_str", 16))
- Err = DWARFYAML::emitDebugStr(OS, Obj.DWARF);
- else if (0 == strncmp(&Sec.sectname[0], "__debug_abbrev", 16))
- Err = DWARFYAML::emitDebugAbbrev(OS, Obj.DWARF);
- else if (0 == strncmp(&Sec.sectname[0], "__debug_aranges", 16)) {
- if (Obj.DWARF.DebugAranges)
- Err = DWARFYAML::emitDebugAranges(OS, Obj.DWARF);
- } else if (0 == strncmp(&Sec.sectname[0], "__debug_ranges", 16))
- Err = DWARFYAML::emitDebugRanges(OS, Obj.DWARF);
- else if (0 == strncmp(&Sec.sectname[0], "__debug_pubnames", 16)) {
- if (Obj.DWARF.PubNames)
- Err = DWARFYAML::emitDebugPubnames(OS, Obj.DWARF);
- } else if (0 == strncmp(&Sec.sectname[0], "__debug_pubtypes", 16)) {
- if (Obj.DWARF.PubTypes)
- Err = DWARFYAML::emitDebugPubtypes(OS, Obj.DWARF);
- } else if (0 == strncmp(&Sec.sectname[0], "__debug_info", 16))
- Err = DWARFYAML::emitDebugInfo(OS, Obj.DWARF);
- else if (0 == strncmp(&Sec.sectname[0], "__debug_line", 16))
- Err = DWARFYAML::emitDebugLine(OS, Obj.DWARF);
-
- if (Err)
- return Err;
+ if (0 == strncmp(&Sec.segname[0], "__DWARF", sizeof(Sec.segname))) {
+ StringRef SectName(Sec.sectname,
+ strnlen(Sec.sectname, sizeof(Sec.sectname)));
+ auto EmitFunc = DWARFYAML::getDWARFEmitterByName(SectName.substr(2));
+ if (Obj.DWARF.getNonEmptySectionNames().count(SectName.substr(2))) {
+ if (Error Err = EmitFunc(OS, Obj.DWARF))
+ return Err;
+ }
continue;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85821.285068.patch
Type: text/x-patch
Size: 2259 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200812/465b967d/attachment.bin>
More information about the llvm-commits
mailing list