[clang] [clang] Improve diagnostics for vector builtins (PR #125673)

Fraser Cormack via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 18 07:07:19 PST 2025


================
@@ -12411,16 +12411,13 @@ def err_builtin_is_within_lifetime_invalid_arg : Error<
   "%select{non-|function }0pointer argument to '__builtin_is_within_lifetime' "
   "is not allowed">;
 
-def err_builtin_invalid_arg_type: Error <
-  "%ordinal0 argument must be "
-  "%select{a vector, integer or floating point type|a matrix|"
-  "a pointer to a valid matrix element type|"
-  "a signed integer or floating point type|a vector type|"
-  "a floating point type|"
-  "a vector of integers|"
-  "an unsigned integer|"
-  "an 'int'|"
-  "a vector of floating points}1 (was %2)">;
+def err_builtin_invalid_arg_type: Error<
+  "%ordinal0 argument must be a"
+  "%select{| scalar| vector| vector,| vector of| scalar or vector of}1"
+  "%select{| integer| signed integer| unsigned integer| 'int'|"
+  " matrix| pointer to a valid matrix element}2"
----------------
frasercrmck wrote:

Yes I think `matrix` should be in the first grouping, for that reason. I can't think of why I put it in the second - let me see if I was fudging something.

To achieve `scalar, vector, or matrix of` it could go fairly simply into the first grouping, though it's obviously not very scalable as more and more container types get added. Those should be pretty rare, though.

We could also split out `scalar`, `vector` and `matrix` into separate selects, but that puts more work onto each user, and might make some of the other conditional checks and comma management harder to achieve.

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


More information about the cfe-commits mailing list