Hi!
Propose to move the MismatchedDeallocator checker from unix.* to
cplusplus.* group if you don't think it's too late. This check is
specific for C++.
--
Anton
Index: lib/StaticAnalyzer/Checkers/Checkers.td
===================================================================
--- lib/StaticAnalyzer/Checkers/Checkers.td (revision 204255)
+++ lib/StaticAnalyzer/Checkers/Checkers.td (working copy)
@@ -180,6 +180,10 @@
HelpText<"Check for double-free and use-after-free problems. Traces memory managed by new/delete.">,
DescFile<"MallocChecker.cpp">;
+def MismatchedDeallocatorChecker : Checker<"MismatchedDeallocator">,
+ HelpText<"Check for mismatched deallocators.">,
+ DescFile<"MallocChecker.cpp">;
+
} // end: "cplusplus"
let ParentPackage = CplusplusAlpha in {
@@ -298,10 +302,6 @@
def MallocSizeofChecker : Checker<"MallocSizeof">,
HelpText<"Check for dubious malloc arguments involving sizeof">,
DescFile<"MallocSizeofChecker.cpp">;
-
-def MismatchedDeallocatorChecker : Checker<"MismatchedDeallocator">,
- HelpText<"Check for mismatched deallocators.">,
- DescFile<"MallocChecker.cpp">;
} // end "unix"
Index: test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
===================================================================
--- test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp (revision 204255)
+++ test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp (working copy)
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete -std=c++11 -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.MismatchedDeallocator,cplusplus.NewDelete -std=c++11 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.MismatchedDeallocator,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -verify %s
#include "Inputs/system-header-simulator-for-malloc.h"
@@ -32,9 +32,9 @@
free(++p); // expected-warning{{Argument to free() is offset by 4 bytes from the start of memory allocated by malloc()}}
}
-//-----------------------------------------------------------------
-// Check that unix.MismatchedDeallocator catches all types of bugs.
-//-----------------------------------------------------------------
+//----------------------------------------------------------------------
+// Check that cplusplus.MismatchedDeallocator catches all types of bugs.
+//----------------------------------------------------------------------
void testMismatchedDeallocator() {
int *x = (int *)malloc(sizeof(int));
delete x; // expected-warning{{Memory allocated by malloc() should be deallocated by free(), not 'delete'}}
Index: test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp
===================================================================
--- test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp (revision 204255)
+++ test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp (working copy)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator -analyzer-store region -std=c++11 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.MismatchedDeallocator -analyzer-store region -std=c++11 -verify %s
// expected-no-diagnostics
typedef __typeof(sizeof(int)) size_t;
@@ -5,10 +5,10 @@
void *malloc(size_t);
void free(void *);
-//--------------------------------------------------------------------
-// Check that unix.Malloc + unix.MismatchedDeallocator does not enable
+//-------------------------------------------------------------------------
+// Check that unix.Malloc + cplusplus.MismatchedDeallocator does not enable
// warnings produced by the alpha.cplusplus.NewDelete checker.
-//--------------------------------------------------------------------
+//-------------------------------------------------------------------------
void testNewDeleteNoWarn() {
int i;
delete &i; // no-warning
Index: test/Analysis/Malloc+NewDelete_intersections.cpp
===================================================================
--- test/Analysis/Malloc+NewDelete_intersections.cpp (revision 204255)
+++ test/Analysis/Malloc+NewDelete_intersections.cpp (working copy)
@@ -7,7 +7,7 @@
//-------------------------------------------------------------------
// Check that unix.Malloc + cplusplus.NewDelete does not enable
-// warnings produced by unix.MismatchedDeallocator.
+// warnings produced by cplusplus.MismatchedDeallocator.
//-------------------------------------------------------------------
void testMismatchedDeallocator() {
int *p = (int *)malloc(sizeof(int));
Index: test/Analysis/MismatchedDeallocator-checker-test.mm
===================================================================
--- test/Analysis/MismatchedDeallocator-checker-test.mm (revision 204255)
+++ test/Analysis/MismatchedDeallocator-checker-test.mm (working copy)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.MismatchedDeallocator -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.MismatchedDeallocator -fblocks -verify %s
#include "Inputs/system-header-simulator-objc.h"
#include "Inputs/system-header-simulator-cxx.h"
@@ -117,7 +117,7 @@
//-------------------------------------------------------
// Check for intersection with unix.Malloc bounded with
-// unix.MismatchedDeallocator
+// cplusplus.MismatchedDeallocator
//-------------------------------------------------------
// new/delete oparators are subjects of cplusplus.NewDelete.
@@ -155,7 +155,7 @@
//---------------------------------------------------------------
// Check for intersection with cplusplus.NewDelete bounded with
-// unix.MismatchedDeallocator
+// cplusplus.MismatchedDeallocator
//---------------------------------------------------------------
// malloc()/free() are subjects of unix.Malloc and unix.MallocWithAnnotations
Index: test/Analysis/MismatchedDeallocator-path-notes.cpp
===================================================================
--- test/Analysis/MismatchedDeallocator-path-notes.cpp (revision 204255)
+++ test/Analysis/MismatchedDeallocator-path-notes.cpp (working copy)
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=text -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false %s -o %t.plist
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.MismatchedDeallocator -analyzer-output=text -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.MismatchedDeallocator -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false %s -o %t.plist
// RUN: FileCheck --input-file=%t.plist %s
void changePointee(int *p);
Index: test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp
===================================================================
--- test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp (revision 204255)
+++ test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp (working copy)
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,unix.MismatchedDeallocator -std=c++11 -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks,unix.MismatchedDeallocator -DLEAKS -std=c++11 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,cplusplus.MismatchedDeallocator -std=c++11 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks,cplusplus.MismatchedDeallocator -DLEAKS -std=c++11 -verify %s
// expected-no-diagnostics
typedef __typeof(sizeof(int)) size_t;
@@ -6,10 +6,10 @@
void *malloc(size_t);
void free(void *);
-//------------------------------------------------------------------
-// Check that alpha.cplusplus.NewDelete + unix.MismatchedDeallocator
+//-----------------------------------------------------------------------
+// Check that alpha.cplusplus.NewDelete + cplusplus.MismatchedDeallocator
// does not enable warnings produced by the unix.Malloc checker.
-//------------------------------------------------------------------
+//-----------------------------------------------------------------------
void testMallocFreeNoWarn() {
int i;
free(&i); // no warn
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits