[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-06-19 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki abandoned this revision. danielmarjamaki added a comment. I will not continue working on this checker Repository: rL LLVM https://reviews.llvm.org/D32346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.or

[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-05-22 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision. alexfh added inline comments. This revision now requires changes to proceed. Comment at: docs/clang-tidy/checks/readability-strlen-argument.rst:20 +char *p = new char[(strlen(s) - 1)] +strcpy(p, s); + JonasToth w

[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-05-22 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments. Comment at: clang-tidy/readability/StrlenArgumentCheck.cpp:23-24 + Finder->addMatcher( + callExpr(anyOf(callee(functionDecl(hasName("::strlen"))), + callee(functionDecl(hasName("std::strlen", + hasAnyArgume

[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-04-25 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments. Comment at: docs/clang-tidy/checks/readability-strlen-argument.rst:8 + +In the example code below the developer probably wanted to make room for an extra char in the allocation but misplaced the addition. + danielmarjamaki wrote:

[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-04-25 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added inline comments. Comment at: docs/clang-tidy/checks/readability-strlen-argument.rst:8 + +In the example code below the developer probably wanted to make room for an extra char in the allocation but misplaced the addition. + JonasToth wrote:

[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-04-25 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment. > #include > void dostuff(const char *P) { > > if (strncmp(P+2,"xyz",3)==0) {} > > } > > Iam not super familiar with C, but the intend of the function is to check the following: P = "foxyz", P2 = "abxyz", P3 = "opxyz", ... And if P matches this kind of st

[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-04-25 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment. I am thinking about making my check more strict so it only warns in allocations. I believe the example code is much more motivating when there is allocation. In https://reviews.llvm.org/D32346#733430, @JonasToth wrote: > My thoughts on the check added. > Have

[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-04-25 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments. Comment at: docs/clang-tidy/checks/readability-strlen-argument.rst:8 + +In the example code below the developer probably wanted to make room for an extra char in the allocation but misplaced the addition. + when the intend was to

[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-04-25 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki updated this revision to Diff 96526. danielmarjamaki added a comment. Fixed review comments. Made code examples and documentation more motivational. Repository: rL LLVM https://reviews.llvm.org/D32346 Files: clang-tidy/readability/CMakeLists.txt clang-tidy/readability/Rea

[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-04-24 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments. Comment at: test/clang-tidy/readability-strlen-argument.cpp:1 +// RUN: %check_clang_tidy %s readability-strlen-argument %t + danielmarjamaki wrote: > JonasToth wrote: > > Same as documentation, maybe a little more telling examples

[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-04-24 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg added inline comments. Comment at: test/clang-tidy/readability-strlen-argument.cpp:11 + X = strlen(Str + 10); + // CHECK-FIXES: {{^}} X = (strlen(Str) - 10);{{$}} + but if any of the first ten chars in Str can be NUL, then the change is bogus? (I guess

[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-04-24 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment. > In https://reviews.llvm.org/D32346#733906, @Eugene.Zelenko wrote: > >> It may be good idea to add check for arguments which taken from C++ >> containers like std::string, std::string_view, etc. > > > Not sure how you want. Do you envision something like: > >

[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-04-24 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment. Thanks for all comments. I am working on fixing them. Updated patch will be uploaded soon. > Have you run it over a big codebase? What is the turnout? I did not see this warning yet. Maybe after fixing the comments (::strlen) there will be a difference. In htt

[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-04-21 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment. It may be good idea to add check for arguments which taken from C++ containers like std::string, std::string_view, etc. Repository: rL LLVM https://reviews.llvm.org/D32346 ___ cfe-commits mailing list cfe-commits@

[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-04-21 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment. Please mention this check in docs/ReleaseNotes.rst (in alphabetical order). Comment at: docs/clang-tidy/checks/readability-strlen-argument.rst:6 + +This checker will detect addition in strlen() argument. Example code: + JonasToth

[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-04-21 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment. My thoughts on the check added. Have you run it over a big codebase? What is the turnout? Comment at: clang-tidy/readability/StrlenArgumentCheck.cpp:23 + Finder->addMatcher( + callExpr(callee(functionDecl(hasName("strlen"))), + has

[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-04-21 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki created this revision. Herald added a subscriber: mgorny. I propose this new readability checker. Repository: rL LLVM https://reviews.llvm.org/D32346 Files: clang-tidy/readability/CMakeLists.txt clang-tidy/readability/ReadabilityTidyModule.cpp clang-tidy/readability/Str