[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen

Csaba Dabis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 18 16:12:58 PDT 2018


Charusso marked 14 inline comments as done.
Charusso added inline comments.


================
Comment at: clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp:226
+    DiagnosticBuilder &Diag) {
+  if (getLangOpts().CPlusPlus11) {
+    StringRef NewFuncName = (Name[0] != 'w') ? "strncpy_s" : "wcsncpy_s";
----------------
aaron.ballman wrote:
> What about C?
The `else` part would fire.


================
Comment at: test/clang-tidy/bugprone-not-null-terminated-result-strlen-before-cxx11.cpp:11
+void bad_memcpy(char *dest, const char *src) {
+  memcpy(dest, src, strlen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' function's result is not null-terminated [bugprone-not-null-terminated-result]
----------------
lebedev.ri wrote:
> What about these functions, but in `std::` namespace?
It is covered in `test/clang-tidy/bugprone-not-null-terminated-result-strlen-cxx11.cpp`, the test make sure my rename function doesn't touch the `std::` part.


https://reviews.llvm.org/D45050





More information about the cfe-commits mailing list