[PATCH] D151431: [clang-tidy] Add check bugprone-unique-ptr-array-mismatch.

Piotr Zegar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 26 09:02:33 PDT 2023


PiotrZSL accepted this revision.
PiotrZSL added a comment.

In D151431#4376181 <https://reviews.llvm.org/D151431#4376181>, @balazske wrote:

> Maybe we can remove the warning in all cases when the type is a POD type (or add a check option)?

**Leave it... **From a user perspective, it doesn't mater if type is POD or not.
I was mentioning non POD just because this is one of "undefined behavior" that sometimes is well defined.
But you don't know if project isn't using some custom new[]/delete[]



================
Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone/unique-ptr-array-mismatch.rst:24
+  std::unique_ptr<Foo> x(new Foo[10]); // -> std::unique_ptr<Foo[]> x(new Foo[10]);
+  //                     ^ warning: unique pointer to non-array is initialized with array [bugprone-unique-ptr-array-mismatch]
+  std::unique_ptr<Foo> x1(new Foo), x2(new Foo[10]); // no replacement
----------------
remove check name from comment to make it shorter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151431



More information about the cfe-commits mailing list