r179410 - [analyzer] Makes NewDeleteLeaks checker work independently from NewDelete.
Jordan Rose
jordan_rose at apple.com
Fri Apr 12 14:52:25 PDT 2013
Sorry, I did this deliberately—I wanted NewDeleteLeaks to be a "sub-checker" of sorts, where you couldn't track leaks without also tracking use-after-free issues. Of course, if I really wanted to do that, I should have also made NewDeleteLeaks automatically enable NewDelete, in the same way that they all enable the basic CStringChecker. (Really, only the malloc checkers should do that.)
I guess I should have discussed this with you before slipping it in like this, but do you have an opinion on which way you'd prefer and why? (Can't tell if this is an opinion or just automatically fixing what looked like a mistake.)
Jordan
On Apr 12, 2013, at 13:48 , Anton Yartsev <anton.yartsev at gmail.com> wrote:
> Author: ayartsev
> Date: Fri Apr 12 15:48:49 2013
> New Revision: 179410
>
> URL: http://llvm.org/viewvc/llvm-project?rev=179410&view=rev
> Log:
> [analyzer] Makes NewDeleteLeaks checker work independently from NewDelete.
>
> Added:
> cfe/trunk/test/Analysis/NewDeleteLeaks-checker-test.cpp
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=179410&r1=179409&r2=179410&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Fri Apr 12 15:48:49 2013
> @@ -1091,7 +1091,7 @@ bool MallocChecker::isTrackedByCurrentCh
> }
> case AF_CXXNew:
> case AF_CXXNewArray: {
> - if (!Filter.CNewDeleteChecker)
> + if (!Filter.CNewDeleteChecker && !Filter.CNewDeleteLeaksChecker)
> return false;
> return true;
> }
>
> Added: cfe/trunk/test/Analysis/NewDeleteLeaks-checker-test.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/NewDeleteLeaks-checker-test.cpp?rev=179410&view=auto
> ==============================================================================
> --- cfe/trunk/test/Analysis/NewDeleteLeaks-checker-test.cpp (added)
> +++ cfe/trunk/test/Analysis/NewDeleteLeaks-checker-test.cpp Fri Apr 12 15:48:49 2013
> @@ -0,0 +1,28 @@
> +// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.cplusplus.NewDeleteLeaks -std=c++11 -fblocks -verify %s
> +#include "Inputs/system-header-simulator-cxx.h"
> +
> +//----- Standard non-placement operators
> +void testGlobalOpNew() {
> + void *p = operator new(0);
> +} // expected-warning{{Potential leak of memory pointed to by 'p'}}
> +
> +void testGlobalOpNewArray() {
> + void *p = operator new[](0);
> +} // expected-warning{{Potential leak of memory pointed to by 'p'}}
> +
> +void testGlobalNewExpr() {
> + int *p = new int;
> +} // expected-warning{{Potential leak of memory pointed to by 'p'}}
> +
> +void testGlobalNewExprArray() {
> + int *p = new int[0];
> +} // expected-warning{{Potential leak of memory pointed to by 'p'}}
> +
> +//----- Standard nothrow placement operators
> +void testGlobalNoThrowPlacementOpNewBeforeOverload() {
> + void *p = operator new(0, std::nothrow);
> +} // expected-warning{{Potential leak of memory pointed to by 'p'}}
> +
> +void testGlobalNoThrowPlacementExprNewBeforeOverload() {
> + int *p = new(std::nothrow) int;
> +} // expected-warning{{Potential leak of memory pointed to by 'p'}}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list