================ @@ -191,6 +191,60 @@ static MarshallingInfo createMarshallingInfo(const Record &R) { return Ret; } +static void EmitHelpTextsForVariants( + raw_ostream &OS, std::vector<std::pair<std::vector<std::string>, StringRef>> + HelpTextsForVariants) { + // OptTable must be constexpr so it uses std::arrays with these capacities. + const unsigned MaxVisibilityPerHelp = 2; + const unsigned MaxVisibilityHelp = 1; + + // This function must initialise any unused elements of those arrays. + for (auto [Visibilities, _] : HelpTextsForVariants) + while (Visibilities.size() < MaxVisibilityPerHelp) + Visibilities.push_back("0"); + + while (HelpTextsForVariants.size() < MaxVisibilityHelp) + HelpTextsForVariants.push_back( + {std::vector<std::string>(MaxVisibilityPerHelp, "0"), ""}); + + OS << ", (std::array<std::pair<std::array<unsigned, " << MaxVisibilityPerHelp + << ">, const char*>, " << MaxVisibilityHelp << ">{{ "; + + assert(HelpTextsForVariants.size() <= MaxVisibilityHelp && + "Too many help text variants to store in " + "OptTable::HelpTextsForVariants"); ---------------- luporl wrote:
This is subjective, but if you agree, I think that moving this assert to the beginning of the function, or before the `OS <<` line would make it easier to read. https://github.com/llvm/llvm-project/pull/81869 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits