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

Eugene Zelenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 29 11:10:52 PDT 2018


Eugene.Zelenko added inline comments.


================
Comment at: clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp:21
+
+std::string exprToStr(const Expr *Expr,
+                      const MatchFinder::MatchResult &Result) {
----------------
Please make it static. Same for other functions.


================
Comment at: clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp:56
+          FuncExpr->getArg(ArgPos)->IgnoreParenCasts())) {
+    const auto LHSStr = exprToStr(BinOp->getLHS()->IgnoreParens(), Result);
+    const auto RHSStr = exprToStr(BinOp->getRHS()->IgnoreParens(), Result);
----------------
Please don't use auto when type could not be deduced from statement itself (new, cast, iterator). Same for other places.


================
Comment at: docs/ReleaseNotes.rst:62
 
+- New `bugprone-not-null-terminated-result
+  <http://clang.llvm.org/extra/clang-tidy/checks/bugprone-not-null-terminated-result.html>`_ check
----------------
Please rebase for trunk, place check in alphabetical order in new checks list, use //:doc:// and proper link.


================
Comment at: docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst:4
+bugprone-not-null-terminated-result
+=========================================
+
----------------
Is length same as length of title?


================
Comment at: docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst:6
+
+This check can be used to find function calls where ``strlen`` or ``wcslen``
+are passed as an argument and cause a not null-terminated result. Depending on
----------------
Please synchronize with statement in Release Notes.


================
Comment at: docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst:29
+
+In addition to issuing warnings, "Fix-it" rewrite all the necessary code
+depending on the version number. The upper code would be the following:
----------------
Please use fix-it. Same for other places.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45050





More information about the cfe-commits mailing list