[PATCH] D103113: [lld-macho] Deduplicate fixed-width literals
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 8 22:05:12 PDT 2021
int3 added inline comments.
================
Comment at: lld/MachO/SyntheticSections.cpp:1129-1135
+ case S_4BYTE_LITERALS: {
+ for (size_t i = 0, e = isec->data.size() / 4; i < e; ++i) {
+ uint32_t value = *reinterpret_cast<const uint32_t *>(buf + i * 4);
+ literal4Map.emplace(value, literal4Map.size());
+ }
+ break;
+ }
----------------
gkm wrote:
> What is the purpose of the braces around these `case` bodies?
Declaring variables whose scope can leak out of the switch-case raises the error "cannot jump from switch statement to this case label... jump bypasses variable initialization". In this case it's not actually needed since `i` and `value` are scoped within the `for` loop, but nonetheless I like putting braces around non-trivial case blocks so I don't have to worry about this issue.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103113/new/
https://reviews.llvm.org/D103113
More information about the llvm-commits
mailing list