[PATCH] D76572: Replace `T(x)` with `reinterpret_cast<T>(x)` everywhere it means reinterpret_cast. No functional change

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 23 07:36:32 PDT 2020


Quuxplusone added a comment.

In D76572#1936191 <https://reviews.llvm.org/D76572#1936191>, @grandinj wrote:

> Libreoffice has a similar clang-tidy-style cast-checker [for C-style casts] here:
>
> https://cgit.freedesktop.org/libreoffice/core/tree/compilerplugins/clang/cstylecast.cxx
>  https://cgit.freedesktop.org/libreoffice/core/tree/compilerplugins/clang/test/cstylecast.cxx


Nice. Does LibreOffice have anything (either in clang-tidy or in a paper guideline) against `T(x)`-style casts? E.g.

  struct PB {};
  struct D : private PB {};
  using FloatRef = float&;
  using IntPtr = int*;
  using PBPtr = PB*;
  int i = 42;
  const int *cpi = &i;
  D *pd = nullptr;
  float& f = FloatRef(i);  // reinterpret_cast
  int *pi = IntPtr(cpi);  // const_cast
  PB *pb = PBPtr(pd);  // cast to private base


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76572





More information about the cfe-commits mailing list