[PATCH] D104887: [clang] Evaluate strlen of strcpy argument for -Wfortify-source.

Michael Benfield via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 16 15:15:12 PDT 2021


mbenfield added inline comments.


================
Comment at: clang/lib/Sema/SemaChecking.cpp:739
     DiagID = diag::warn_fortify_source_size_mismatch;
-    SizeIndex = TheCall->getNumArgs() - 1;
-    ObjectIndex = 0;
+    SourceSize = ComputeCheckVariantSize(TheCall->getNumArgs() - 1);
+    DestinationSize = ComputeSizeArgument(0);
----------------
george.burgess.iv wrote:
> i expected `ComputeCheckVariantSize` to imply that the argument was to a `_chk` function, but these `case`s don't reference `_chk` functions (nor do we set `IsChkVariant = true;`). should this be calling `ComputeSizeArgument` instead?
Maybe the name `ComputeCheckVariantSize` was misleading and it'll be more clear now that I'm changing the name, but these functions like `strncat`, the `memcpy`s below, and `snprintf`, etc, all take an explicit size argument just like the `_chk` functions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104887/new/

https://reviews.llvm.org/D104887



More information about the cfe-commits mailing list