[PATCH] D4784: [clang-tidy] Add check for possibly incomplete switch statements

Piotr Zegar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 16 06:37:20 PDT 2023


PiotrZSL added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.cpp:19
+  Finder->addMatcher(
+      switchStmt(has(implicitCastExpr().bind("cast")),
+                 unless(hasAncestor(switchStmt(has(defaultStmt())))))
----------------
xgupta wrote:
> PiotrZSL wrote:
> > this should be something like:
> > ```hasCondition(expr(hasType(qualType(hasCanonicalType(unless(hasDeclaration(enumDecl()))))))```
> > Or you can verify just if type is integral type.
> > Note that with modern C++ you may have init statements in enums.
> > 
> For some reason, the check is giving warning for enum cases and I couldn't understand why, can you please help?
Add getCheckTraversalKind and check again....


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D4784



More information about the cfe-commits mailing list