10#include "clang/AST/ASTContext.h"
11#include "clang/ASTMatchers/ASTMatchFinder.h"
18 Finder->addMatcher(callExpr(callee(functionDecl(namedDecl(hasName(
"::rand")),
19 parameterCountIs(0))))
20 .bind(
"randomGenerator"),
27 Msg =
"; use C++11 random library instead";
29 const auto *MatchedDecl = Result.Nodes.getNodeAs<CallExpr>(
"randomGenerator");
30 diag(MatchedDecl->getBeginLoc(),
"rand() has limited randomness" + Msg);
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
const LangOptions & getLangOpts() const
Returns the language options from the context.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.