[Clang] Improve Dynamic builtin_shufflevector size mismatch diagnostic
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Currently, for this code
```c
typedef float v8b __attribute__((ext_vector_type(8)));
typedef int v6f __attribute__((ext_vector_type(6)));
void dynamic_vector_shuffle() {
v8b a;
v6f b;
auto r = __builtin_shufflevector(a, b);
}
```
We report `error: first two arguments to '__builtin_shufflevector' must have the same type`.
Compiler-explorer: https://godbolt.org/z/jhh96nE3s
But dynamic `__builtin_shufflevector` doesn't require the two arguments to have the same type; it requires the same size + the second one (Mask) to have an integer element type
https://github.com/llvm/llvm-project/blob/0d18bb67d106cdf1e2c9e114ac1b67167a233b6c/clang/lib/Sema/SemaChecking.cpp#L6588-L6595
I suggest changing this diagnostic to mention the actual reason, similar to `err_convertvector_incompatible_vector`
```
def err_convertvector_incompatible_vector : Error<
"first two arguments to __builtin_convertvector must have the same number of elements">;
```
Maybe also print the two types or the two sizes.
I will work on it if it is confirmed :D
Contributor guide
Assessment
This issue has not been assessed yet.