]> granicus.if.org Git - clang/commitdiff
[analyzer] Rename AttrNonNullChecker -> NonNullParamChecker
authorAnna Zaks <ganna@apple.com>
Sat, 9 Mar 2013 03:23:14 +0000 (03:23 +0000)
committerAnna Zaks <ganna@apple.com>
Sat, 9 Mar 2013 03:23:14 +0000 (03:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176755 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
lib/StaticAnalyzer/Checkers/CMakeLists.txt
lib/StaticAnalyzer/Checkers/Checkers.td
lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp [moved from lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp with 89% similarity]
test/Analysis/misc-ps-region-store.m

index 26dbb7f2506eb9274deca60d476b06f49c219ea4..fdb6bbbe52268eeeadb6a9bc6a41d802357e8174 100644 (file)
@@ -384,7 +384,7 @@ void CFRetainReleaseChecker::checkPreStmt(const CallExpr *CE,
     return;
 
   // FIXME: The rest of this just checks that the argument is non-null.
-  // It should probably be refactored and combined with AttrNonNullChecker.
+  // It should probably be refactored and combined with NonNullParamChecker.
 
   // Get the argument's value.
   const Expr *Arg = CE->getArg(0);
index 60d1e3e83463fa87e5f8d46b525692a2d858257d..b7df10e7ffbe8c2d5870d3920cc60ddbb48655ef 100644 (file)
@@ -7,7 +7,6 @@ add_clang_library(clangStaticAnalyzerCheckers
   AnalyzerStatsChecker.cpp
   ArrayBoundChecker.cpp
   ArrayBoundCheckerV2.cpp
-  AttrNonNullChecker.cpp
   BasicObjCFoundationChecks.cpp
   BoolAssignmentChecker.cpp
   BuiltinFunctionChecker.cpp
@@ -43,6 +42,7 @@ add_clang_library(clangStaticAnalyzerCheckers
   MallocSizeofChecker.cpp
   NSAutoreleasePoolChecker.cpp
   NSErrorChecker.cpp
+  NonNullParamChecker.cpp
   NoReturnFunctionChecker.cpp
   ObjCAtSyncChecker.cpp
   ObjCContainersASTChecker.cpp
index 5170b7a149a2e972088f9c223acba94fdd931d21..bbcf9aa438c84e923862f6a3911605ba473ab89c 100644 (file)
@@ -60,9 +60,9 @@ def CallAndMessageChecker : Checker<"CallAndMessage">,
   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">,
similarity index 89%
rename from lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp
rename to lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
index d1593419e8415bfe167437e601dcfe8e09c4243d..273a7a38824ad8399317de55ce15eb15ca23edd1 100644 (file)
@@ -1,4 +1,4 @@
-//===--- AttrNonNullChecker.h - Undefined arguments checker ----*- C++ -*--===//
+//===--- NonNullParamChecker.cpp - Undefined arguments checker -*- C++ -*--===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,8 +7,11 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// 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
 //
 //===----------------------------------------------------------------------===//
 
@@ -24,7 +27,7 @@ using namespace clang;
 using namespace ento;
 
 namespace {
-class AttrNonNullChecker
+class NonNullParamChecker
   : public Checker< check::PreCall > {
   mutable OwningPtr<BugType> BTAttrNonNull;
   mutable OwningPtr<BugType> BTNullRefArg;
@@ -39,7 +42,7 @@ public:
 };
 } // 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)
@@ -146,7 +149,7 @@ void AttrNonNullChecker::checkPreCall(const CallEvent &Call,
   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
@@ -165,7 +168,7 @@ BugReport *AttrNonNullChecker::genReportNullAttrNonNull(
   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"));
@@ -185,6 +188,6 @@ BugReport *AttrNonNullChecker::genReportReferenceToNullPointer(
 
 }
 
-void ento::registerAttrNonNullChecker(CheckerManager &mgr) {
-  mgr.registerChecker<AttrNonNullChecker>();
+void ento::registerNonNullParamChecker(CheckerManager &mgr) {
+  mgr.registerChecker<NonNullParamChecker>();
 }
index a7fbd66d6808cb7148596653b77c62c54ff58108..bb22c25998c38a0ffad1e0fd0d33f8950eab26a8 100644 (file)
@@ -1193,7 +1193,7 @@ static void RDar8424269_B(RDar8424269_A *p, unsigned char *RDar8424269_D,
   tmp2 = tmp2t[2];
 }
 
-// <rdar://problem/8642434> - Handle transparent unions with the AttrNonNullChecker.
+// <rdar://problem/8642434> - Handle transparent unions with the NonNullParamChecker.
 typedef union {
   struct rdar_8642434_typeA *_dq;
 }