[PATCH] D4784: [clang-tidy] Add check for possibly incomplete switch statements
Shivam Gupta via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 16 10:19:42 PDT 2023
xgupta 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())))))
----------------
PiotrZSL wrote:
> 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....
Wow, feel like a magic!
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