[flang-commits] [flang] [flang] Improve warnings for invalid arguments when folding host runtime (PR #96807)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Fri Jun 28 08:04:09 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};
----------------
klausler wrote:
Instead of using magic values, consider using `std::optional<int>`, with `std::nullopt` signifying the last argument. You can then access the argument via `.value_or(args.size()-1)`.
https://github.com/llvm/llvm-project/pull/96807
More information about the flang-commits
mailing list