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

Salman Javed via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 29 12:11:25 PST 2021


salman-javed-nz added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp:63-73
+static clang::CharSourceRange getReplaceRange(const ExplicitCastExpr *Expr) {
+  if (const auto *CastExpr = dyn_cast<CStyleCastExpr>(Expr)) {
+    return CharSourceRange::getCharRange(
+        CastExpr->getLParenLoc(),
+        CastExpr->getSubExprAsWritten()->getBeginLoc());
+  } else if (const auto *CastExpr = dyn_cast<CXXFunctionalCastExpr>(Expr)) {
+    return CharSourceRange::getCharRange(CastExpr->getBeginLoc(),
----------------
Looks much better than my suggested change. Good stuff.


================
Comment at: clang-tools-extra/docs/ReleaseNotes.rst:139
 
+- Updated ``google-readability-casting`` to diagnose and fix functional casts, to achieve feature
+  parity with the corresponding ``cpplint.py`` check.
----------------
Should this be like the
```
:doc:`bugprone-suspicious-memory-comparison
  <clang-tidy/checks/bugprone-suspicious-memory-comparison>`
```
a few lines above.


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

https://reviews.llvm.org/D114427



More information about the cfe-commits mailing list