Revert rC349281 '[analyzer][MallocChecker][NFC] Document and reorganize some functions'

llvm-svn: 349340
This commit is contained in:
Kristof Umann 2018-12-17 12:07:57 +00:00
parent 357973192d
commit 09e86e77c9
6 changed files with 20 additions and 28 deletions

View File

@ -137,7 +137,7 @@ class RefState {
const Stmt *S;
Kind K : 3;
AllocationFamily Family : 29;
AllocationFamily Family : 3;
RefState(Kind k, const Stmt *s, AllocationFamily family)
: S(s), K(k), Family(family) {
@ -1431,8 +1431,7 @@ ProgramStateRef MallocChecker::addExtentSize(CheckerContext &C,
void MallocChecker::checkPreStmt(const CXXDeleteExpr *DE,
CheckerContext &C) const {
// This will regard deleting freed() regions as a use-after-free, rather then
// a double-free or double-delete error.
if (!ChecksEnabled[CK_NewDeleteChecker])
if (SymbolRef Sym = C.getSVal(DE->getArgument()).getAsSymbol())
checkUseAfterFree(Sym, C, DE->getArgument());
@ -1629,8 +1628,7 @@ ProgramStateRef MallocChecker::FreeMemAux(CheckerContext &C,
}
/// Checks if the previous call to free on the given symbol failed - if free
/// failed, returns true. Also, stores the corresponding return value symbol in
/// \p RetStatusSymbol.
/// failed, returns true. Also, returns the corresponding return value symbol.
static bool didPreviousFreeFail(ProgramStateRef State,
SymbolRef Sym, SymbolRef &RetStatusSymbol) {
const SymbolRef *Ret = State->get<FreeReturnValue>(Sym);
@ -2291,12 +2289,6 @@ void MallocChecker::ReportDoubleFree(CheckerContext &C, SourceRange Range,
if (!CheckKind.hasValue())
return;
// If this is a double delete error, print the appropiate warning message.
if (CheckKind == CK_NewDeleteChecker) {
ReportDoubleDelete(C, Sym);
return;
}
if (ExplodedNode *N = C.generateErrorNode()) {
if (!BT_DoubleFree[*CheckKind])
BT_DoubleFree[*CheckKind].reset(new BugType(

View File

@ -194,17 +194,17 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Attempt to delete released memory</string>
<string>Attempt to free released memory</string>
<key>message</key>
<string>Attempt to delete released memory</string>
<string>Attempt to free released memory</string>
</dict>
</array>
<key>description</key><string>Attempt to delete released memory</string>
<key>description</key><string>Attempt to free released memory</string>
<key>category</key><string>Memory error</string>
<key>type</key><string>Double delete</string>
<key>type</key><string>Double free</string>
<key>check_name</key><string>cplusplus.NewDelete</string>
<!-- This hash is experimental and going to change! -->
<key>issue_hash_content_of_line_in_context</key><string>593b185245106bed5175ccf2753039b2</string>
<key>issue_hash_content_of_line_in_context</key><string>bd8e324d09c70b9e2be6f824a4942e5a</string>
<key>issue_context_kind</key><string>function</string>
<key>issue_context</key><string>test</string>
<key>issue_hash_function_offset</key><string>8</string>
@ -423,17 +423,17 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Attempt to delete released memory</string>
<string>Attempt to free released memory</string>
<key>message</key>
<string>Attempt to delete released memory</string>
<string>Attempt to free released memory</string>
</dict>
</array>
<key>description</key><string>Attempt to delete released memory</string>
<key>description</key><string>Attempt to free released memory</string>
<key>category</key><string>Memory error</string>
<key>type</key><string>Double delete</string>
<key>type</key><string>Double free</string>
<key>check_name</key><string>cplusplus.NewDelete</string>
<!-- This hash is experimental and going to change! -->
<key>issue_hash_content_of_line_in_context</key><string>6484e9b006ede7362edef2187ba6eb37</string>
<key>issue_hash_content_of_line_in_context</key><string>8bf1a5b9fdae9d86780aa6c4cdce2605</string>
<key>issue_context_kind</key><string>function</string>
<key>issue_context</key><string>test</string>
<key>issue_hash_function_offset</key><string>3</string>

View File

@ -46,7 +46,7 @@ void testMismatchedDeallocator() {
void testNewDoubleFree() {
int *p = new int;
delete p;
delete p; // expected-warning{{Attempt to delete released memory}}
delete p; // expected-warning{{Attempt to free released memory}}
}
void testNewLeak() {

View File

@ -182,7 +182,7 @@ void testUseThisAfterDelete() {
void testDoubleDelete() {
int *p = new int;
delete p;
delete p; // expected-warning{{Attempt to delete released memory}}
delete p; // expected-warning{{Attempt to free released memory}}
}
void testExprDeleteArg() {

View File

@ -11,8 +11,8 @@ void test() {
delete p;
// expected-note@-1 {{Memory is released}}
delete p; // expected-warning {{Attempt to delete released memory}}
// expected-note@-1 {{Attempt to delete released memory}}
delete p; // expected-warning {{Attempt to free released memory}}
// expected-note@-1 {{Attempt to free released memory}}
}
struct Odd {
@ -24,7 +24,7 @@ struct Odd {
void test(Odd *odd) {
odd->kill(); // expected-note{{Calling 'Odd::kill'}}
// expected-note@-1 {{Returning; memory was released}}
delete odd; // expected-warning {{Attempt to delete released memory}}
// expected-note@-1 {{Attempt to delete released memory}}
delete odd; // expected-warning {{Attempt to free released memory}}
// expected-note@-1 {{Attempt to free released memory}}
}

View File

@ -528,7 +528,7 @@ struct NonTrivial {
return *this;
}
~NonTrivial() {
delete[] p; // expected-warning {{delete released memory}}
delete[] p; // expected-warning {{free released memory}}
}
};