зеркало из https://github.com/microsoft/clang-1.git
[analyzer] Re-enable cplusplus.NewDelete (but not NewDeleteLeaks).
As mentioned in the previous commit message, the use-after-free and double-free warnings for 'delete' are worth enabling even while the leak warnings still have false positives. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178891 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
e85deb356f
Коммит
e449edc5bd
|
@ -1969,6 +1969,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
|
||||
CmdArgs.push_back("-analyzer-checker=deadcode");
|
||||
|
||||
if (types::isCXX(Inputs[0].getType()))
|
||||
CmdArgs.push_back("-analyzer-checker=cplusplus");
|
||||
|
||||
// Enable the following experimental checkers for testing.
|
||||
CmdArgs.push_back("-analyzer-checker=security.insecureAPI.UncheckedReturn");
|
||||
CmdArgs.push_back("-analyzer-checker=security.insecureAPI.getpw");
|
||||
|
|
|
@ -167,6 +167,11 @@ def ReturnUndefChecker : Checker<"UndefReturn">,
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
let ParentPackage = Cplusplus in {
|
||||
|
||||
def NewDeleteChecker : Checker<"NewDelete">,
|
||||
HelpText<"Check for double-free and use-after-free problems. Traces memory managed by new/delete.">,
|
||||
DescFile<"MallocChecker.cpp">;
|
||||
|
||||
} // end: "cplusplus"
|
||||
|
||||
let ParentPackage = CplusplusAlpha in {
|
||||
|
@ -175,10 +180,6 @@ def VirtualCallChecker : Checker<"VirtualCall">,
|
|||
HelpText<"Check virtual function calls during construction or destruction">,
|
||||
DescFile<"VirtualCallChecker.cpp">;
|
||||
|
||||
def NewDeleteChecker : Checker<"NewDelete">,
|
||||
HelpText<"Check for double-free and use-after-free problems. Traces memory managed by new/delete.">,
|
||||
DescFile<"MallocChecker.cpp">;
|
||||
|
||||
def NewDeleteLeaksChecker : Checker<"NewDeleteLeaks">,
|
||||
HelpText<"Check for memory leaks. Traces memory managed by new/delete.">,
|
||||
DescFile<"MallocChecker.cpp">;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,alpha.cplusplus.NewDelete -std=c++11 -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,alpha.cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -verify %s
|
||||
// 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
|
||||
|
||||
typedef __typeof(sizeof(int)) size_t;
|
||||
void *malloc(size_t);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,alpha.cplusplus.NewDelete -std=c++11 -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,alpha.cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -std=c++11 -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete -std=c++11 -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -std=c++11 -verify %s
|
||||
|
||||
typedef __typeof(sizeof(int)) size_t;
|
||||
void *malloc(size_t);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.cplusplus.NewDelete,unix.MismatchedDeallocator -std=c++11 -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks,unix.MismatchedDeallocator -DLEAKS -std=c++11 -verify %s
|
||||
// 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
|
||||
// expected-no-diagnostics
|
||||
|
||||
typedef __typeof(sizeof(int)) size_t;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.cplusplus.NewDelete -std=c++11 -fblocks -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -fblocks -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete -std=c++11 -fblocks -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -fblocks -verify %s
|
||||
#include "Inputs/system-header-simulator-cxx.h"
|
||||
|
||||
typedef __typeof__(sizeof(int)) size_t;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.cplusplus.NewDelete,unix.Malloc -std=c++11 -fblocks -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -DLEAKS -fblocks -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,unix.Malloc -std=c++11 -fblocks -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -DLEAKS -fblocks -verify %s
|
||||
#include "Inputs/system-header-simulator-cxx.h"
|
||||
|
||||
#ifndef LEAKS
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.cplusplus.NewDelete -std=c++11 -fblocks -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -std=c++11 -DLEAKS -fblocks -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete -std=c++11 -fblocks -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -std=c++11 -DLEAKS -fblocks -verify %s
|
||||
#include "Inputs/system-header-simulator-cxx.h"
|
||||
#include "Inputs/system-header-simulator-objc.h"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.NewDelete,unix.Malloc -analyzer-output=text -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.NewDelete,unix.Malloc -analyzer-output=plist %s -o %t.plist
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=cplusplus.NewDelete,unix.Malloc -analyzer-output=text -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=cplusplus.NewDelete,unix.Malloc -analyzer-output=plist %s -o %t.plist
|
||||
// RUN: FileCheck --input-file=%t.plist %s
|
||||
|
||||
void test() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -fblocks -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -fblocks -verify %s
|
||||
// expected-no-diagnostics
|
||||
|
||||
namespace std {
|
||||
|
|
|
@ -168,8 +168,9 @@ SBOutputDirName = "ScanBuildResults"
|
|||
SBOutputDirReferencePrefix = "Ref"
|
||||
|
||||
# The list of checkers used during analyzes.
|
||||
# Currently, consists of all the non experimental checkers.
|
||||
Checkers="alpha.unix.SimpleStream,alpha.security.taint,core,deadcode,security,unix,osx"
|
||||
# Currently, consists of all the non experimental checkers, plus a few alpha
|
||||
# checkers we don't want to regress on.
|
||||
Checkers="alpha.unix.SimpleStream,alpha.security.taint,alpha.cplusplus.NewDeleteLeaks,core,cplusplus,deadcode,security,unix,osx"
|
||||
|
||||
Verbose = 1
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче