Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions flang/lib/Optimizer/Builder/IntrinsicCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,20 @@ static constexpr IntrinsicHandler handlers[]{
/*isElemental=*/true},
};

template <std::size_t N>
static constexpr bool isSorted(const IntrinsicHandler (&array)[N]) {
// Replace by std::sorted when C++20 is default (will be constexpr).
const IntrinsicHandler *lastSeen{nullptr};
bool isSorted{true};
for (const auto &x : array) {
if (lastSeen)
isSorted &= std::string_view{lastSeen->name} < std::string_view{x.name};
lastSeen = &x;
}
return isSorted;
}
static_assert(isSorted(handlers) && "map must be sorted");

static const IntrinsicHandler *findIntrinsicHandler(llvm::StringRef name) {
auto compare = [](const IntrinsicHandler &handler, llvm::StringRef name) {
return name.compare(handler.name) > 0;
Expand Down
Loading