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

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 29 09:31:29 PST 2021


Quuxplusone added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp:101-110
+static StringRef getDestTypeString(const SourceManager &SM,
+                                   const LangOptions &LangOpts,
+                                   const ExplicitCastExpr *CastExpr) {
+  return isa<CStyleCastExpr>(CastExpr)
+             ? getDestTypeString(SM, LangOpts,
+                                 dyn_cast<const CStyleCastExpr>(CastExpr))
+             : getDestTypeString(
----------------
I actually meant to move the conditional //inside// the body, like this. ^
Now there's only one function, and the reader doesn't have to do mental overload resolution to figure out what the caller's behavior is intended to be.



================
Comment at: clang-tools-extra/test/clang-tidy/checkers/google-readability-casting.cpp:318
   // FIXME: This should be a static_cast.
   // C HECK-FIXES: auto s5 = static_cast<const S&>(cr);
   auto s6 = (S)cr;
----------------
Pre-existing: This looks accidental.


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

https://reviews.llvm.org/D114427



More information about the cfe-commits mailing list