[all-commits] [llvm/llvm-project] 4728d3: [clang] Reject references to vector types in `__bu...

Akash Manna via All-commits all-commits at lists.llvm.org
Wed Sep 9 10:18:50 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4728d3c8e911e9f67e8eaf2f6756364f10518560
      https://github.com/llvm/llvm-project/commit/4728d3c8e911e9f67e8eaf2f6756364f10518560
  Author: Akash Manna <akash.manna.mymail at gmail.com>
  Date:   2026-09-09 (Wed, 09 Sep 2026)

  Changed paths:
    M clang/docs/ReleaseNotes.md
    M clang/lib/Sema/SemaExpr.cpp
    M clang/test/SemaCXX/builtin_vectorelements.cpp
    M clang/test/SemaCXX/ptrauth-type-discriminator.cpp
    A clang/test/SemaOpenCLCXX/vec_step.clcpp

  Log Message:
  -----------
  [clang] Reject references to vector types in `__builtin_vectorelements` (#219767)

Fixes #216997

`__builtin_vectorelements` shares its operand check with `sizeof` and
friends, and that shared code looks through reference types before it
dispatches to the per-builtin check. So `__builtin_vectorelements(veci4
&)` was accepted by Sema, but the expression kept the reference as its
argument type, and everything downstream — constant evaluation, the
bytecode interpreter, CodeGen — expects that type to be a vector.
Constant-evaluating the initializer in the reproducer then trips
`assert(Ty->isSizelessVectorType())`. The alias syntax in the report
isn't the cause; `vec` there is a well-formed reference-to-vector type.

The check now runs before the reference is looked through, so a
reference to a vector type gets the existing "must be of vector type"
error, the same one `__builtin_vectorelements(int &)` already produced.
No other trait kind is affected.

LLM tools were used for this contribution. I've reviewed, built, and
tested the change myself before pushing to GitHub.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list