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