11 #include "clang/AST/ASTContext.h" 12 #include "clang/ASTMatchers/ASTMatchFinder.h" 21 if (!Node.hasDefinition())
return false;
22 if (!Node.getNumVBases())
return false;
23 for (
const CXXBaseSpecifier &Base : Node.bases())
24 if (Base.isVirtual())
return true;
28 void VirtualInheritanceCheck::registerMatchers(MatchFinder *Finder) {
30 Finder->addMatcher(cxxRecordDecl(hasDirectVirtualBaseClass()).bind(
"decl"),
34 void VirtualInheritanceCheck::check(
const MatchFinder::MatchResult &Result) {
35 if (
const auto *D = Result.Nodes.getNodeAs<CXXRecordDecl>(
"decl"))
36 diag(D->getLocStart(),
"direct virtual inheritance is disallowed");
AST_MATCHER(VarDecl, isAsm)