[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
Sat Sep 29 06:38:41 PDT 2018


Charusso updated this revision to Diff 167597.
Charusso marked 37 inline comments as done.
Charusso edited the summary of this revision.
Charusso added a comment.

Thanks for the very in-depth review @aaron.ballman!

I have not found a way to obtain the instance of Preprocessor nicely, but it is working well. Changes:

- Huge refactor `.`
- Macro definition checking is rely on Preprocessor.
- `isUnjectUL()` is now a function, not a static variable.
- `WantToUseSafeFunctions` is the new integer specifying the `AreSafeFunctionsAvailable` variable without the override feature rely on the necessary macros has been defined.
- Added a test case in `bugprone-not-null-terminated-result-memcpy-before-safe.c` if the user wants to use safe functions but it is unavailable.
- Extra: the LOC is now a round number.


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.167597.patch
Type: text/x-patch
Size: 92753 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180929/05c07db0/attachment-0001.bin>


More information about the cfe-commits mailing list