r349340 - Revert rC349281 '[analyzer][MallocChecker][NFC] Document and reorganize some functions'
Kristof Umann via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 17 04:07:57 PST 2018
Author: szelethus
Date: Mon Dec 17 04:07:57 2018
New Revision: 349340
URL: http://llvm.org/viewvc/llvm-project?rev=349340&view=rev
Log:
Revert rC349281 '[analyzer][MallocChecker][NFC] Document and reorganize some functions'
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
cfe/trunk/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
cfe/trunk/test/Analysis/NewDelete-checker-test.cpp
cfe/trunk/test/Analysis/NewDelete-path-notes.cpp
cfe/trunk/test/Analysis/dtor.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=349340&r1=349339&r2=349340&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Mon Dec 17 04:07:57 2018
@@ -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::addExtent
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::FreeMemAu
}
/// 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(Che
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(
Modified: cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist?rev=349340&r1=349339&r2=349340&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist (original)
+++ cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist Mon Dec 17 04:07:57 2018
@@ -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>
Modified: cfe/trunk/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Malloc%2BMismatchedDeallocator%2BNewDelete.cpp?rev=349340&r1=349339&r2=349340&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp (original)
+++ cfe/trunk/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp Mon Dec 17 04:07:57 2018
@@ -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() {
Modified: cfe/trunk/test/Analysis/NewDelete-checker-test.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/NewDelete-checker-test.cpp?rev=349340&r1=349339&r2=349340&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/NewDelete-checker-test.cpp (original)
+++ cfe/trunk/test/Analysis/NewDelete-checker-test.cpp Mon Dec 17 04:07:57 2018
@@ -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() {
Modified: cfe/trunk/test/Analysis/NewDelete-path-notes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/NewDelete-path-notes.cpp?rev=349340&r1=349339&r2=349340&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/NewDelete-path-notes.cpp (original)
+++ cfe/trunk/test/Analysis/NewDelete-path-notes.cpp Mon Dec 17 04:07:57 2018
@@ -11,8 +11,8 @@ void test() {
delete p;
// expected-note at -1 {{Memory is released}}
- delete p; // expected-warning {{Attempt to delete released memory}}
- // expected-note at -1 {{Attempt to delete released memory}}
+ delete p; // expected-warning {{Attempt to free released memory}}
+ // expected-note at -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 at -1 {{Returning; memory was released}}
- delete odd; // expected-warning {{Attempt to delete released memory}}
- // expected-note at -1 {{Attempt to delete released memory}}
+ delete odd; // expected-warning {{Attempt to free released memory}}
+ // expected-note at -1 {{Attempt to free released memory}}
}
Modified: cfe/trunk/test/Analysis/dtor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dtor.cpp?rev=349340&r1=349339&r2=349340&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/dtor.cpp (original)
+++ cfe/trunk/test/Analysis/dtor.cpp Mon Dec 17 04:07:57 2018
@@ -528,7 +528,7 @@ struct NonTrivial {
return *this;
}
~NonTrivial() {
- delete[] p; // expected-warning {{delete released memory}}
+ delete[] p; // expected-warning {{free released memory}}
}
};
More information about the cfe-commits
mailing list