[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-21 Thread Balogh, Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rGfccd0da5ee6f: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc (authored by baloghadamsoftware). Changed prior to commit: https://reviews.llvm.org/D71001?vs=239103=239290#toc

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-21 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment. In D71001#1830792 , @gribozavr2 wrote: > Let me know if you want me to commit this change for you. Thank you! I will commit it today. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71001/new/

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-21 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment. Let me know if you want me to commit this change for you. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71001/new/ https://reviews.llvm.org/D71001 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-20 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 239103. baloghadamsoftware added a comment. Updated according to the comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71001/new/ https://reviews.llvm.org/D71001 Files:

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-20 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 5 inline comments as done. baloghadamsoftware added a comment. Hello, Thank you for your useful comments. I think I fixed them all now. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71001/new/ https://reviews.llvm.org/D71001

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-17 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment. Since I seem to be in the minority about thinking that this check does not pull its weight, I reviewed the code, and will LGTM and push once the few small issues are fixed. Comment at:

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-16 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 238528. baloghadamsoftware added a comment. Indentation of the code fixed in the documentation. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71001/new/ https://reviews.llvm.org/D71001 Files:

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-16 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments. Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-pointer-arithmetic-in-alloc.rst:15 + +void bad_malloc(int n) { + char *p = (char*) malloc(n) + 10; Identification. I think 2 character should

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-16 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 238451. baloghadamsoftware marked an inline comment as done. baloghadamsoftware added a comment. Rebased. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71001/new/ https://reviews.llvm.org/D71001 Files:

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-09 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp:81-82 + diag(PtrArith->getBeginLoc(), + "pointer arithmetic is applied to the result of %0() instead of its " + "argument") + <<

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-06 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 5 inline comments as done. baloghadamsoftware added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp:81-82 + diag(PtrArith->getBeginLoc(), + "pointer arithmetic is applied to the

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-06 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 232573. baloghadamsoftware added a comment. Updated according to the comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71001/new/ https://reviews.llvm.org/D71001 Files:

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-05 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment. While I can't pitch in with actual findings of this check, @MyDeveloperDay, you're right in many aspects, including those specific examples //not// firing. But an example that actually fires this check indicates a very specific **undefined behaviour** case. So if

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment. Drive by comment: (I have no vested interested other than seeing cool new checkers) FWIW, I work on a system with a multi million line legacy 25+ years old C++ codebase, where we now have clang-tidy integrated into a CI system and we have > 100,000 firings of

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment. This might be a strange argument, but I did see this happen several times at different companies. When a company tries to decide which lint tools to use they are doing an evaluation. Usually, people doing the evaluation are not compiler/static analysis devs. Given

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D71001#1769048 , @gribozavr2 wrote: > In D71001#1769035 , @Eugene.Zelenko > wrote: > > > > ASan can help debug this issue, and more. > > > > This is dynamic analysis, and

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment. In D71001#1769429 , @gribozavr2 wrote: > In D71001#1769394 , @Eugene.Zelenko > wrote: > > > With such logic, Clang-tidy is maintenance burden: 368 unaddressed request > > in

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment. In D71001#1769394 , @Eugene.Zelenko wrote: > With such logic, Clang-tidy is maintenance burden: 368 unaddressed request in > Bugzilla is very telling. Doesn't that just prove the point that we already have a problem with

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment. In D71001#1769382 , @gribozavr2 wrote: > In D71001#1769071 , > @baloghadamsoftware wrote: > > > In D71001#1769018 , @gribozavr2 > > wrote:

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment. In D71001#1769071 , @baloghadamsoftware wrote: > In D71001#1769018 , @gribozavr2 > wrote: > > > ASan can help debug this issue, and more. > > > ASan is too heavyweight for this simple

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment. In D71001#1769018 , @gribozavr2 wrote: > ASan can help debug this issue, and more. ASan is too heavyweight for this simple problem. It does not point out the source of the issue as quickly as this simple check which

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment. In D71001#1769018 , @gribozavr2 wrote: > This check is quite limited. For example, if the addition is done in a > separate statement, this check wouldn't catch the problem. ASan would. That is not a simple and common

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment. In D71001#1769035 , @Eugene.Zelenko wrote: > > ASan can help debug this issue, and more. > > This is dynamic analysis, and detection of problem depends on test case. > Detection of such problem during static analysis makes

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment. In D71001#1768964 , @baloghadamsoftware wrote: > In D71001#1768704 , @Eugene.Zelenko > wrote: > > > What about new operator? May be check should have option for custom > >

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment. > ASan can help debug this issue, and more. This is dynamic analysis, and detection of problem depends on test case. Detection of such problem during static analysis makes sense. Repository: rCTE Clang Tools Extra CHANGES SINCE LAST ACTION

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment. In D71001#1768963 , @baloghadamsoftware wrote: > In D71001#1768880 , @gribozavr2 > wrote: > > > Is this a common problem? There's a lot of silly code we could try to find, > > but if

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment. In D71001#1768704 , @Eugene.Zelenko wrote: > What about new operator? May be check should have option for custom > allocators? Do you mean `new[]`. Thus e.g. `const *carr = new C[n] + 10;` instead of `const *carr =

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment. In D71001#1768880 , @gribozavr2 wrote: > Is this a common problem? There's a lot of silly code we could try to find, > but if people don't actually write it, then we get all downsides of > maintenance without the

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment. Is this a common problem? There's a lot of silly code we could try to find, but if people don't actually write it, then we get all downsides of maintenance without the benefits of the checker. Repository: rCTE Clang Tools Extra CHANGES SINCE LAST ACTION

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment. What about new operator? May be check should have option for custom allocators? Comment at: clang-tools-extra/docs/ReleaseNotes.rst:207 +- New :doc:`bugprone-misplaced-pointer-arithmetic-in-alloc + ` check. Please move to new

[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2019-12-04 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision. baloghadamsoftware added reviewers: alexfh, aaron.ballman, gribozavr. baloghadamsoftware added a project: clang-tools-extra. Herald added subscribers: mgehre, Szelethus, rnkovacs, xazax.hun, whisperity, mgorny. Herald added a project: clang. Finds cases