[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

Fraser Cormack via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 6 04:17:58 PST 2025


================
@@ -14585,11 +14585,18 @@ void Sema::CheckAddressOfPackedMember(Expr *rhs) {
                      _2, _3, _4));
 }
 
+static ExprResult UsualUnaryConversionsNoPromoteInt(Sema &S, Expr *E) {
+  // Don't promote integer types
+  if (QualType Ty = E->getType(); S.getASTContext().isPromotableIntegerType(Ty))
+    return S.DefaultFunctionArrayLvalueConversion(E);
+  return S.UsualUnaryConversions(E);
----------------
frasercrmck wrote:

Yes, pretty much. `UsualUnaryConversions` does `DefaultFunctionArrayLvalueConversion` first, then floating-point specific logic. However, it also handles `isPromotableBitField`s.

In your other comment you ask about enums, and perhaps bitfields also falls into that category? Do we really need to support these types in vector maths/arithmetic builtins? There are tests for them, so I preserved the existing logic (though seemingly not for bitfields) but I see the argument for removing that support.

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


More information about the cfe-commits mailing list