11 #include "clang/AST/ASTContext.h" 12 #include "clang/ASTMatchers/ASTMatchFinder.h" 21 AST_MATCHER(CXXRecordDecl, hasDirectVirtualBaseClass) {
22 if (!Node.hasDefinition())
return false;
23 if (!Node.getNumVBases())
return false;
24 for (
const CXXBaseSpecifier &Base : Node.bases())
25 if (Base.isVirtual())
return true;
30 void VirtualInheritanceCheck::registerMatchers(MatchFinder *Finder) {
32 Finder->addMatcher(cxxRecordDecl(hasDirectVirtualBaseClass()).bind(
"decl"),
36 void VirtualInheritanceCheck::check(
const MatchFinder::MatchResult &Result) {
37 if (
const auto *D = Result.Nodes.getNodeAs<CXXRecordDecl>(
"decl"))
38 diag(D->getLocStart(),
"direct virtual inheritance is disallowed");
AST_MATCHER(BinaryOperator, isAssignmentOperator)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//