File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
flang/lib/Optimizer/Builder Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -678,6 +678,20 @@ static constexpr IntrinsicHandler handlers[]{
678678 /* isElemental=*/ true },
679679};
680680
681+ template <std::size_t N>
682+ static constexpr bool isSorted (const IntrinsicHandler (&array)[N]) {
683+ // Replace by std::sorted when C++20 is default (will be constexpr).
684+ const IntrinsicHandler *lastSeen{nullptr };
685+ bool isSorted{true };
686+ for (const auto &x : array) {
687+ if (lastSeen)
688+ isSorted &= std::string_view{lastSeen->name } < std::string_view{x.name };
689+ lastSeen = &x;
690+ }
691+ return isSorted;
692+ }
693+ static_assert (isSorted(handlers) && "map must be sorted");
694+
681695static const IntrinsicHandler *findIntrinsicHandler (llvm::StringRef name) {
682696 auto compare = [](const IntrinsicHandler &handler, llvm::StringRef name) {
683697 return name.compare (handler.name ) > 0 ;
You can’t perform that action at this time.
0 commit comments