[clang] [clang-tools-extra] Add function check for windows platform (PR #106581)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 30 00:47:33 PDT 2024


================
@@ -150,6 +150,8 @@ class CStringChecker : public Checker< eval::Call,
       // FIXME: C23 introduces 'memset_explicit', maybe also model that
       {{CDM::CLibraryMaybeHardened, {"strcpy"}, 2},
        &CStringChecker::evalStrcpy},
+      {{CDM::CLibraryMaybeHardened, {"lstrcpy"}, 2},
----------------
NagyDonat wrote:

```suggestion
      {{CDM::CLibrary, {"lstrcpy"}, 2},
```
The matching mode `CLibraryMaybeHardened` was introduced to also recognize references to the "hardened" function variants that are named like `_strcpy_chk` or `__builtin___strcpy_chk` (and may have one or two additional parameters compared to the "regular" function). As `lstrcpy` does not have a hardened variant (according to a google search that produced zero results), we should simply match it with `CDM::CLibrary`.
In this case the plain `CLibrary` matching mode is enough, because 


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


More information about the cfe-commits mailing list