[cfe-commits] r132130 - in /cfe/trunk: lib/StaticAnalyzer/Core/CFRefCount.cpp test/Analysis/plist-output-alternate.m
Ted Kremenek
kremenek at apple.com
Thu May 26 11:45:44 PDT 2011
Author: kremenek
Date: Thu May 26 13:45:44 2011
New Revision: 132130
URL: http://llvm.org/viewvc/llvm-project?rev=132130&view=rev
Log:
Tighen analyzer diagnostics w.r.t ObjC/CF leaks.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CFRefCount.cpp
cfe/trunk/test/Analysis/plist-output-alternate.m
Modified: cfe/trunk/lib/StaticAnalyzer/Core/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CFRefCount.cpp?rev=132130&r1=132129&r2=132130&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CFRefCount.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CFRefCount.cpp Thu May 26 13:45:44 2011
@@ -2090,7 +2090,7 @@
}
if (CurrV.isOwned()) {
- os << "+1 retain count (owning reference).";
+ os << "+1 retain count";
if (static_cast<CFRefBug&>(getBugType()).getTF().isGCEnabled()) {
assert(CurrV.getObjKind() == RetEffect::CF);
@@ -2100,7 +2100,7 @@
}
else {
assert (CurrV.isNotOwned());
- os << "+0 retain count (non-owning reference).";
+ os << "+0 retain count";
}
PathDiagnosticLocation Pos(S, BRC.getSourceManager());
@@ -2232,11 +2232,11 @@
case RefVal::ReturnedOwned:
os << "Object returned to caller as an owning reference (single retain "
- "count transferred to caller).";
+ "count transferred to caller)";
break;
case RefVal::ReturnedNotOwned:
- os << "Object returned to caller with a +0 (non-owning) retain count.";
+ os << "Object returned to caller with a +0 retain count";
break;
default:
@@ -2369,12 +2369,7 @@
llvm::tie(AllocNode, FirstBinding) =
GetAllocationSite(BRC.getStateManager(), EndN, Sym);
- // Get the allocate site.
- assert(AllocNode);
- const Stmt* FirstStmt = cast<PostStmt>(AllocNode->getLocation()).getStmt();
-
SourceManager& SMgr = BRC.getSourceManager();
- unsigned AllocLine =SMgr.getInstantiationLineNumber(FirstStmt->getLocStart());
// Compute an actual location for the leak. Sometimes a leak doesn't
// occur at an actual statement (e.g., transition between blocks; end
@@ -2407,10 +2402,14 @@
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
- os << "Object allocated on line " << AllocLine;
+ os << "Object leaked: ";
- if (FirstBinding)
- os << " and stored into '" << FirstBinding->getString() << '\'';
+ if (FirstBinding) {
+ os << "object allocated and stored into '"
+ << FirstBinding->getString() << '\'';
+ }
+ else
+ os << "allocated object";
// Get the retain count.
const RefVal* RV = EndN->getState()->get<RefBindings>(Sym);
@@ -2425,7 +2424,7 @@
<< MD->getSelector().getAsString()
<< "') does not start with 'copy', 'mutableCopy', 'alloc' or 'new'."
" This violates the naming convention rules "
- " given in the Memory Management Guide for Cocoa (object leaked)";
+ " given in the Memory Management Guide for Cocoa";
}
else {
const FunctionDecl *FD = cast<FunctionDecl>(D);
@@ -2433,7 +2432,7 @@
<< FD->getNameAsString()
<< "') does not contain 'Copy' or 'Create'. This violates the naming"
" convention rules given the Memory Management Guide for Core "
- " Foundation (object leaked)";
+ " Foundation";
}
}
else if (RV->getKind() == RefVal::ErrorGCLeakReturned) {
@@ -2446,7 +2445,7 @@
}
else
os << " is not referenced later in this execution path and has a retain "
- "count of +" << RV->getCount() << " (object leaked)";
+ "count of +" << RV->getCount();
return new PathDiagnosticEventPiece(L, os.str());
}
Modified: cfe/trunk/test/Analysis/plist-output-alternate.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/plist-output-alternate.m?rev=132130&r1=132129&r2=132130&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/plist-output-alternate.m (original)
+++ cfe/trunk/test/Analysis/plist-output-alternate.m Thu May 26 13:45:44 2011
@@ -864,9 +864,9 @@
// CHECK: </array>
// CHECK: </array>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count (owning reference)</string>
+// CHECK: <string>Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count</string>
// CHECK: <key>message</key>
-// CHECK: <string>Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count (owning reference)</string>
+// CHECK: <string>Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count</string>
// CHECK: </dict>
// CHECK: <dict>
// CHECK: <key>kind</key><string>control</string>
@@ -994,9 +994,9 @@
// CHECK: </array>
// CHECK: </array>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Object allocated on line 53 and stored into 'value' is not referenced later in this execution path and has a retain count of +1 (object leaked)</string>
+// CHECK: <string>Object leaked: object allocated and stored into 'value' is not referenced later in this execution path and has a retain count of +1</string>
// CHECK: <key>message</key>
-// CHECK: <string>Object allocated on line 53 and stored into 'value' is not referenced later in this execution path and has a retain count of +1 (object leaked)</string>
+// CHECK: <string>Object leaked: object allocated and stored into 'value' is not referenced later in this execution path and has a retain count of +1</string>
// CHECK: </dict>
// CHECK: </array>
// CHECK: <key>description</key><string>Potential leak of an object allocated on line 53 and stored into 'value'</string>
@@ -1012,3 +1012,4 @@
// CHECK: </array>
// CHECK: </dict>
// CHECK: </plist>
+
More information about the cfe-commits
mailing list