================
@@ -1450,6 +1480,17 @@ void
Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
}
}
DestinationSize = ComputeSizeArgument(0);
+ const Expr *SizeOfArg = TheCall->getArg(1)->IgnoreParenImpCasts();
+ const Expr *Dest = TheCall->getArg(0)->IgnoreParenImpCasts();
+ const Expr *SizeOfArgExpr = getSizeOfExprArg(SizeOfArg);
+ const QualType SizeOfArgType = getSizeOfArgType(SizeOfArg);
+ const Type *ExprType = SizeOfArgType.getTypePtrOrNull();
+ if (ExprType && ExprType->isPointerType() &&
+ referToTheSameDecl(SizeOfArgExpr, Dest)) {
+ DiagRuntimeBehavior(SizeOfArg->getExprLoc(), Dest,
+ PDiag(diag::warn_sizeof_pointer_dest_type_memacess)
+ << FD->getNameInfo().getName());
+ }
----------------
ojhunt wrote:
Rather than a reimplementation of similar semantics we should consider
refactoring the existing checks so they can be used here instead.
https://github.com/llvm/llvm-project/pull/170637
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits