[flang-commits] [flang] [flang][cli] Add diagnostic flags to the CLI (PR #142022)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Thu May 29 13:11:15 PDT 2025


================
@@ -58,15 +59,51 @@ constexpr std::array<std::string_view, ITEMS> EnumNames(const char *p) {
   return result;
 }
 
+template <typename F, typename T>
+std::optional<T> inline fmap(std::optional<F> x, std::function<T(const F)> f) {
+  return x ? std::optional<T>{f(*x)} : std::nullopt;
+}
+
+using Predicate = std::function<bool(const std::string_view)>;
+// Finds the first index for which the predicate returns true.
+std::optional<int> FindEnumIndex(
+    Predicate pred, int size, const std::string_view *names);
+
+using FindEnumIndexType = std::optional<int>(
+    Predicate, int, const std::string_view *);
+
+template <typename NAME>
+std::optional<NAME> inline FindEnum(
+    Predicate pred, std::function<std::optional<int>(Predicate)> find) {
+  std::function<NAME(int)> f = [](int x) { return static_cast<NAME>(x); };
----------------
klausler wrote:

Braced initialization always in f18 before lowering or in the runtime.

https://github.com/llvm/llvm-project/pull/142022


More information about the flang-commits mailing list