#include "clang/AST/DeclCXX.h"
#include "clang/AST/ExprCXX.h"
#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "llvm/ADT/StringRef.h"
usingnamespaceclang;
usingnamespaceento;
namespace {
enum class AllocKind { … };
}
namespace llvm {
template <> struct FoldingSetTrait<AllocKind> { … };
}
namespace {
class PointerArithChecker
: public Checker<
check::PreStmt<BinaryOperator>, check::PreStmt<UnaryOperator>,
check::PreStmt<ArraySubscriptExpr>, check::PreStmt<CastExpr>,
check::PostStmt<CastExpr>, check::PostStmt<CXXNewExpr>,
check::PostStmt<CallExpr>, check::DeadSymbols> { … };
}
REGISTER_MAP_WITH_PROGRAMSTATE(…) …
void PointerArithChecker::checkDeadSymbols(SymbolReaper &SR,
CheckerContext &C) const { … }
AllocKind PointerArithChecker::getKindOfNewOp(const CXXNewExpr *NE,
const FunctionDecl *FD) const { … }
const MemRegion *
PointerArithChecker::getPointedRegion(const MemRegion *Region,
CheckerContext &C) const { … }
const MemRegion *PointerArithChecker::getArrayRegion(const MemRegion *Region,
bool &Polymorphic,
AllocKind &AKind,
CheckerContext &C) const { … }
void PointerArithChecker::reportPointerArithMisuse(const Expr *E,
CheckerContext &C,
bool PointedNeeded) const { … }
void PointerArithChecker::initAllocIdentifiers(ASTContext &C) const { … }
void PointerArithChecker::checkPostStmt(const CallExpr *CE,
CheckerContext &C) const { … }
void PointerArithChecker::checkPostStmt(const CXXNewExpr *NE,
CheckerContext &C) const { … }
void PointerArithChecker::checkPostStmt(const CastExpr *CE,
CheckerContext &C) const { … }
void PointerArithChecker::checkPreStmt(const CastExpr *CE,
CheckerContext &C) const { … }
void PointerArithChecker::checkPreStmt(const UnaryOperator *UOp,
CheckerContext &C) const { … }
void PointerArithChecker::checkPreStmt(const ArraySubscriptExpr *SubsExpr,
CheckerContext &C) const { … }
void PointerArithChecker::checkPreStmt(const BinaryOperator *BOp,
CheckerContext &C) const { … }
void ento::registerPointerArithChecker(CheckerManager &mgr) { … }
bool ento::shouldRegisterPointerArithChecker(const CheckerManager &mgr) { … }