Fix leak in ObjCSelfInitChecker, found by LSan.

BugReport doesn't take ownership of the bug type, so let the checker own the
the bug type.  (Requires making the bug type mutable, which is icky, but which
is also what other checkers do.)

llvm-svn: 208110
diff --git a/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
index 6c33084..3eec681 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
@@ -55,6 +55,13 @@
 static bool isSelfVar(SVal location, CheckerContext &C);
 
 namespace {
+class InitSelfBug : public BugType {
+public:
+  InitSelfBug(const CheckerBase *Checker)
+      : BugType(Checker, "Missing \"self = [(super or self) init...]\"",
+                categories::CoreFoundationObjectiveC) {}
+};
+
 class ObjCSelfInitChecker : public Checker<  check::PostObjCMessage,
                                              check::PostStmt<ObjCIvarRefExpr>,
                                              check::PreStmt<ReturnStmt>,
@@ -62,7 +69,13 @@
                                              check::PostCall,
                                              check::Location,
                                              check::Bind > {
+  mutable InitSelfBug InitSelfBugType;
+
+  void checkForInvalidSelf(const Expr *E, CheckerContext &C,
+                           const char *errorStr) const;
+
 public:
+  ObjCSelfInitChecker() : InitSelfBugType(this) {}
   void checkPostObjCMessage(const ObjCMethodCall &Msg, CheckerContext &C) const;
   void checkPostStmt(const ObjCIvarRefExpr *E, CheckerContext &C) const;
   void checkPreStmt(const ReturnStmt *S, CheckerContext &C) const;
@@ -79,17 +92,6 @@
 } // end anonymous namespace
 
 namespace {
-
-class InitSelfBug : public BugType {
-public:
-  InitSelfBug(const CheckerBase *Checker)
-      : BugType(Checker, "Missing \"self = [(super or self) init...]\"",
-                categories::CoreFoundationObjectiveC) {}
-};
-
-} // end anonymous namespace
-
-namespace {
 enum SelfFlagEnum {
   /// \brief No flag set.
   SelfFlag_None = 0x0,
@@ -146,9 +148,8 @@
   return true;
 }
 
-static void checkForInvalidSelf(const Expr *E, CheckerContext &C,
-                                const char *errorStr,
-                                const CheckerBase *Checker) {
+void ObjCSelfInitChecker::checkForInvalidSelf(const Expr *E, CheckerContext &C,
+                                              const char *errorStr) const {
   if (!E)
     return;
   
@@ -163,7 +164,7 @@
   if (!N)
     return;
 
-  BugReport *report = new BugReport(*new InitSelfBug(Checker), errorStr, N);
+  BugReport *report = new BugReport(InitSelfBugType, errorStr, N);
   C.emitReport(report);
 }
 
@@ -208,8 +209,7 @@
   checkForInvalidSelf(
       E->getBase(), C,
       "Instance variable used while 'self' is not set to the result of "
-      "'[(super or self) init...]'",
-      this);
+      "'[(super or self) init...]'");
 }
 
 void ObjCSelfInitChecker::checkPreStmt(const ReturnStmt *S,
@@ -221,8 +221,7 @@
 
   checkForInvalidSelf(S->getRetValue(), C,
                       "Returning 'self' while it is not set to the result of "
-                      "'[(super or self) init...]'",
-                      this);
+                      "'[(super or self) init...]'");
 }
 
 // When a call receives a reference to 'self', [Pre/Post]Call pass