Overhaul BugReporter interface and implementation. The new interface cleans up
the ownership of BugTypes and BugReports. Now BugReports are owned by BugTypes,
and BugTypes are owned by the BugReporter object.

The major functionality change in this patch is that reports are not immediately
emitted by a call to BugReporter::EmitWarning (now called EmitReport), but
instead of queued up in report "equivalence classes". When
BugReporter::FlushReports() is called, it emits one diagnostic per report
equivalence class. This provides a nice cleanup with the caching of reports as
well as enables the BugReporter engine to select the "best" path for reporting a
path-sensitive bug based on all the locations in the ExplodedGraph that the same
bug could occur.

Along with this patch, Leaks are now coalesced into a common equivalence class
by their allocation site, and the "summary" diagnostic for leaks now reports the
allocation site as the location of the bug (this may later be augmented to also
provide an example location where the leak occurs).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63796 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Analysis/CFDateGC.m b/test/Analysis/CFDateGC.m
index c405fe2..f4f75e9 100644
--- a/test/Analysis/CFDateGC.m
+++ b/test/Analysis/CFDateGC.m
@@ -70,8 +70,8 @@
 }
 
 void f3_leak_with_gc() {
-  CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent());
-  [[(id) date retain] release]; // expected-warning{{leak}}
+  CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning{{leak}}
+  [[(id) date retain] release];
 }
 
 // The following test case verifies that we "stop tracking" a retained object
diff --git a/test/Analysis/CGColorSpace.c b/test/Analysis/CGColorSpace.c
index a46448c..b229bd2 100644
--- a/test/Analysis/CGColorSpace.c
+++ b/test/Analysis/CGColorSpace.c
@@ -7,8 +7,8 @@
 extern void CGColorSpaceRelease(CGColorSpaceRef space);
 
 void f() {
-  CGColorSpaceRef X = CGColorSpaceCreateDeviceRGB();
-  CGColorSpaceRetain(X);  // expected-warning{{leak}}
+  CGColorSpaceRef X = CGColorSpaceCreateDeviceRGB(); // expected-warning{{leak}}
+  CGColorSpaceRetain(X);
 }
 
 void fb() {
diff --git a/test/Analysis/NSPanel.m b/test/Analysis/NSPanel.m
index 5f9f26c..7e2d0a8 100644
--- a/test/Analysis/NSPanel.m
+++ b/test/Analysis/NSPanel.m
@@ -80,9 +80,9 @@
 }
 - (void)myMethod2
 {
-  NSPanel *panel = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:(BOOL)1];
+  NSPanel *panel = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:(BOOL)1]; // expected-warning{{leak}}
 
-  [panels addObject:panel]; // expected-warning{{leak}}  
+  [panels addObject:panel];  
 }
 @end
 
diff --git a/test/Analysis/NSString.m b/test/Analysis/NSString.m
index b123d62..297c63d 100644
--- a/test/Analysis/NSString.m
+++ b/test/Analysis/NSString.m
@@ -109,12 +109,12 @@
 NSString* f7(NSString* s1, NSString* s2, NSString* s3) {
 
   NSString* s4 = (NSString*)
-    CFStringCreateWithFormat(kCFAllocatorDefault, 0,
+    CFStringCreateWithFormat(kCFAllocatorDefault, 0,  // expected-warning{{leak}}
                              (CFStringRef) __builtin___CFStringMakeConstantString("%@ %@ (%@)"), 
                              s1, s2, s3);
 
   CFRetain(s4);
-  return s4; // expected-warning{{leak}}
+  return s4;
 }
 
 NSMutableArray* f8() {
diff --git a/test/Analysis/NSWindow.m b/test/Analysis/NSWindow.m
index bcb6c41..33d7752 100644
--- a/test/Analysis/NSWindow.m
+++ b/test/Analysis/NSWindow.m
@@ -67,7 +67,7 @@
 }
 
 void f2b() {
-  NSWindow *window = [[NSWindow alloc]
+  NSWindow *window = [[NSWindow alloc] // expected-warning{{leak}}
                       initWithContentRect:NSMakeRect(0,0,100,100) 
                         styleMask:NSTitledWindowMask|NSClosableWindowMask
                         backing:NSBackingStoreBuffered
@@ -76,7 +76,7 @@
 
   [window orderFrontRegardless];
   
-  [window retain]; // expected-warning{{leak}}
+  [window retain];
 }
 
 
diff --git a/test/Analysis/refcnt_naming.m b/test/Analysis/refcnt_naming.m
index 44ccf27..0fa95eb 100644
--- a/test/Analysis/refcnt_naming.m
+++ b/test/Analysis/refcnt_naming.m
@@ -23,8 +23,8 @@
 
 - (NSURL *)myMethod:(NSString *)inString
 {
-  NSURL *url = (NSURL *)CFURLCreateWithString(0, (CFStringRef)inString, 0);
-  return url; // expected-warning{{leak}}
+  NSURL *url = (NSURL *)CFURLCreateWithString(0, (CFStringRef)inString, 0); // expected-warning{{leak}}
+  return url;
 }
 
 - (NSURL *)getMethod:(NSString *)inString
diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m
index 66ff991..9a5a855 100644
--- a/test/Analysis/retain-release.m
+++ b/test/Analysis/retain-release.m
@@ -130,28 +130,28 @@
 
 CFAbsoluteTime f5(int x) {  
   CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
-  CFDateRef date = CFDateCreate(0, t);
+  CFDateRef date = CFDateCreate(0, t); // expected-warning{{leak}}
   
   if (x)
     CFRelease(date);
   
-  return t; // expected-warning{{leak}}
+  return t;
 }
 
 // Test a leak involving the return.
 
 CFDateRef f6(int x) {  
-  CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent());
+  CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent());  // expected-warning{{leak}}
   CFRetain(date);
-  return date; // expected-warning{{leak}}
+  return date;
 }
 
 // Test a leak involving an overwrite.
 
 CFDateRef f7() {
-  CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent());
+  CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent());  //expected-warning{{leak}}
   CFRetain(date);
-  date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); //expected-warning{{leak}}
+  date = CFDateCreate(0, CFAbsoluteTimeGetCurrent());
   return date;
 }
 
@@ -160,9 +160,9 @@
 CFDateRef MyDateCreate();
 
 CFDateRef f8() {
-  CFDateRef date = MyDateCreate();
+  CFDateRef date = MyDateCreate(); // expected-warning{{leak}}
   CFRetain(date);  
-  return date; // expected-warning{{leak}}
+  return date;
 }
 
 CFDateRef f9() {
@@ -179,24 +179,24 @@
 // http://developer.apple.com/DOCUMENTATION/DARWIN/Reference/DiscArbitrationFramework/
 //
 void f10(io_service_t media, DADiskRef d, CFStringRef s) {
-  DADiskRef disk = DADiskCreateFromBSDName(kCFAllocatorDefault, 0, "hello");
-  if (disk) NSLog(@"ok"); // expected-warning{{leak}}
+  DADiskRef disk = DADiskCreateFromBSDName(kCFAllocatorDefault, 0, "hello"); // expected-warning{{leak}}
+  if (disk) NSLog(@"ok");
   
-  disk = DADiskCreateFromIOMedia(kCFAllocatorDefault, 0, media);
-  if (disk) NSLog(@"ok"); // expected-warning{{leak}}
+  disk = DADiskCreateFromIOMedia(kCFAllocatorDefault, 0, media); // expected-warning{{leak}}
+  if (disk) NSLog(@"ok");
 
-  CFDictionaryRef dict = DADiskCopyDescription(d); 
-  if (dict) NSLog(@"ok"); // expected-warning{{leak}}
+  CFDictionaryRef dict = DADiskCopyDescription(d);  // expected-warning{{leak}}
+  if (dict) NSLog(@"ok"); 
   
-  disk = DADiskCopyWholeDisk(d);
-  if (disk) NSLog(@"ok"); // expected-warning{{leak}}
+  disk = DADiskCopyWholeDisk(d); // expected-warning{{leak}}
+  if (disk) NSLog(@"ok");
     
-  DADissenterRef dissenter = DADissenterCreate(kCFAllocatorDefault,
+  DADissenterRef dissenter = DADissenterCreate(kCFAllocatorDefault,   // expected-warning{{leak}}
                                                 kDAReturnSuccess, s);
-  if (dissenter) NSLog(@"ok"); // expected-warning{{leak}}
+  if (dissenter) NSLog(@"ok");
   
-  DASessionRef session = DASessionCreate(kCFAllocatorDefault);
-  if (session) NSLog(@"ok"); // expected-warning{{leak}}
+  DASessionRef session = DASessionCreate(kCFAllocatorDefault);  // expected-warning{{leak}}
+  if (session) NSLog(@"ok");
 }
 
 // Test retain/release checker with CFString and CFMutableArray.