[flang-commits] [flang] [flang] Improve warnings for invalid arguments when folding host runtime (PR #96807)

Pete Steinfeld via flang-commits flang-commits at lists.llvm.org
Fri Jun 28 14:45:07 PDT 2024


================
@@ -633,10 +633,243 @@ static DynamicType BiggerType(DynamicType type) {
   return type;
 }
 
+/// Structure to register intrinsic argument checks that must be performed.
+using ArgumentVerifierFunc = bool (*)(
+    const std::vector<Expr<SomeType>> &, FoldingContext &);
+struct ArgumentVerifier {
+  using Key = std::string_view;
+  // Needed for implicit compare with keys.
+  constexpr operator Key() const { return key; }
+  Key key; // intrinsic name
+  ArgumentVerifierFunc verifier;
+};
+
+static constexpr int lastArg{-1};
----------------
psteinfeld wrote:

I don't understand the advantage of this.  It seems like `std::nullopt` just becomes another kind of magic value.  Currently, the code accesses the last argument using `args.back()`, which seems pretty clear to me.

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


More information about the flang-commits mailing list