From 2a481fa63be612e4a47d992b799cc2848bb9b616 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 19 Apr 2013 22:19:14 +0000 Subject: [PATCH] [analyzer] Website: update lists of potential and actual checkers. - memory.MismatchedDelete, memory.MultipleDelete, and memory.DeallocateNonPtr are complete (unix.MismatchedDeallocator and cplusplus.NewDelete) - Per discussion on the mailing list, different.UnaryPlusWithUnsigned has dubious value; remove it. - Add potential checker ctordtor.PlacementSelfCopy per an internal bug report. - core.AttributeNonNull is now core.NonNullParamChecker, though no one should be depending on this name anyway. llvm-svn: 179900 --- clang/www/analyzer/available_checks.html | 21 +++--- clang/www/analyzer/potential_checkers.html | 83 +++------------------- 2 files changed, 23 insertions(+), 81 deletions(-) diff --git a/clang/www/analyzer/available_checks.html b/clang/www/analyzer/available_checks.html index be15125a7e89..8c7d9e987a51 100644 --- a/clang/www/analyzer/available_checks.html +++ b/clang/www/analyzer/available_checks.html @@ -30,15 +30,15 @@ core.AdjustedReturnValueCheck to see if the return value of a function call is different than the caller expects (e.g., from calls through function pointers). -core.AttributeNonNullCheck for null pointers passed as arguments to a function whose arguments are marked with the 'nonnull' attribute. - - core.CallAndMessageCheck for logical errors for function calls and Objective-C message expressions (e.g., uninitialized arguments, null function pointers). core.DivideZeroCheck for division by zero. +core.NonNullParamCheckerCheck for null pointers passed as arguments to a function whose arguments are known to be non-null. + + core.NullDereferenceCheck for dereferences of null pointers. @@ -72,6 +72,9 @@ core.uninitialized.UndefReturnCheck for uninitialized values being returned to the caller. +cplusplus.NewDeleteCheck for double-free and use-after-free problems involving C++ delete. + + deadcode.DeadStoresCheck for values stored to variables that are never read afterwards. -osx.APICheck for proper uses of various Mac OS X APIs. - - -osx.AtomicCASEvaluate calls to OSAtomic functions. +osx.APICheck for proper uses of various Apple APIs. osx.SecKeychainAPICheck for proper uses of Secure Keychain APIs. -osx.cocoa.AtSyncCheck for null pointers used as mutexes for @synchronized. +osx.cocoa.AtSyncCheck for nil pointers used as mutexes for @synchronized. osx.cocoa.ClassReleaseCheck for sending 'retain', 'release', or 'autorelease' directly to a Class. @@ -164,12 +164,15 @@ unix.APICheck calls to various UNIX/Posix functions. -unix.MallocCheck for memory leaks, double free, and use-after-free problems. +unix.MallocCheck for memory leaks, double free, and use-after-free problems involving malloc. unix.MallocSizeofCheck for dubious malloc arguments involving sizeof. +unix.MismatchedDeallocatorCheck for mismatched deallocators (e.g. passing a pointer allocating with new to free()). + + unix.cstring.BadSizeArgCheck the size argument passed into C string functions for common erroneous patterns. diff --git a/clang/www/analyzer/potential_checkers.html b/clang/www/analyzer/potential_checkers.html index 04bf9fe45d09..c769541e70d8 100644 --- a/clang/www/analyzer/potential_checkers.html +++ b/clang/www/analyzer/potential_checkers.html @@ -62,43 +62,6 @@ void test() { PR15238 -memory.MismatchedDelete -
(C, C++)


-Mismatched deallocation function is used -
-#include <stdlib.h>
-
-void test() {
-  int *p1 = new int;
-  int *p2 = new int[1];
-  int *p3 = (int*)malloc(sizeof(int));
-
-  delete[] p1; // warn
-  delete p2; // warn
-  delete p3; // warn
-}
-
PR15238 - - -memory.MultipleDelete -
(C++)


-Attempt to deallocate released memory -
-#include <new>
-
-void test() {
-  int *p1 = new int;
-  int *p2 = new(p1) int;
-  int *p3 = p1;
-  delete p1;
-  delete p1; // warn
-  delete p2; // warn
-  delete p3; // warn
-}
-
PR15237 - - - memory.LeakPtrValChanged
enhancement to unix.Malloc
(C, C++)


Potential memory leak: a pointer to newly allocated data loses its original @@ -124,31 +87,6 @@ void test() { done at r174678 (C case) - -memory.DeallocateNonPtr -
enhancement to unix.Malloc
(C, C++)


-Deallocation function is applied to non-pointer -
-#include <stdlib.h>
-
-class A {
-  int *p;
-public:
-  operator int *() { return p; }  
-};
-
-void test() {
-  A a;
-  delete a; // warn
-  free(a); // warn
-  const char *s = "text";
-  delete s; // warn
-  free(s); // warn
-}
-
PR15237 - - - memory.LeakEvalOrder
(C, C++)


Potential memory leak: argument evaluation order is undefined, g() may never be called @@ -232,6 +170,17 @@ class A { }; +ctordtor.PlacementSelfCopy
+(C++11)


+For a placement copy or move, it is almost certainly an error if the constructed object is also the object being copied from. +
+class A {};
+
+void test(A *dst, A *src) {
+  ::new (dst) A(*dst); // warn (should be 'src')
+}
+
+ @@ -1276,16 +1225,6 @@ void test() { } -different.UnaryPlusWithUnsigned -
(C)


-Using 'unary +' with unsigned is meaningless -
-void test() {
-  unsigned a;
-  a = +a; // warn
-}
-
- different.LogicalOpUselessArg
(C)


The second operand of the && operator has no impact on expression result