[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-02-07 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGc63522e6ba77: [clang-tidy] Add new check 'shared-ptr-array-mismatch'. (authored by balazske). Changed prior to commit: https://reviews.llvm.org/D1

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-02-04 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood accepted this revision. LegalizeAdulthood added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D117306/new/ https://reviews.llvm.org/D117306 _

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-02-04 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 405971. balazske added a comment. Code simplification. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D117306/new/ https://reviews.llvm.org/D117306 Files: clang-tools-extra/clang-tidy/bugprone/BugproneTidyMod

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-02-04 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done. balazske added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.h:40 + /// in this class. + virtual SmartPtrClassMatcher getSmartPointerClassMatcher() const = 0; + njames93

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-02-03 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp:41-47 + const Decl *ParentDecl = ConstructParents.begin()->get(); + if (!ParentDecl) +return nullptr; + if (const auto *ParentVar = dyn_cast(ParentDecl)) +

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-02-02 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.h:40 + /// in this class. + virtual SmartPtrClassMatcher getSmartPointerClassMatcher() const = 0; + There's only one implementation of this ab

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-01-24 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 402439. balazske added a comment. Fixed small issues. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D117306/new/ https://reviews.llvm.org/D117306 Files: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModu

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-01-19 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments. Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone-shared-ptr-array-mismatch.rst:22 + std::shared_ptr x(new Foo[10]); // -> std::shared_ptr x(new Foo[10]); + // ^ warning: shared pointer to non-array is initialize

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-01-18 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment. Possible improvement: Add the check for `reset` too. Comment at: clang-tools-extra/test/clang-tidy/checkers/modernize-make-shared.cpp:48 void basic() { + std::shared_ptr Pt1(new int[22]); + This change was not intentional (should be

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-01-18 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 400791. balazske added a comment. - Moved to bugprone module. - Introduced a common base class, it is possible to add similar check for unique_ptr. - Documentation changes. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-01-17 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment. LGTM, but there are still some outstanding review comments. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D117306/new/ https://reviews.llvm.org/D117306 ___ cfe-commits m

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-01-17 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 2 inline comments as done. balazske added a comment. In D117306#3247859 , @njames93 wrote: > In D117306#3247417 , > @LegalizeAdulthood wrote: > >> In D117306#3245915

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-01-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment. In D117306#3247417 , @LegalizeAdulthood wrote: > In D117306#3245915 , @njames93 > wrote: > >> How does this check play with the `modernize-make-shared` check? > > Wouldn't it be orthogo

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-01-17 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment. Is there a fast way to find single-variable field declaration? class A { shared_ptr F1{new int}, F2{new int[10]}; }; The `FieldDecl` does not contain information like `DeclStmt::isSingleDecl`. The only way looks like to check the source locations. Repository:

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-01-17 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment. I am not sure if it is correct to have replacement (fixit) for a part of the cases only. It is not possible to make a fixit for every use. In a case like `shared_ptr p1{new int}, p2{new int[10]};` the type can not be changed without other changes. For this reason the r

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-01-16 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment. In D117306#3245915 , @njames93 wrote: > How does this check play with the `modernize-make-shared` check? Wouldn't it be orthogonal? This check looks for existing `make_shared` usages, whereas modernize-make-shared adds

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-01-16 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/clang-tidy/misc/SharedPtrArrayMismatchCheck.cpp:21-26 +SharedPtrArrayMismatchCheck::SharedPtrArrayMismatchCheck( +StringRef Name, ClangTidyContext *Context) +: ClangTidyCheck(Name, Context) {} + +void

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-01-15 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment. How does this check play with the `modernize-make-shared` check? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D117306/new/ https://reviews.llvm.org/D117306 ___ cfe-commits maili

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-01-14 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment. I think this check belongs to `bugprone` module. How about `std::unique_ptr`? Comment at: clang-tools-extra/clang-tidy/misc/SharedPtrArrayMismatchCheck.cpp:1 +//===--- SharedPtrArrayMismatchCheck.cpp - clang-tidy +//--===// --

[PATCH] D117306: [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-01-14 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision. Herald added subscribers: carlosgalvezp, steakhal, martong, gamesh411, Szelethus, dkrupp, xazax.hun, mgorny. balazske requested review of this revision. Herald added a project: clang-tools-extra. Herald added a subscriber: cfe-commits. Repository: rG LLVM Github