10#include "clang/AST/ASTContext.h"
11#include "clang/ASTMatchers/ASTMatchFinder.h"
19 return Node.getParent()->isLambda();
25 Finder->addMatcher(fieldDecl(unless(isMemberOfLambda()),
26 hasType(hasCanonicalType(referenceType())))
29 Finder->addMatcher(fieldDecl(unless(isMemberOfLambda()),
30 hasType(qualType(isConstQualified())))
36 const MatchFinder::MatchResult &Result) {
37 if (
const auto *MatchedDecl = Result.Nodes.getNodeAs<FieldDecl>(
"ref"))
38 diag(MatchedDecl->getLocation(),
"member %0 of type %1 is a reference")
39 << MatchedDecl << MatchedDecl->getType();
40 if (
const auto *MatchedDecl = Result.Nodes.getNodeAs<FieldDecl>(
"const"))
41 diag(MatchedDecl->getLocation(),
"member %0 of type %1 is const qualified")
42 << MatchedDecl << MatchedDecl->getType();
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
AST_MATCHER(FieldDecl, hasIntBitwidth)