xazax.hun added inline comments.
================ Comment at: clang-tidy/misc/MisplacedOperatorInStrlenInAllocCheck.cpp:30 + Finder->addMatcher( + callExpr(callee(functionDecl(hasName("malloc"))), + hasArgument(0, anyOf(hasDescendant(BadUse), BadUse))) ---------------- Maybe it is worth to have a configurable list of allocation functions? Maybe it would be worth to support`alloca` as well? ================ Comment at: clang-tidy/misc/MisplacedOperatorInStrlenInAllocCheck.cpp:44 + const MatchFinder::MatchResult &Result) { + // FIXME: Add callback implementation. + const auto *Alloc = Result.Nodes.getNodeAs<CallExpr>("Alloc"); ---------------- What is this fixme? ================ Comment at: clang-tidy/misc/MisplacedOperatorInStrlenInAllocCheck.h:19 + +/// FIXME: Write a short description. +/// ---------------- There is a missing description. ================ Comment at: docs/clang-tidy/checks/misc-misplaced-operator-in-strlen-in-alloc.rst:16 + void bad_malloc(char *str) { + char *c = (char*) malloc(strlen(str + 1)); + } ---------------- What if this code is intentional for some reason? I think in thase case it could be rewritten like the following (which is much cleaner): ``` char *c = (char*) malloc(strlen(str)-1); ``` I think it might be a good idea to mention this possibility as a way to suppress this warning in the documentation. https://reviews.llvm.org/D39121 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits