[clang] Fix memcpy-operator= generation with restrict parameters. (PR #194906)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 30 05:15:23 PDT 2026


================
@@ -15181,7 +15181,7 @@ buildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T,
                       bool CopyingBaseSubobject, bool Copying) {
   // Maybe we should use a memcpy?
   if (T->isArrayType() && !T.isConstQualified() && !T.isVolatileQualified() &&
-      T.isTriviallyCopyableType(S.Context))
+      !T.isRestrictQualified() && T.isTriviallyCopyableType(S.Context))
----------------
AaronBallman wrote:

The changes here are correct as far as they go, but I actually wonder if we want this predicate to be even more conservative: if there are any qualifiers of any kind or it's an attributed type, just use the for loop version and let CodeGen figure out if that's acceptable to turn back into a memcpy. But I don't insist on a PR for that,

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


More information about the cfe-commits mailing list