[clang] [Clang][Sema] Add -Wstringop-overread warning for source buffer overreads (PR #183004)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 24 14:58:20 PST 2026
================
@@ -1414,16 +1479,47 @@ void Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
case Builtin::BImempcpy:
case Builtin::BI__builtin_mempcpy: {
DiagID = diag::warn_fortify_source_overflow;
- SourceSize = ComputeExplicitObjectSizeArgument(TheCall->getNumArgs() - 1);
- DestinationSize = ComputeSizeArgument(0);
+ SourceSize =
+ Checker.ComputeExplicitObjectSizeArgument(TheCall->getNumArgs() - 1);
+ DestinationSize = Checker.ComputeSizeArgument(0);
+
+ // Buffer overread doesn't make sense for memset.
+ if (BuiltinID != Builtin::BImemset &&
+ BuiltinID != Builtin::BI__builtin_memset) {
+ checkSourceBufferOverread(FD, TheCall, /*SrcArgIdx=*/1, /*SizeArgIdx=*/2,
----------------
erichkeane wrote:
Same here.
https://github.com/llvm/llvm-project/pull/183004
More information about the cfe-commits
mailing list