HelpText<"Check for logical errors for function calls and Objective-C message expressions (e.g., uninitialized arguments, null function pointers)">,
DescFile<"CallAndMessageChecker.cpp">;
-def AttrNonNullChecker : Checker<"AttributeNonNull">,
- HelpText<"Check for null pointers passed as arguments to a function whose arguments are marked with the 'nonnull' attribute">,
- DescFile<"AttrNonNullChecker.cpp">;
+def NonNullParamChecker : Checker<"NonNullParamChecker">,
+ HelpText<"Check for null pointers passed as arguments to a function whose arguments are references or marked with the 'nonnull' attribute">,
+ DescFile<"NonNullParamChecker.cpp">;
def VLASizeChecker : Checker<"VLASize">,
HelpText<"Check for declarations of VLA of undefined or zero size">,
-//===--- AttrNonNullChecker.h - Undefined arguments checker ----*- C++ -*--===//
+//===--- NonNullParamChecker.cpp - Undefined arguments checker -*- C++ -*--===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
//
-// This defines AttrNonNullChecker, a builtin check in ExprEngine that
-// performs checks for arguments declared to have nonnull attribute.
+// This defines NonNullParamChecker, which checks for arguments expected not to
+// be null due to:
+// - the corresponding parameters being declared to have nonnull attribute
+// - the corresponding parameters being references; since the call would form
+// a reference to a null pointer
//
//===----------------------------------------------------------------------===//
using namespace ento;
namespace {
-class AttrNonNullChecker
+class NonNullParamChecker
: public Checker< check::PreCall > {
mutable OwningPtr<BugType> BTAttrNonNull;
mutable OwningPtr<BugType> BTNullRefArg;
};
} // end anonymous namespace
-void AttrNonNullChecker::checkPreCall(const CallEvent &Call,
+void NonNullParamChecker::checkPreCall(const CallEvent &Call,
CheckerContext &C) const {
const Decl *FD = Call.getDecl();
if (!FD)
C.addTransition(state);
}
-BugReport *AttrNonNullChecker::genReportNullAttrNonNull(
+BugReport *NonNullParamChecker::genReportNullAttrNonNull(
const ExplodedNode *ErrorNode, const Expr *ArgE) const {
// Lazily allocate the BugType object if it hasn't already been
// created. Ownership is transferred to the BugReporter object once
return R;
}
-BugReport *AttrNonNullChecker::genReportReferenceToNullPointer(
+BugReport *NonNullParamChecker::genReportReferenceToNullPointer(
const ExplodedNode *ErrorNode, const Expr *ArgE) const {
if (!BTNullRefArg)
BTNullRefArg.reset(new BuiltinBug("Dereference of null pointer"));
}
-void ento::registerAttrNonNullChecker(CheckerManager &mgr) {
- mgr.registerChecker<AttrNonNullChecker>();
+void ento::registerNonNullParamChecker(CheckerManager &mgr) {
+ mgr.registerChecker<NonNullParamChecker>();
}