[PATCH] D60139: [clang-tidy] Add bugprone-placement-new-target-type-mismatch check

Dennis Luxen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 10 06:37:47 PDT 2019


DennisL marked 12 inline comments as done.
DennisL added a comment.

In D60139#1460233 <https://reviews.llvm.org/D60139#1460233>, @JonasToth wrote:

> Hey Dennis,
>
> my 2cents on the check. I think it is very good to have! Did you check coding guidelines if they say something to this issue? (e.g. cppcoreguidelines, hicpp, cert) As we have modules for them it would be great to make aliases to this check if they demand this to be checked.


Thanks for the great suggestions. Updated the diff according to the feedback. Also checked with cppcoreguidelines, hicpp as well as cert. Only cert has a related, yet different rule <https://wiki.sei.cmu.edu/confluence/display/cplusplus/MEM54-CPP.+Provide+placement+new+with+properly+aligned+pointers+to+sufficient+storage+capacity> stating that calls to placement new shall be provided with properly aligned pointers. I'd say this should be a distinct check. Happy to work on it after this one.



================
Comment at: clang-tidy/bugprone/PlacementNewTargetTypeMismatch.cpp:42
+
+  assert((Cast->getSubExpr()->getType()->isPointerType() ||
+         Cast->getSubExpr()->getType()->isArrayType()) &&
----------------
JonasToth wrote:
> Is this universally true? What about the nothrow-overload, would that interfere?
Thanks, rewrote that check.


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

https://reviews.llvm.org/D60139





More information about the cfe-commits mailing list