10#include "clang/AST/ASTContext.h"
11#include "clang/ASTMatchers/ASTMatchFinder.h"
19 memberExpr(hasObjectExpression(hasType(recordDecl(isUnion()))))
25 const auto *Matched = Result.Nodes.getNodeAs<MemberExpr>(
"expr");
26 SourceLocation
Loc = Matched->getMemberLoc();
28 Loc = Matched->getBeginLoc();
29 diag(
Loc,
"do not access members of unions; consider using (boost::)variant "
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.