[PATCH] D63735: [MachOObjectFile]Added Valid Architecture Function

Steven Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 16 11:35:48 PDT 2019


steven_wu added a comment.

In D63735#1588025 <https://reviews.llvm.org/D63735#1588025>, @smeenai wrote:

> In D63735#1587999 <https://reviews.llvm.org/D63735#1587999>, @steven_wu wrote:
>
> > This adds an unnecessary static initializer to the MachOObject.cpp. Can you move the array of validArchs into filescope? You can declare it in getValidArchs() and use getValidArchs() in isValidArchs.
>
>
> I was hoping that `std::array` wouldn't necessitate a static initializer, since it's just supposed to be a zero-cost wrapper around a C array.


Not if you create std::array<StringRef>.

> Could you clarify what you mean by file scope? It's already a `static const` inside MachOObjectFile.cpp; do you mean moving the declaration into `getValidArchs()`?



  ArrayRef<StringRef> MachOObjectFile::getValidArchs() {
    static const std::array<StringRef, 17> validArchs = {
        "i386",   "x86_64", "x86_64h",  "armv4t",  "arm",    "armv5e",
        "armv6",  "armv6m", "armv7",    "armv7em", "armv7k", "armv7m",
        "armv7s", "arm64",  "arm64_32", "ppc",     "ppc64",
    };
    return validArchs;
  }




Repository:
  rL LLVM

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

https://reviews.llvm.org/D63735





More information about the llvm-commits mailing list