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

Balázs Kéri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 4 07:41:00 PST 2022


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 wrote:
> LegalizeAdulthood wrote:
> > There's only one implementation of this abstract method declared here.
> > 
> > Why the extra level in the class hierarchy if there's only one implementation?
> The idea I think is so that this can be used to make a similar check for `unique_ptr`. However I almost don't see the need for this, and I'd argue that they should both be implemented in one check. So this will detect 
> ```lang=c++
> std::shared_ptr<int> X = new int[5];
> std::unique_ptr<int> Y = new int[5];
> ```
If I remember correctly the idea was to make the possible check for `unique_ptr`. Putting it into a separate check allows to independently turn the checks for shared or unique pointer on or off (like `MakeSmartPtrCheck`).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117306/new/

https://reviews.llvm.org/D117306



More information about the cfe-commits mailing list