[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen(), size() or equal length

Csaba Dabis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 28 13:50:17 PDT 2018


Charusso updated this revision to Diff 162942.
Charusso marked an inline comment as done.
Charusso retitled this revision from "[clang-tidy] New checker for not null-terminated result caused by strlen or wcslen" to "[clang-tidy] New checker for not null-terminated result caused by strlen(), size() or equal length".
Charusso edited the summary of this revision.
Charusso added a comment.

- The checker by default search for `__STDC_WANT_LIB_EXT1__` macro to determine if `_s` suffixed functions are available. This behaviour could be overridden by specifying `AreSafeFunctionsAvailable`, which is became a string (it was an integer, but it can be used in the same way).

- If the destination array length is based on a custom `malloc()` the current approach only want to rewrite it if it is 100% sure the chosen argument is specifying the length.

- If the checker works with `size()` function now it is only match for `std::string` (e.g. it matched to StringRefs).

- Now it handles macro defined lengths properly.


https://reviews.llvm.org/D45050

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
  clang-tidy/bugprone/NotNullTerminatedResultCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-not-null-terminated-result-in-initialization-strlen.c
  test/clang-tidy/bugprone-not-null-terminated-result-memcpy-before-safe.c
  test/clang-tidy/bugprone-not-null-terminated-result-memcpy-safe-cxx.cpp
  test/clang-tidy/bugprone-not-null-terminated-result-memcpy-safe-other.c
  test/clang-tidy/bugprone-not-null-terminated-result-memcpy-safe.c
  test/clang-tidy/bugprone-not-null-terminated-result-strlen.c
  test/clang-tidy/bugprone-not-null-terminated-result-wcslen.cpp
  test/clang-tidy/bugprone-not-null-terminated-result-wmemcpy-safe-cxx.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45050.162942.patch
Type: text/x-patch
Size: 90825 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180828/cad1f4fb/attachment-0001.bin>


More information about the cfe-commits mailing list