================
@@ -14980,6 +14988,22 @@ buildMemcpyForAssignmentOp(Sema &S, SourceLocation
Loc, QualType T,
S.Context, To, UO_AddrOf, S.Context.getPointerType(To->getType()),
VK_PRValue, OK_Ordinary, Loc, false, S.CurFPFeatureOverrides());
+ if (SuppressMemaccessWarning) {
+ // An explicit cast to void* survives IgnoreParenImpCasts, so the memaccess
+ // check sees a void pointee and skips the non-trivial-copy warning.
+ QualType ConstVoidPtr =
+ S.Context.getPointerType(S.Context.VoidTy.withConst());
+ ExprResult FromCast = S.BuildCStyleCastExpr(
+ Loc, S.Context.getTrivialTypeSourceInfo(ConstVoidPtr, Loc), Loc, From);
+ ExprResult ToCast = S.BuildCStyleCastExpr(
----------------
AaronBallman wrote:
> I feel like addings casts to silence warnings is not something we should do
> (even if that's what people would do in source code)
I tend to agree. For example, those casts would likely be a bit of a surprise
to tooling using AST matchers. (But then again, maybe the optimization where we
call memcpy will already be a surprise to them and the casts are just more
surprise.) And because they're not explicit, will it be possible for them to
show up in `-ast-print` output?
https://github.com/llvm/llvm-project/pull/206579
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits