11 #include "clang/AST/ASTContext.h" 12 #include "clang/ASTMatchers/ASTMatchFinder.h" 20 void LimitedRandomnessCheck::registerMatchers(MatchFinder *Finder) {
21 Finder->addMatcher(callExpr(callee(functionDecl(namedDecl(hasName(
"::rand")),
22 parameterCountIs(0))))
23 .bind(
"randomGenerator"),
27 void LimitedRandomnessCheck::check(
const MatchFinder::MatchResult &
Result) {
29 if (getLangOpts().CPlusPlus)
30 msg =
"; use C++11 random library instead";
32 const auto *MatchedDecl = Result.Nodes.getNodeAs<CallExpr>(
"randomGenerator");
33 diag(MatchedDecl->getBeginLoc(),
"rand() has limited randomness" + msg);
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//