10#include "clang/AST/ASTContext.h"
19 const SwitchCase *Case =
Node.getSwitchCaseList();
21 if (DefaultStmt::classof(Case))
24 Case = Case->getNextSwitchCase();
32 switchStmt(hasCondition(expr(unless(isInstantiationDependent()),
33 hasType(qualType(hasCanonicalType(
34 unless(hasDeclaration(enumDecl()))))))),
35 unless(hasDefaultCase()))
41 const ast_matchers::MatchFinder::MatchResult &Result) {
42 const auto *Switch = Result.Nodes.getNodeAs<SwitchStmt>(
"switch");
44 diag(Switch->getSwitchLoc(),
"switching on non-enum value without "
45 "default case may not cover all cases");
::clang::DynTypedNode Node
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
AST_MATCHER(clang::VarDecl, hasConstantDeclaration)