[PATCH] D114427: [clang-tidy] Warn on functional C-style casts

Carlos Galvez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 23 02:56:12 PST 2021


carlosgalvezp created this revision.
Herald added a subscriber: xazax.hun.
carlosgalvezp requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

The google-readability-casting check is meant to be on par
with cpplint's readability/casting check, according to the
documentation. However it currently does not diagnose
functional casts, like:

float x = 1.5F;
int y = int(x);

This is detected by cpplint, however, and the guidelines
are clear that such a cast is only allowed when the type
is a class type (constructor call):

> You may use cast formats like `T(x)` only when `T` is a class type.

Therefore, update the clang-tidy check to check this
case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114427

Files:
  clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/google-readability-casting.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114427.389142.patch
Type: text/x-patch
Size: 6934 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211123/5f4c1df7/attachment.bin>


More information about the cfe-commits mailing list