#include "clang/AST/Attr.h"
#include "clang/Analysis/AnyCall.h"
#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "llvm/ADT/StringExtras.h"
usingnamespaceclang;
usingnamespaceento;
namespace {
class NonNullParamChecker
: public Checker<check::PreCall, check::BeginFunction,
EventDispatcher<ImplicitNullDerefEvent>> { … };
template <class CallType>
void setBitsAccordingToFunctionAttributes(const CallType &Call,
llvm::SmallBitVector &AttrNonNull) { … }
template <class CallType>
void setBitsAccordingToParameterAttributes(const CallType &Call,
llvm::SmallBitVector &AttrNonNull) { … }
template <class CallType>
llvm::SmallBitVector getNonNullAttrsImpl(const CallType &Call,
unsigned ExpectedSize) { … }
llvm::SmallBitVector getNonNullAttrs(const CallEvent &Call) { … }
llvm::SmallBitVector getNonNullAttrs(const AnyCall &Call) { … }
}
void NonNullParamChecker::checkPreCall(const CallEvent &Call,
CheckerContext &C) const { … }
void NonNullParamChecker::checkBeginFunction(CheckerContext &Context) const { … }
std::unique_ptr<PathSensitiveBugReport>
NonNullParamChecker::genReportNullAttrNonNull(const ExplodedNode *ErrorNode,
const Expr *ArgE,
unsigned IdxOfArg) const { … }
std::unique_ptr<PathSensitiveBugReport>
NonNullParamChecker::genReportReferenceToNullPointer(
const ExplodedNode *ErrorNode, const Expr *ArgE) const { … }
void ento::registerNonNullParamChecker(CheckerManager &mgr) { … }
bool ento::shouldRegisterNonNullParamChecker(const CheckerManager &mgr) { … }