[PATCH] D72756: [LLD][ELF] Add support for INPUT_SECTION_FLAGS

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 17 02:34:04 PST 2020


grimar added inline comments.


================
Comment at: lld/ELF/ScriptParser.cpp:1146
+  };
+#undef ENUM_ENT
+  if (llvm::Optional<uint64_t> asInt = parseInt(tok))
----------------
grimar wrote:
> May be use `llvm::StringSwitch` instead?
To clarify: `StringSwitch` looks probably much simpler than a combination of `EnumEntry<unsigned>` array + `llvm::find_if`.
So it seems could be:

```
  return StringSwitch<llvm::Optional<uint64_t>> (tok)
    .Case("SHF_WRITE", ELF::SHF_WRITE)
 ...
```

or

```
  return StringSwitch<llvm::Optional<uint64_t>> (tok)
    .Case(ENUM_ENT(SHF_WRITE))
 ...
```
(If we want to use defines. I am not sure in that, given that the number of flags is not so large now,
but have no strong objections)

Both ways still look better probably?


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

https://reviews.llvm.org/D72756





More information about the llvm-commits mailing list