[all-commits] [llvm/llvm-project] 5bbe50: [clang-tidy] Warn on functional C-style casts

Carlos Galvez via All-commits all-commits at lists.llvm.org
Mon Nov 29 23:31:58 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5bbe50148f3b515c170be22209395b72890f5b8c
      https://github.com/llvm/llvm-project/commit/5bbe50148f3b515c170be22209395b72890f5b8c
  Author: Carlos Galvez <carlosgalvezp at gmail.com>
  Date:   2021-11-30 (Tue, 30 Nov 2021)

  Changed paths:
    M clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
    M clang-tools-extra/docs/ReleaseNotes.rst
    M clang-tools-extra/test/clang-tidy/checkers/google-readability-casting.cpp

  Log Message:
  -----------
  [clang-tidy] Warn on functional C-style casts

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.

Differential Revision: https://reviews.llvm.org/D114427




More information about the All-commits mailing list