11 #include "clang/AST/ASTContext.h"
12 #include "clang/ASTMatchers/ASTMatchFinder.h"
14 using namespace clang::ast_matchers;
19 void ProTypeUnionAccessCheck::registerMatchers(MatchFinder *
Finder) {
20 if (!getLangOpts().CPlusPlus)
23 Finder->addMatcher(memberExpr(hasObjectExpression(hasType(recordDecl(isUnion())))).bind(
"expr"),
this);
26 void ProTypeUnionAccessCheck::check(
const MatchFinder::MatchResult &
Result) {
27 const auto *Matched = Result.Nodes.getNodeAs<MemberExpr>(
"expr");
28 diag(Matched->getMemberLoc(),
"do not access members of unions; use (boost::)variant instead");
std::unique_ptr< ast_matchers::MatchFinder > Finder