10 #include "clang/AST/ASTContext.h"
11 #include "clang/ASTMatchers/ASTMatchFinder.h"
17 namespace cppcoreguidelines {
19 void ProTypeUnionAccessCheck::registerMatchers(MatchFinder *Finder) {
21 memberExpr(hasObjectExpression(hasType(recordDecl(isUnion()))))
26 void ProTypeUnionAccessCheck::check(
const MatchFinder::MatchResult &Result) {
27 const auto *Matched = Result.Nodes.getNodeAs<MemberExpr>(
"expr");
28 diag(Matched->getMemberLoc(),
29 "do not access members of unions; use (boost::)variant instead");