From 404028798f4bf629fba6d3202f5d4725e7f502b5 Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Tue, 23 Apr 2013 23:57:50 +0000 Subject: [PATCH] [analyzer] Set the allocation site to be the uniqueing location for retain count checker leaks. The uniqueing location is the location which is part of the hash used to determine if two reports are the same. This is used by the CmpRuns.py script to compare two analyzer runs and determine which warnings are new. llvm-svn: 180166 --- .../Checkers/RetainCountChecker.cpp | 13 +++++- clang/test/Analysis/plist-output-alternate.m | 2 +- clang/test/Analysis/plist-output.m | 2 +- .../Analysis/retain-release-path-notes-gc.m | 46 +++++++++---------- .../test/Analysis/retain-release-path-notes.m | 18 ++++---- 5 files changed, 45 insertions(+), 36 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index 7f83d1d37120..824ce34ab33d 100644 --- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -2358,8 +2358,17 @@ CFRefLeakReport::CFRefLeakReport(CFRefBug &D, const LangOptions &LOpts, else AllocStmt = P.castAs().getStmt(); assert(AllocStmt && "All allocations must come from explicit calls"); - Location = PathDiagnosticLocation::createBegin(AllocStmt, SMgr, - n->getLocationContext()); + + PathDiagnosticLocation AllocLocation = + PathDiagnosticLocation::createBegin(AllocStmt, SMgr, + AllocNode->getLocationContext()); + Location = AllocLocation; + + // Set uniqieing info, which will be used for unique the bug reports. The + // leaks should be uniqued on the allocation site. + UniqueingLocation = AllocLocation; + UniqueingDecl = AllocNode->getLocationContext()->getDecl(); + // Fill in the description of the bug. Description.clear(); llvm::raw_string_ostream os(Description); diff --git a/clang/test/Analysis/plist-output-alternate.m b/clang/test/Analysis/plist-output-alternate.m index d201fe4ec072..93d0421d665e 100644 --- a/clang/test/Analysis/plist-output-alternate.m +++ b/clang/test/Analysis/plist-output-alternate.m @@ -1362,7 +1362,7 @@ void rdar8331641(int x) { // CHECK-NEXT: typeLeak // CHECK-NEXT: issue_context_kindfunction // CHECK-NEXT: issue_contextrdar8331641 -// CHECK-NEXT: issue_hash6 +// CHECK-NEXT: issue_hash2 // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line58 diff --git a/clang/test/Analysis/plist-output.m b/clang/test/Analysis/plist-output.m index a6112cb2bac5..3dfd6be2e713 100644 --- a/clang/test/Analysis/plist-output.m +++ b/clang/test/Analysis/plist-output.m @@ -2141,7 +2141,7 @@ int testFoo(Foo *x) { // CHECK-NEXT: typeLeak // CHECK-NEXT: issue_context_kindObjective-C method // CHECK-NEXT: issue_contexttest2 -// CHECK-NEXT: issue_hash4 +// CHECK-NEXT: issue_hash2 // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line88 diff --git a/clang/test/Analysis/retain-release-path-notes-gc.m b/clang/test/Analysis/retain-release-path-notes-gc.m index 913714e6cdd2..f74d61fa9adc 100644 --- a/clang/test/Analysis/retain-release-path-notes-gc.m +++ b/clang/test/Analysis/retain-release-path-notes-gc.m @@ -139,7 +139,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -202,7 +202,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1 // CHECK-NEXT: message -// CHECK-NEXT: Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1 +// CHECK-NEXT: Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: descriptionPotential leak (when using garbage collection) of an object stored into 'leaked' @@ -210,7 +210,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: typeLeak of object when using garbage collection // CHECK-NEXT: issue_context_kindfunction // CHECK-NEXT: issue_contextcreationViaCFCreate -// CHECK-NEXT: issue_hash2 +// CHECK-NEXT: issue_hash1 // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line44 @@ -282,7 +282,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -357,7 +357,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: Reference count incremented. The object now has a +2 retain count // CHECK-NEXT: message -// CHECK-NEXT: Reference count incremented. The object now has a +2 retain count +// CHECK-NEXT: Reference count incremented. The object now has a +2 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -432,7 +432,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: In GC mode a call to 'CFMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. An object must have a 0 retain count to be garbage collected. After this call its retain count is +1 // CHECK-NEXT: message -// CHECK-NEXT: In GC mode a call to 'CFMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. An object must have a 0 retain count to be garbage collected. After this call its retain count is +1 +// CHECK-NEXT: In GC mode a call to 'CFMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. An object must have a 0 retain count to be garbage collected. After this call its retain count is +1 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -507,7 +507,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: In GC mode a call to 'NSMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. Since it now has a 0 retain count the object can be automatically collected by the garbage collector // CHECK-NEXT: message -// CHECK-NEXT: In GC mode a call to 'NSMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. Since it now has a 0 retain count the object can be automatically collected by the garbage collector +// CHECK-NEXT: In GC mode a call to 'NSMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. Since it now has a 0 retain count the object can be automatically collected by the garbage collector // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -582,7 +582,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: Reference count incremented. The object now has a +1 retain count. The object is not eligible for garbage collection until the retain count reaches 0 again // CHECK-NEXT: message -// CHECK-NEXT: Reference count incremented. The object now has a +1 retain count. The object is not eligible for garbage collection until the retain count reaches 0 again +// CHECK-NEXT: Reference count incremented. The object now has a +1 retain count. The object is not eligible for garbage collection until the retain count reaches 0 again // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -645,7 +645,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1 // CHECK-NEXT: message -// CHECK-NEXT: Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1 +// CHECK-NEXT: Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: descriptionPotential leak (when using garbage collection) of an object stored into 'leaked' @@ -653,7 +653,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: typeLeak of object when using garbage collection // CHECK-NEXT: issue_context_kindfunction // CHECK-NEXT: issue_contextmakeCollectable -// CHECK-NEXT: issue_hash6 +// CHECK-NEXT: issue_hash1 // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line53 @@ -725,7 +725,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: Method returns an Objective-C object with a +0 retain count // CHECK-NEXT: message -// CHECK-NEXT: Method returns an Objective-C object with a +0 retain count +// CHECK-NEXT: Method returns an Objective-C object with a +0 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -800,7 +800,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: In GC mode the 'retain' message has no effect // CHECK-NEXT: message -// CHECK-NEXT: In GC mode the 'retain' message has no effect +// CHECK-NEXT: In GC mode the 'retain' message has no effect // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -875,7 +875,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: In GC mode the 'release' message has no effect // CHECK-NEXT: message -// CHECK-NEXT: In GC mode the 'release' message has no effect +// CHECK-NEXT: In GC mode the 'release' message has no effect // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -950,7 +950,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: In GC mode an 'autorelease' has no effect // CHECK-NEXT: message -// CHECK-NEXT: In GC mode an 'autorelease' has no effect +// CHECK-NEXT: In GC mode an 'autorelease' has no effect // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -1013,7 +1013,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: Incorrect decrement of the reference count of an object that is not owned at this point by the caller // CHECK-NEXT: message -// CHECK-NEXT: Incorrect decrement of the reference count of an object that is not owned at this point by the caller +// CHECK-NEXT: Incorrect decrement of the reference count of an object that is not owned at this point by the caller // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: descriptionIncorrect decrement of the reference count of an object that is not owned at this point by the caller @@ -1093,7 +1093,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -1168,7 +1168,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: Object returned to caller as an owning reference (single retain count transferred to caller) // CHECK-NEXT: message -// CHECK-NEXT: Object returned to caller as an owning reference (single retain count transferred to caller) +// CHECK-NEXT: Object returned to caller as an owning reference (single retain count transferred to caller) // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindevent @@ -1197,7 +1197,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: Object leaked: object allocated and stored into 'object' and returned from method 'getViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector // CHECK-NEXT: message -// CHECK-NEXT: Object leaked: object allocated and stored into 'object' and returned from method 'getViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector +// CHECK-NEXT: Object leaked: object allocated and stored into 'object' and returned from method 'getViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: descriptionPotential leak (when using garbage collection) of an object stored into 'object' @@ -1205,7 +1205,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: typeLeak of returned object when using garbage collection // CHECK-NEXT: issue_context_kindObjective-C method // CHECK-NEXT: issue_contextgetViolation -// CHECK-NEXT: issue_hash2 +// CHECK-NEXT: issue_hash1 // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line67 @@ -1277,7 +1277,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -1352,7 +1352,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: Object returned to caller as an owning reference (single retain count transferred to caller) // CHECK-NEXT: message -// CHECK-NEXT: Object returned to caller as an owning reference (single retain count transferred to caller) +// CHECK-NEXT: Object returned to caller as an owning reference (single retain count transferred to caller) // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindevent @@ -1381,7 +1381,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: extended_message // CHECK-NEXT: Object leaked: object allocated and stored into 'object' and returned from method 'copyViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector // CHECK-NEXT: message -// CHECK-NEXT: Object leaked: object allocated and stored into 'object' and returned from method 'copyViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector +// CHECK-NEXT: Object leaked: object allocated and stored into 'object' and returned from method 'copyViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: descriptionPotential leak (when using garbage collection) of an object stored into 'object' @@ -1389,7 +1389,7 @@ void retainReleaseIgnored () { // CHECK-NEXT: typeLeak of returned object when using garbage collection // CHECK-NEXT: issue_context_kindObjective-C method // CHECK-NEXT: issue_contextcopyViolation -// CHECK-NEXT: issue_hash2 +// CHECK-NEXT: issue_hash1 // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line72 diff --git a/clang/test/Analysis/retain-release-path-notes.m b/clang/test/Analysis/retain-release-path-notes.m index 8a023736c570..a3c681ae3750 100644 --- a/clang/test/Analysis/retain-release-path-notes.m +++ b/clang/test/Analysis/retain-release-path-notes.m @@ -378,7 +378,7 @@ static int Cond; // CHECK-NEXT: typeLeak // CHECK-NEXT: issue_context_kindfunction // CHECK-NEXT: issue_contextcreationViaAlloc -// CHECK-NEXT: issue_hash2 +// CHECK-NEXT: issue_hash1 // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line47 @@ -521,7 +521,7 @@ static int Cond; // CHECK-NEXT: typeLeak // CHECK-NEXT: issue_context_kindfunction // CHECK-NEXT: issue_contextcreationViaCFCreate -// CHECK-NEXT: issue_hash2 +// CHECK-NEXT: issue_hash1 // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line52 @@ -889,7 +889,7 @@ static int Cond; // CHECK-NEXT: typeLeak // CHECK-NEXT: issue_context_kindfunction // CHECK-NEXT: issue_contextacquisitionViaMethod -// CHECK-NEXT: issue_hash5 +// CHECK-NEXT: issue_hash1 // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line60 @@ -1107,7 +1107,7 @@ static int Cond; // CHECK-NEXT: typeLeak // CHECK-NEXT: issue_context_kindfunction // CHECK-NEXT: issue_contextacquisitionViaProperty -// CHECK-NEXT: issue_hash3 +// CHECK-NEXT: issue_hash1 // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line66 @@ -1325,7 +1325,7 @@ static int Cond; // CHECK-NEXT: typeLeak // CHECK-NEXT: issue_context_kindfunction // CHECK-NEXT: issue_contextacquisitionViaCFFunction -// CHECK-NEXT: issue_hash3 +// CHECK-NEXT: issue_hash1 // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line72 @@ -2565,7 +2565,7 @@ static int Cond; // CHECK-NEXT: typeLeak // CHECK-NEXT: issue_context_kindfunction // CHECK-NEXT: issue_contextmakeCollectableIgnored -// CHECK-NEXT: issue_hash4 +// CHECK-NEXT: issue_hash1 // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line104 @@ -2933,7 +2933,7 @@ static int Cond; // CHECK-NEXT: typeLeak of returned object // CHECK-NEXT: issue_context_kindfunction // CHECK-NEXT: issue_contextCFGetRuleViolation -// CHECK-NEXT: issue_hash2 +// CHECK-NEXT: issue_hash1 // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line114 @@ -3669,7 +3669,7 @@ static int Cond; // CHECK-NEXT: typeLeak of returned object // CHECK-NEXT: issue_context_kindObjective-C method // CHECK-NEXT: issue_contextgetViolation -// CHECK-NEXT: issue_hash2 +// CHECK-NEXT: issue_hash1 // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line135 @@ -5333,7 +5333,7 @@ static int Cond; // CHECK-NEXT: typeLeak // CHECK-NEXT: issue_context_kindObjective-C method // CHECK-NEXT: issue_contexttest -// CHECK-NEXT: issue_hash13 +// CHECK-NEXT: issue_hash8 // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line236