Index: include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
===================================================================
--- include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h	(revision 240274)
+++ include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h	(working copy)
@@ -464,7 +464,7 @@
   /// The reports are usually generated by the checkers. Further, they are
   /// folded based on the profile value, which is done to coalesce similar
   /// reports.
-  void emitReport(BugReport *R);
+  void emitReport(std::unique_ptr<BugReport> &R);
 
   void EmitBasicReport(const Decl *DeclWithIssue, const CheckerBase *Checker,
                        StringRef BugName, StringRef BugCategory,
Index: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
===================================================================
--- include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h	(revision 240274)
+++ include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h	(working copy)
@@ -232,7 +232,7 @@
   }
 
   /// \brief Emit the diagnostics report.
-  void emitReport(BugReport *R) {
+  void emitReport(std::unique_ptr<BugReport> &R) {
     Changed = true;
     Eng.getBugReporter().emitReport(R);
   }
Index: lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp	(working copy)
@@ -76,8 +76,7 @@
     // reference is outside the range.
 
     // Generate a report for this bug.
-    BugReport *report = 
-      new BugReport(*BT, BT->getDescription(), N);
+    auto report = std::make_unique<BugReport>(*BT, BT->getDescription(), N);
 
     report->addRange(LoadS->getSourceRange());
     C.emitReport(report);
Index: lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp	(working copy)
@@ -207,7 +207,8 @@
     break;
   }
 
-  checkerContext.emitReport(new BugReport(*BT, os.str(), errorNode));
+  auto R = std::make_unique<BugReport>(*BT, os.str(), errorNode);
+  checkerContext.emitReport(R);
 }
 
 void RegionRawOffsetV2::dump() const {
Index: lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp	(working copy)
@@ -207,7 +207,7 @@
   if (!BT)
     BT.reset(new APIMisuse(this, "nil argument"));
 
-  BugReport *R = new BugReport(*BT, Msg, N);
+  auto R = std::make_unique<BugReport>(*BT, Msg, N);
   R->addRange(Range);
   bugreporter::trackNullOrUndefValue(N, E, *R);
   C.emitReport(R);
@@ -516,7 +516,7 @@
     if (!BT)
       BT.reset(new APIMisuse(this, "Bad use of CFNumberCreate"));
 
-    BugReport *report = new BugReport(*BT, os.str(), N);
+    auto report = std::make_unique<BugReport>(*BT, os.str(), N);
     report->addRange(CE->getArg(2)->getSourceRange());
     C.emitReport(report);
   }
@@ -605,7 +605,7 @@
     else
       llvm_unreachable("impossible case");
 
-    BugReport *report = new BugReport(*BT, description, N);
+    auto report = std::make_unique<BugReport>(*BT, description, N);
     report->addRange(Arg->getSourceRange());
     bugreporter::trackNullOrUndefValue(N, Arg, *report);
     C.emitReport(report);
@@ -666,7 +666,7 @@
           "of class '" << Class->getName()
        << "' and not the class directly";
   
-    BugReport *report = new BugReport(*BT, os.str(), N);
+    auto report = std::make_unique<BugReport>(*BT, os.str(), N);
     report->addRange(msg.getSourceRange());
     C.emitReport(report);
   }
@@ -819,7 +819,7 @@
     ArgTy.print(os, C.getLangOpts());
     os << "'";
 
-    BugReport *R = new BugReport(*BT, os.str(), errorNode.getValue());
+    auto R = std::make_unique<BugReport>(*BT, os.str(), errorNode.getValue());
     R->addRange(msg.getArgSourceRange(I));
     C.emitReport(R);
   }
Index: lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp	(working copy)
@@ -35,7 +35,8 @@
   if (ExplodedNode *N = C.addTransition(state)) {
     if (!BT)
       BT.reset(new BuiltinBug(this, "Assignment of a non-Boolean value"));
-    C.emitReport(new BugReport(*BT, BT->getDescription(), N));
+    auto R = std::make_unique<BugReport>(*BT, BT->getDescription(), N);
+    C.emitReport(R);
   }
 }
 
Index: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp	(working copy)
@@ -94,7 +94,7 @@
   if (!N)
     return;
 
-  BugReport *R = new BugReport(*BT, BT->getName(), N);
+  auto R = std::make_unique<BugReport>(*BT, BT->getName(), N);
   if (BadE) {
     R->addRange(BadE->getSourceRange());
     if (BadE->isGLValue())
@@ -164,7 +164,7 @@
     if (PSV.isUndef()) {
       if (ExplodedNode *N = C.generateSink()) {
         LazyInit_BT(BD, BT);
-        BugReport *R = new BugReport(*BT, Message, N);
+        auto R = std::make_unique<BugReport>(*BT, Message, N);
         R->addRange(ArgRange);
         if (ArgEx) {
           bugreporter::trackNullOrUndefValue(N, ArgEx, *R);
@@ -199,7 +199,7 @@
       // Generate a report for this bug.
       StringRef Desc =
           describeUninitializedArgumentInCall(Call, IsFirstArgument);
-      BugReport *R = new BugReport(*BT, Desc, N);
+      auto R = std::make_unique<BugReport>(*BT, Desc, N);
       R->addRange(ArgRange);
       if (ArgEx)
         bugreporter::trackNullOrUndefValue(N, ArgEx, *R);
@@ -281,7 +281,7 @@
         }
 
         // Generate a report for this bug.
-        BugReport *R = new BugReport(*BT, os.str(), N);
+        auto R = std::make_unique<BugReport>(*BT, os.str(), N);
         R->addRange(ArgRange);
 
         // FIXME: enhance track back for uninitialized value for arbitrary
@@ -342,7 +342,7 @@
     else
       Desc = "Argument to 'delete' is uninitialized";
     BugType *BT = BT_cxx_delete_undef.get();
-    BugReport *R = new BugReport(*BT, Desc, N);
+    auto R = std::make_unique<BugReport>(*BT, Desc, N);
     bugreporter::trackNullOrUndefValue(N, DE, *R);
     C.emitReport(R);
     return;
@@ -400,7 +400,7 @@
          << (Params == 1 ? "" : "s") << " is called with less ("
          << Call.getNumArgs() << ")";
 
-      BugReport *R = new BugReport(*BT_call_few_args, os.str(), N);
+      auto R = std::make_unique<BugReport>(*BT_call_few_args, os.str(), N);
       C.emitReport(R);
     }
   }
@@ -461,7 +461,7 @@
       }
       assert(BT && "Unknown message kind.");
 
-      BugReport *R = new BugReport(*BT, BT->getName(), N);
+      auto R = std::make_unique<BugReport>(*BT, BT->getName(), N);
       const ObjCMessageExpr *ME = msg.getOriginExpr();
       R->addRange(ME->getReceiverRange());
 
@@ -512,7 +512,7 @@
     os << "' that will be garbage";
   }
 
-  BugReport *report = new BugReport(*BT_msg_ret, os.str(), N);
+  auto report = std::make_unique<BugReport>(*BT_msg_ret, os.str(), N);
   report->addRange(ME->getReceiverRange());
   // FIXME: This won't track "self" in messages to super.
   if (const Expr *receiver = ME->getInstanceReceiver()) {
Index: lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp	(working copy)
@@ -136,7 +136,7 @@
       BT.reset(new BuiltinBug(this, "Cast region with wrong size.",
                                     "Cast a region whose size is not a multiple"
                                     " of the destination type size."));
-    BugReport *R = new BugReport(*BT, BT->getDescription(), errorNode);
+    auto R = std::make_unique<BugReport>(*BT, BT->getDescription(), errorNode);
     R->addRange(CE->getSourceRange());
     C.emitReport(R);
   }
Index: lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp	(working copy)
@@ -63,7 +63,7 @@
                            "Casting a non-structure type to a structure type "
                            "and accessing a field can lead to memory access "
                            "errors or data corruption."));
-      BugReport *R = new BugReport(*BT,BT->getDescription(), N);
+      auto R = std::make_unique<BugReport>(*BT, BT->getDescription(), N);
       R->addRange(CE->getSourceRange());
       C.emitReport(R);
     }
Index: lib/StaticAnalyzer/Checkers/ChrootChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/ChrootChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/ChrootChecker.cpp	(working copy)
@@ -145,8 +145,8 @@
           BT_BreakJail.reset(new BuiltinBug(
               this, "Break out of jail", "No call of chdir(\"/\") immediately "
                                          "after chroot"));
-        BugReport *R = new BugReport(*BT_BreakJail, 
-                                     BT_BreakJail->getDescription(), N);
+        auto R = std::make_unique<BugReport>(*BT_BreakJail,
+                                             BT_BreakJail->getDescription(), N);
         C.emitReport(R);
       }
   
Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/CStringChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp	(working copy)
@@ -245,7 +245,7 @@
 
     // Generate a report for this bug.
     BuiltinBug *BT = static_cast<BuiltinBug*>(BT_Null.get());
-    BugReport *report = new BugReport(*BT, os.str(), N);
+    auto report = std::make_unique<BugReport>(*BT, os.str(), N);
 
     report->addRange(S->getSourceRange());
     bugreporter::trackNullOrUndefValue(N, S, *report);
@@ -304,9 +304,9 @@
     BuiltinBug *BT = static_cast<BuiltinBug*>(BT_Bounds.get());
 
     // Generate a report for this bug.
-    BugReport *report;
+    std::unique_ptr<BugReport> report;
     if (warningMsg) {
-      report = new BugReport(*BT, warningMsg, N);
+      report = std::make_unique<BugReport>(*BT, warningMsg, N);
     } else {
       assert(CurrentFunctionDescription);
       assert(CurrentFunctionDescription[0] != '\0');
@@ -316,7 +316,7 @@
       os << toUppercase(CurrentFunctionDescription[0])
          << &CurrentFunctionDescription[1]
          << " accesses out-of-bound array element";
-      report = new BugReport(*BT, os.str(), N);      
+      report = std::make_unique<BugReport>(*BT, os.str(), N);
     }
 
     // FIXME: It would be nice to eventually make this diagnostic more clear,
@@ -534,9 +534,8 @@
                                  categories::UnixAPI, "Improper arguments"));
 
   // Generate a report for this bug.
-  BugReport *report = 
-    new BugReport(*BT_Overlap,
-      "Arguments must not be overlapping buffers", N);
+  auto report = std::make_unique<BugReport>(
+      *BT_Overlap, "Arguments must not be overlapping buffers", N);
   report->addRange(First->getSourceRange());
   report->addRange(Second->getSourceRange());
 
@@ -603,8 +602,9 @@
         "be represented as a size_t";
 
       // Generate a report for this bug.
-      BugReport *report = new BugReport(*BT_AdditionOverflow, warning, N);
-      C.emitReport(report);        
+      auto report =
+          std::make_unique<BugReport>(*BT_AdditionOverflow, warning, N);
+      C.emitReport(report);
 
       return nullptr;
     }
@@ -721,7 +721,7 @@
            << "', which is not a null-terminated string";
 
         // Generate a report for this bug.
-        BugReport *report = new BugReport(*BT_NotCString, os.str(), N);
+        auto report = std::make_unique<BugReport>(*BT_NotCString, os.str(), N);
 
         report->addRange(Ex->getSourceRange());
         C.emitReport(report);        
@@ -785,8 +785,7 @@
         os << "not a null-terminated string";
 
       // Generate a report for this bug.
-      BugReport *report = new BugReport(*BT_NotCString,
-                                                        os.str(), N);
+      auto report = std::make_unique<BugReport>(*BT_NotCString, os.str(), N);
 
       report->addRange(Ex->getSourceRange());
       C.emitReport(report);        
Index: lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp	(working copy)
@@ -160,10 +160,8 @@
   }
 
   os.flush();
-  BugReport *report =
-    new BugReport(*BT_null,
-                  buf.empty() ? BT_null->getDescription() : StringRef(buf),
-                  N);
+  auto report = std::make_unique<BugReport>(
+      *BT_null, buf.empty() ? BT_null->getDescription() : StringRef(buf), N);
 
   bugreporter::trackNullOrUndefValue(N, bugreporter::getDerefExpr(S), *report);
 
@@ -183,8 +181,8 @@
         BT_undef.reset(
             new BuiltinBug(this, "Dereference of undefined pointer value"));
 
-      BugReport *report =
-        new BugReport(*BT_undef, BT_undef->getDescription(), N);
+      auto report =
+          std::make_unique<BugReport>(*BT_undef, BT_undef->getDescription(), N);
       bugreporter::trackNullOrUndefValue(N, bugreporter::getDerefExpr(S),
                                          *report);
       C.emitReport(report);
Index: lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp	(working copy)
@@ -39,7 +39,7 @@
     if (!BT)
       BT.reset(new BuiltinBug(this, "Division by zero"));
 
-    BugReport *R = new BugReport(*BT, Msg, N);
+    auto R = std::make_unique<BugReport>(*BT, Msg, N);
     bugreporter::trackNullOrUndefValue(N, bugreporter::GetDenomExpr(N), *R);
     C.emitReport(R);
   }
Index: lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp	(working copy)
@@ -97,7 +97,7 @@
   if (!BT)
     BT.reset(new BugType(this, "Checking analyzer assumptions", "debug"));
 
-  BugReport *R = new BugReport(*BT, getArgumentValueString(CE, C), N);
+  auto R = std::make_unique<BugReport>(*BT, getArgumentValueString(CE, C), N);
   C.emitReport(R);
 }
 
@@ -108,7 +108,7 @@
   if (!BT)
     BT.reset(new BugType(this, "Checking analyzer assumptions", "debug"));
 
-  BugReport *R = new BugReport(*BT, "REACHABLE", N);
+  auto R = std::make_unique<BugReport>(*BT, "REACHABLE", N);
   C.emitReport(R);
 }
 
@@ -128,7 +128,7 @@
   if (!BT)
     BT.reset(new BugType(this, "Checking analyzer assumptions", "debug"));
 
-  BugReport *R = new BugReport(*BT, getArgumentValueString(CE, C), N);
+  auto R = std::make_unique<BugReport>(*BT, getArgumentValueString(CE, C), N);
   C.emitReport(R);
 }
 
Index: lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp	(working copy)
@@ -57,7 +57,7 @@
                          "Using a fixed address is not portable because that "
                          "address will probably not be valid in all "
                          "environments or platforms."));
-    BugReport *R = new BugReport(*BT, BT->getDescription(), N);
+    auto R = std::make_unique<BugReport>(*BT, BT->getDescription(), N);
     R->addRange(B->getRHS()->getSourceRange());
     C.emitReport(R);
   }
Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp	(working copy)
@@ -642,7 +642,7 @@
   // Generate diagnostic.
   if (ExplodedNode *N = C.addTransition()) {
     initBugType();
-    BugReport *report = new BugReport(*BT, Msg, N);
+    auto report = std::make_unique<BugReport>(*BT, Msg, N);
     report->addRange(E->getSourceRange());
     C.emitReport(report);
     return true;
Index: lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp	(working copy)
@@ -103,9 +103,8 @@
   const ExplodedNode *getAllocationNode(const ExplodedNode *N, SymbolRef Sym,
                                         CheckerContext &C) const;
 
-  BugReport *generateAllocatedDataNotReleasedReport(const AllocationPair &AP,
-                                                    ExplodedNode *N,
-                                                    CheckerContext &C) const;
+  std::unique_ptr<BugReport> generateAllocatedDataNotReleasedReport(
+      const AllocationPair &AP, ExplodedNode *N, CheckerContext &C) const;
 
   /// Check if RetSym evaluates to an error value in the current state.
   bool definitelyReturnedError(SymbolRef RetSym,
@@ -269,10 +268,10 @@
 
   os << "Deallocator doesn't match the allocator: '"
      << FunctionsToTrack[PDeallocIdx].Name << "' should be used.";
-  BugReport *Report = new BugReport(*BT, os.str(), N);
+  auto Report = std::make_unique<BugReport>(*BT, os.str(), N);
   Report->addVisitor(llvm::make_unique<SecKeychainBugVisitor>(AP.first));
   Report->addRange(ArgExpr->getSourceRange());
-  markInteresting(Report, AP);
+  markInteresting(Report.get(), AP);
   C.emitReport(Report);
 }
 
@@ -314,7 +313,7 @@
               << "the allocator: missing a call to '"
               << FunctionsToTrack[DIdx].Name
               << "'.";
-          BugReport *Report = new BugReport(*BT, os.str(), N);
+          auto Report = std::make_unique<BugReport>(*BT, os.str(), N);
           Report->addVisitor(llvm::make_unique<SecKeychainBugVisitor>(V));
           Report->addRange(ArgExpr->getSourceRange());
           Report->markInteresting(AS->Region);
@@ -370,8 +369,8 @@
     if (!N)
       return;
     initBugType();
-    BugReport *Report = new BugReport(*BT,
-        "Trying to free data which has not been allocated.", N);
+    auto Report = std::make_unique<BugReport>(
+        *BT, "Trying to free data which has not been allocated.", N);
     Report->addRange(ArgExpr->getSourceRange());
     if (AS)
       Report->markInteresting(AS->Region);
@@ -436,8 +435,8 @@
     if (!N)
       return;
     initBugType();
-    BugReport *Report = new BugReport(*BT,
-        "Only call free if a valid (non-NULL) buffer was returned.", N);
+    auto Report = std::make_unique<BugReport>(
+        *BT, "Only call free if a valid (non-NULL) buffer was returned.", N);
     Report->addVisitor(llvm::make_unique<SecKeychainBugVisitor>(ArgSM));
     Report->addRange(ArgExpr->getSourceRange());
     Report->markInteresting(AS->Region);
@@ -519,10 +518,9 @@
   return AllocNode;
 }
 
-BugReport *MacOSKeychainAPIChecker::
-  generateAllocatedDataNotReleasedReport(const AllocationPair &AP,
-                                         ExplodedNode *N,
-                                         CheckerContext &C) const {
+std::unique_ptr<BugReport>
+MacOSKeychainAPIChecker::generateAllocatedDataNotReleasedReport(
+    const AllocationPair &AP, ExplodedNode *N, CheckerContext &C) const {
   const ADFunctionInfo &FI = FunctionsToTrack[AP.second->AllocatorIdx];
   initBugType();
   SmallString<70> sbuf;
@@ -547,11 +545,12 @@
                                               C.getSourceManager(),
                                               AllocNode->getLocationContext());
 
-  BugReport *Report = new BugReport(*BT, os.str(), N, LocUsedForUniqueing,
-                                   AllocNode->getLocationContext()->getDecl());
+  auto Report =
+      std::make_unique<BugReport>(*BT, os.str(), N, LocUsedForUniqueing,
+                                  AllocNode->getLocationContext()->getDecl());
 
   Report->addVisitor(llvm::make_unique<SecKeychainBugVisitor>(AP.first));
-  markInteresting(Report, AP);
+  markInteresting(Report.get(), AP);
   return Report;
 }
 
@@ -589,9 +588,9 @@
   ExplodedNode *N = C.addTransition(C.getState(), C.getPredecessor(), &Tag);
 
   // Generate the error reports.
-  for (AllocationPairVec::iterator I = Errors.begin(), E = Errors.end();
-                                                       I != E; ++I) {
-    C.emitReport(generateAllocatedDataNotReleasedReport(*I, N, C));
+  for (const auto P : Errors) {
+    auto R = generateAllocatedDataNotReleasedReport(P, N, C);
+    C.emitReport(R);
   }
 
   // Generate the new, cleaned up state.
Index: lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp	(working copy)
@@ -92,7 +92,7 @@
   if (isa<VarRegion>(R) && isa<StackLocalsSpaceRegion>(R->getMemorySpace()))
     os << "  Perhaps you intended to declare the variable as 'static'?";
 
-  BugReport *report = new BugReport(*BT_dispatchOnce, os.str(), N);
+  auto report = std::make_unique<BugReport>(*BT_dispatchOnce, os.str(), N);
   report->addRange(CE->getArg(0)->getSourceRange());
   C.emitReport(report);
 }
Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/MallocChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp	(working copy)
@@ -1619,7 +1619,7 @@
 
     printExpectedAllocName(os, C, DeallocExpr);
 
-    BugReport *R = new BugReport(*BT_BadFree[*CheckKind], os.str(), N);
+    auto R = std::make_unique<BugReport>(*BT_BadFree[*CheckKind], os.str(), N);
     R->markInteresting(MR);
     R->addRange(Range);
     C.emitReport(R);
@@ -1643,8 +1643,9 @@
       BT_FreeAlloca[*CheckKind].reset(
           new BugType(CheckNames[*CheckKind], "Free alloca()", "Memory Error"));
 
-    BugReport *R = new BugReport(*BT_FreeAlloca[*CheckKind], 
-                 "Memory allocated by alloca() should not be deallocated", N);
+    auto R = std::make_unique<BugReport>(
+        *BT_FreeAlloca[*CheckKind],
+        "Memory allocated by alloca() should not be deallocated", N);
     R->markInteresting(ArgVal.getAsRegion());
     R->addRange(Range);
     C.emitReport(R);
@@ -1698,7 +1699,7 @@
         os << ", not " << DeallocOs.str();
     }
 
-    BugReport *R = new BugReport(*BT_MismatchedDealloc, os.str(), N);
+    auto R = std::make_unique<BugReport>(*BT_MismatchedDealloc, os.str(), N);
     R->markInteresting(Sym);
     R->addRange(Range);
     R->addVisitor(llvm::make_unique<MallocBugVisitor>(Sym));
@@ -1757,7 +1758,7 @@
   else
     os << "allocated memory";
 
-  BugReport *R = new BugReport(*BT_OffsetFree[*CheckKind], os.str(), N);
+  auto R = std::make_unique<BugReport>(*BT_OffsetFree[*CheckKind], os.str(), N);
   R->markInteresting(MR->getBaseRegion());
   R->addRange(Range);
   C.emitReport(R);
@@ -1779,8 +1780,8 @@
       BT_UseFree[*CheckKind].reset(new BugType(
           CheckNames[*CheckKind], "Use-after-free", "Memory Error"));
 
-    BugReport *R = new BugReport(*BT_UseFree[*CheckKind],
-                                 "Use of memory after it is freed", N);
+    auto R = std::make_unique<BugReport>(*BT_UseFree[*CheckKind],
+                                         "Use of memory after it is freed", N);
 
     R->markInteresting(Sym);
     R->addRange(Range);
@@ -1806,11 +1807,11 @@
       BT_DoubleFree[*CheckKind].reset(
           new BugType(CheckNames[*CheckKind], "Double free", "Memory Error"));
 
-    BugReport *R =
-        new BugReport(*BT_DoubleFree[*CheckKind],
-                      (Released ? "Attempt to free released memory"
-                                : "Attempt to free non-owned memory"),
-                      N);
+    auto R = std::make_unique<BugReport>(
+        *BT_DoubleFree[*CheckKind],
+        (Released ? "Attempt to free released memory"
+                  : "Attempt to free non-owned memory"),
+        N);
     R->addRange(Range);
     R->markInteresting(Sym);
     if (PrevSym)
@@ -1834,8 +1835,8 @@
       BT_DoubleDelete.reset(new BugType(CheckNames[CK_NewDeleteChecker],
                                         "Double delete", "Memory Error"));
 
-    BugReport *R = new BugReport(*BT_DoubleDelete,
-                                 "Attempt to delete released memory", N);
+    auto R = std::make_unique<BugReport>(
+        *BT_DoubleDelete, "Attempt to delete released memory", N);
 
     R->markInteresting(Sym);
     R->addVisitor(llvm::make_unique<MallocBugVisitor>(Sym));
@@ -1861,8 +1862,8 @@
       BT_UseZerroAllocated[*CheckKind].reset(new BugType(
           CheckNames[*CheckKind], "Use of zero allocated", "Memory Error"));
 
-    BugReport *R = new BugReport(*BT_UseZerroAllocated[*CheckKind],
-                                 "Use of zero-allocated memory", N);
+    auto R = std::make_unique<BugReport>(*BT_UseZerroAllocated[*CheckKind],
+                                         "Use of zero-allocated memory", N);
 
     R->addRange(Range);
     if (Sym) {
@@ -2099,9 +2100,9 @@
     os << "Potential memory leak";
   }
 
-  BugReport *R =
-      new BugReport(*BT_Leak[*CheckKind], os.str(), N, LocUsedForUniqueing,
-                    AllocNode->getLocationContext()->getDecl());
+  auto R = std::make_unique<BugReport>(
+      *BT_Leak[*CheckKind], os.str(), N, LocUsedForUniqueing,
+      AllocNode->getLocationContext()->getDecl());
   R->markInteresting(Sym);
   R->addVisitor(llvm::make_unique<MallocBugVisitor>(Sym, true));
   C.emitReport(R);
Index: lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp	(working copy)
@@ -36,10 +36,11 @@
 
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
 
-  BugReport *genReportNullAttrNonNull(const ExplodedNode *ErrorN,
-                                      const Expr *ArgE) const;
-  BugReport *genReportReferenceToNullPointer(const ExplodedNode *ErrorN,
-                                             const Expr *ArgE) const;
+  std::unique_ptr<BugReport>
+  genReportNullAttrNonNull(const ExplodedNode *ErrorN, const Expr *ArgE) const;
+  std::unique_ptr<BugReport>
+  genReportReferenceToNullPointer(const ExplodedNode *ErrorN,
+                                  const Expr *ArgE) const;
 };
 } // end anonymous namespace
 
@@ -143,7 +144,7 @@
       // we cache out.
       if (ExplodedNode *errorNode = C.generateSink(stateNull)) {
 
-        BugReport *R = nullptr;
+        std::unique_ptr<BugReport> R;
         if (haveAttrNonNull)
           R = genReportNullAttrNonNull(errorNode, ArgE);
         else if (haveRefTypeParam)
@@ -171,8 +172,9 @@
   C.addTransition(state);
 }
 
-BugReport *NonNullParamChecker::genReportNullAttrNonNull(
-  const ExplodedNode *ErrorNode, const Expr *ArgE) const {
+std::unique_ptr<BugReport>
+NonNullParamChecker::genReportNullAttrNonNull(const ExplodedNode *ErrorNode,
+                                              const Expr *ArgE) const {
   // Lazily allocate the BugType object if it hasn't already been
   // created. Ownership is transferred to the BugReporter object once
   // the BugReport is passed to 'EmitWarning'.
@@ -180,9 +182,9 @@
     BTAttrNonNull.reset(new BugType(
         this, "Argument with 'nonnull' attribute passed null", "API"));
 
-  BugReport *R = new BugReport(*BTAttrNonNull,
-                  "Null pointer passed as an argument to a 'nonnull' parameter",
-                  ErrorNode);
+  auto R = std::make_unique<BugReport>(
+      *BTAttrNonNull,
+      "Null pointer passed as an argument to a 'nonnull' parameter", ErrorNode);
   if (ArgE)
     bugreporter::trackNullOrUndefValue(ErrorNode, ArgE, *R);
 
@@ -189,14 +191,13 @@
   return R;
 }
 
-BugReport *NonNullParamChecker::genReportReferenceToNullPointer(
-  const ExplodedNode *ErrorNode, const Expr *ArgE) const {
+std::unique_ptr<BugReport> NonNullParamChecker::genReportReferenceToNullPointer(
+    const ExplodedNode *ErrorNode, const Expr *ArgE) const {
   if (!BTNullRefArg)
     BTNullRefArg.reset(new BuiltinBug(this, "Dereference of null pointer"));
 
-  BugReport *R = new BugReport(*BTNullRefArg,
-                               "Forming reference to null pointer",
-                               ErrorNode);
+  auto R = std::make_unique<BugReport>(
+      *BTNullRefArg, "Forming reference to null pointer", ErrorNode);
   if (ArgE) {
     const Expr *ArgEDeref = bugreporter::getDerefExpr(ArgE);
     if (!ArgEDeref)
Index: lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp	(working copy)
@@ -68,8 +68,9 @@
     return;
   }
 
-  BugReport *Report = new BugReport(*BT, "Use -drain instead of -release when "
-    "using NSAutoreleasePool and garbage collection", N);
+  auto Report = std::make_unique<BugReport>(
+      *BT, "Use -drain instead of -release when using NSAutoreleasePool and "
+           "garbage collection", N);
   Report->addRange(msg.getSourceRange());
   C.emitReport(Report);
 }
Index: lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp	(working copy)
@@ -275,7 +275,7 @@
       CFBT.reset(new CFErrorDerefBug(this));
     bug = CFBT.get();
   }
-  BugReport *report = new BugReport(*bug, os.str(), event.SinkNode);
+  auto report = std::make_unique<BugReport>(*bug, os.str(), event.SinkNode);
   BR.emitReport(report);
 }
 
Index: lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp	(working copy)
@@ -47,8 +47,8 @@
       if (!BT_undef)
         BT_undef.reset(new BuiltinBug(this, "Uninitialized value used as mutex "
                                             "for @synchronized"));
-      BugReport *report =
-        new BugReport(*BT_undef, BT_undef->getDescription(), N);
+      auto report =
+          std::make_unique<BugReport>(*BT_undef, BT_undef->getDescription(), N);
       bugreporter::trackNullOrUndefValue(N, Ex, *report);
       C.emitReport(report);
     }
@@ -71,8 +71,8 @@
           BT_null.reset(new BuiltinBug(
               this, "Nil value used as mutex for @synchronized() "
                     "(no synchronization will occur)"));
-        BugReport *report =
-          new BugReport(*BT_null, BT_null->getDescription(), N);
+        auto report =
+            std::make_unique<BugReport>(*BT_null, BT_null->getDescription(), N);
         bugreporter::trackNullOrUndefValue(N, Ex, *report);
 
         C.emitReport(report);
Index: lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp	(working copy)
@@ -143,7 +143,7 @@
       if (!N)
         return;
       initBugType();
-      BugReport *R = new BugReport(*BT, "Index is out of bounds", N);
+      auto R = std::make_unique<BugReport>(*BT, "Index is out of bounds", N);
       R->addRange(IdxExpr->getSourceRange());
       C.emitReport(R);
       return;
Index: lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp	(working copy)
@@ -160,7 +160,7 @@
   if (!BT)
     BT.reset(new BugType(this, "Missing \"self = [(super or self) init...]\"",
                          categories::CoreFoundationObjectiveC));
-  BugReport *report = new BugReport(*BT, errorStr, N);
+  auto report = std::make_unique<BugReport>(*BT, errorStr, N);
   C.emitReport(report);
 }
 
Index: lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp	(working copy)
@@ -58,7 +58,7 @@
                            "Pointer arithmetic done on non-array variables "
                            "means reliance on memory layout, which is "
                            "dangerous."));
-      BugReport *R = new BugReport(*BT, BT->getDescription(), N);
+      auto R = std::make_unique<BugReport>(*BT, BT->getDescription(), N);
       R->addRange(B->getSourceRange());
       C.emitReport(R);
     }
Index: lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp	(working copy)
@@ -66,7 +66,7 @@
           new BuiltinBug(this, "Pointer subtraction",
                          "Subtraction of two pointers that do not point to "
                          "the same memory chunk may cause incorrect result."));
-    BugReport *R = new BugReport(*BT, BT->getDescription(), N);
+    auto R = std::make_unique<BugReport>(*BT, BT->getDescription(), N);
     R->addRange(B->getSourceRange());
     C.emitReport(R);
   }
Index: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp	(working copy)
@@ -145,9 +145,8 @@
       ExplodedNode *N = C.generateSink();
       if (!N)
         return;
-      BugReport *report = new BugReport(*BT_doublelock,
-                                        "This lock has already been acquired",
-                                        N);
+      auto report = std::make_unique<BugReport>(
+          *BT_doublelock, "This lock has already been acquired", N);
       report->addRange(CE->getArg(0)->getSourceRange());
       C.emitReport(report);
       return;
@@ -208,9 +207,8 @@
       ExplodedNode *N = C.generateSink();
       if (!N)
         return;
-      BugReport *Report = new BugReport(*BT_doubleunlock,
-                                        "This lock has already been unlocked",
-                                        N);
+      auto Report = std::make_unique<BugReport>(
+          *BT_doubleunlock, "This lock has already been unlocked", N);
       Report->addRange(CE->getArg(0)->getSourceRange());
       C.emitReport(Report);
       return;
@@ -232,11 +230,9 @@
       ExplodedNode *N = C.generateSink();
       if (!N)
         return;
-      BugReport *report = new BugReport(*BT_lor,
-                                        "This was not the most recently "
-                                        "acquired lock. Possible lock order "
-                                        "reversal",
-                                        N);
+      auto report = std::make_unique<BugReport>(
+          *BT_lor, "This was not the most recently acquired lock. Possible "
+                   "lock order reversal", N);
       report->addRange(CE->getArg(0)->getSourceRange());
       C.emitReport(report);
       return;
@@ -279,7 +275,7 @@
   ExplodedNode *N = C.generateSink();
   if (!N)
     return;
-  BugReport *Report = new BugReport(*BT_destroylock, Message, N);
+  auto Report = std::make_unique<BugReport>(*BT_destroylock, Message, N);
   Report->addRange(CE->getArg(0)->getSourceRange());
   C.emitReport(Report);
 }
@@ -314,7 +310,7 @@
   ExplodedNode *N = C.generateSink();
   if (!N)
     return;
-  BugReport *Report = new BugReport(*BT_initlock, Message, N);
+  auto Report = std::make_unique<BugReport>(*BT_initlock, Message, N);
   Report->addRange(CE->getArg(0)->getSourceRange());
   C.emitReport(Report);
 }
@@ -327,9 +323,8 @@
   ExplodedNode *N = C.generateSink();
   if (!N)
     return;
-  BugReport *Report = new BugReport(*BT_destroylock,
-                                    "This lock has already been destroyed",
-                                    N);
+  auto Report = std::make_unique<BugReport>(
+      *BT_destroylock, "This lock has already been destroyed", N);
   Report->addRange(CE->getArg(0)->getSourceRange());
   C.emitReport(Report);
 }
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp	(revision 240279)
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp	(working copy)
@@ -3340,9 +3340,9 @@
   }
 
   assert(BT);
-  CFRefReport *report = new CFRefReport(*BT, C.getASTContext().getLangOpts(),
-                                        C.isObjCGCEnabled(), SummaryLog,
-                                        N, Sym);
+  auto report = std::unique_ptr<BugReport>(
+      new CFRefReport(*BT, C.getASTContext().getLangOpts(), C.isObjCGCEnabled(),
+                      SummaryLog, N, Sym));
   report->addRange(ErrorRange);
   C.emitReport(report);
 }
@@ -3573,10 +3573,9 @@
         if (N) {
           const LangOptions &LOpts = C.getASTContext().getLangOpts();
           bool GCEnabled = C.isObjCGCEnabled();
-          CFRefReport *report =
-            new CFRefLeakReport(*getLeakAtReturnBug(LOpts, GCEnabled),
-                                LOpts, GCEnabled, SummaryLog,
-                                N, Sym, C, IncludeAllocationLine);
+          auto report = std::unique_ptr<BugReport>(new CFRefLeakReport(
+              *getLeakAtReturnBug(LOpts, GCEnabled), LOpts, GCEnabled,
+              SummaryLog, N, Sym, C, IncludeAllocationLine));
 
           C.emitReport(report);
         }
@@ -3603,10 +3602,9 @@
           if (!returnNotOwnedForOwned)
             returnNotOwnedForOwned.reset(new ReturnedNotOwnedForOwned(this));
 
-          CFRefReport *report =
-              new CFRefReport(*returnNotOwnedForOwned,
-                              C.getASTContext().getLangOpts(), 
-                              C.isObjCGCEnabled(), SummaryLog, N, Sym);
+          auto report = std::unique_ptr<BugReport>(new CFRefReport(
+              *returnNotOwnedForOwned, C.getASTContext().getLangOpts(),
+              C.isObjCGCEnabled(), SummaryLog, N, Sym));
           C.emitReport(report);
         }
       }
@@ -3810,9 +3808,9 @@
       overAutorelease.reset(new OverAutorelease(this));
 
     const LangOptions &LOpts = Ctx.getASTContext().getLangOpts();
-    CFRefReport *report =
-      new CFRefReport(*overAutorelease, LOpts, /* GCEnabled = */ false,
-                      SummaryLog, N, Sym, os.str());
+    auto report = std::unique_ptr<BugReport>(
+        new CFRefReport(*overAutorelease, LOpts, /* GCEnabled = */ false,
+                        SummaryLog, N, Sym, os.str()));
     Ctx.emitReport(report);
   }
 
@@ -3865,9 +3863,9 @@
                           : getLeakAtReturnBug(LOpts, GCEnabled);
       assert(BT && "BugType not initialized.");
 
-      CFRefLeakReport *report = new CFRefLeakReport(*BT, LOpts, GCEnabled, 
-                                                    SummaryLog, N, *I, Ctx,
-                                                    IncludeAllocationLine);
+      auto report = std::unique_ptr<BugReport>(
+          new CFRefLeakReport(*BT, LOpts, GCEnabled, SummaryLog, N, *I, Ctx,
+                              IncludeAllocationLine));
       Ctx.emitReport(report);
     }
   }
Index: lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp	(working copy)
@@ -80,8 +80,7 @@
     // reference is outside the range.
 
     // Generate a report for this bug.
-    BugReport *report = 
-      new BugReport(*BT, BT->getDescription(), N);
+    auto report = std::make_unique<BugReport>(*BT, BT->getDescription(), N);
 
     report->addRange(RetE->getSourceRange());
     C.emitReport(report);
Index: lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp	(working copy)
@@ -84,7 +84,7 @@
   if (!N)
     return;
 
-  BugReport *Report = new BugReport(BT, BT.getDescription(), N);
+  auto Report = std::make_unique<BugReport>(BT, BT.getDescription(), N);
 
   Report->addRange(RetE->getSourceRange());
   bugreporter::trackNullOrUndefValue(N, TrackingE ? TrackingE : RetE, *Report);
Index: lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp	(working copy)
@@ -214,7 +214,7 @@
     return;
 
   // Generate the report.
-  BugReport *R = new BugReport(*DoubleCloseBugType,
+  auto R = std::make_unique<BugReport>(*DoubleCloseBugType,
       "Closing a previously closed file stream", ErrNode);
   R->addRange(Call.getSourceRange());
   R->markInteresting(FileDescSym);
@@ -227,7 +227,7 @@
   // Attach bug reports to the leak node.
   // TODO: Identify the leaked file descriptor.
   for (SymbolRef LeakedStream : LeakedStreams) {
-    BugReport *R = new BugReport(*LeakBugType,
+    auto R = std::make_unique<BugReport>(*LeakBugType,
         "Opened file is never closed; potential resource leak", ErrNode);
     R->markInteresting(LeakedStream);
     C.emitReport(R);
Index: lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp	(working copy)
@@ -108,7 +108,7 @@
   llvm::raw_svector_ostream os(buf);
   SourceRange range = genName(os, R, C.getASTContext());
   os << " returned to caller";
-  BugReport *report = new BugReport(*BT_returnstack, os.str(), N);
+  auto report = std::make_unique<BugReport>(*BT_returnstack, os.str(), N);
   report->addRange(RetE->getSourceRange());
   if (range.isValid())
     report->addRange(range);
@@ -231,7 +231,7 @@
     const VarRegion *VR = cast<VarRegion>(cb.V[i].first->getBaseRegion());
     os << *VR->getDecl()
        << "' upon returning to the caller.  This will be a dangling reference";
-    BugReport *report = new BugReport(*BT_stackleak, os.str(), N);
+    auto report = std::make_unique<BugReport>(*BT_stackleak, os.str(), N);
     if (range.isValid())
       report->addRange(range);
 
Index: lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/StreamChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/StreamChecker.cpp	(working copy)
@@ -277,8 +277,8 @@
           new BuiltinBug(this, "Illegal whence argument",
                          "The whence argument to fseek() should be "
                          "SEEK_SET, SEEK_END, or SEEK_CUR."));
-    BugReport *R = new BugReport(*BT_illegalwhence, 
-				 BT_illegalwhence->getDescription(), N);
+    auto R = std::make_unique<BugReport>(*BT_illegalwhence,
+                                         BT_illegalwhence->getDescription(), N);
     C.emitReport(R);
   }
 }
@@ -354,7 +354,8 @@
       if (!BT_nullfp)
         BT_nullfp.reset(new BuiltinBug(this, "NULL stream pointer",
                                        "Stream pointer might be NULL."));
-      BugReport *R =new BugReport(*BT_nullfp, BT_nullfp->getDescription(), N);
+      auto R = std::make_unique<BugReport>(*BT_nullfp,
+                                           BT_nullfp->getDescription(), N);
       C.emitReport(R);
     }
     return nullptr;
@@ -385,8 +386,8 @@
         BT_doubleclose.reset(new BuiltinBug(
             this, "Double fclose", "Try to close a file Descriptor already"
                                    " closed. Cause undefined behaviour."));
-      BugReport *R = new BugReport(*BT_doubleclose,
-                                   BT_doubleclose->getDescription(), N);
+      auto R = std::make_unique<BugReport>(*BT_doubleclose,
+                                           BT_doubleclose->getDescription(), N);
       C.emitReport(R);
     }
     return nullptr;
@@ -414,8 +415,8 @@
           BT_ResourceLeak.reset(new BuiltinBug(
               this, "Resource Leak",
               "Opened File never closed. Potential Resource leak."));
-        BugReport *R = new BugReport(*BT_ResourceLeak, 
-                                     BT_ResourceLeak->getDescription(), N);
+        auto R = std::make_unique<BugReport>(
+            *BT_ResourceLeak, BT_ResourceLeak->getDescription(), N);
         C.emitReport(R);
       }
     }
Index: lib/StaticAnalyzer/Checkers/TaintTesterChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/TaintTesterChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/TaintTesterChecker.cpp	(working copy)
@@ -50,7 +50,7 @@
   if (State->isTainted(E, C.getLocationContext())) {
     if (ExplodedNode *N = C.addTransition()) {
       initBugType();
-      BugReport *report = new BugReport(*BT, "tainted",N);
+      auto report = std::make_unique<BugReport>(*BT, "tainted",N);
       report->addRange(E->getSourceRange());
       C.emitReport(report);
     }
Index: lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp	(working copy)
@@ -171,10 +171,10 @@
     if (!DivZeroBug)
       DivZeroBug.reset(new BuiltinBug(this, "Division by zero"));
 
-    BugReport *R =
-        new BugReport(*DivZeroBug, "Value being compared against zero has "
-                                   "already been used for division",
-                      N);
+    auto R = std::make_unique<BugReport>(
+        *DivZeroBug, "Value being compared against zero has already been used "
+                     "for division",
+        N);
 
     R->addVisitor(llvm::make_unique<DivisionBRVisitor>(Val.getAsSymbol(),
                                                        C.getStackFrame()));
Index: lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp	(working copy)
@@ -98,7 +98,7 @@
       Ex = FindIt.FindExpr(Ex);
 
       // Emit the bug report.
-      BugReport *R = new BugReport(*BT, BT->getDescription(), N);
+      auto R = std::make_unique<BugReport>(*BT, BT->getDescription(), N);
       bugreporter::trackNullOrUndefValue(N, Ex, *R);
       R->addRange(Ex->getSourceRange());
 
Index: lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp	(working copy)
@@ -89,7 +89,7 @@
         os << "Variable '" << VD->getName() 
            << "' is uninitialized when captured by block";
 
-        BugReport *R = new BugReport(*BT, os.str(), N);
+        auto R = std::make_unique<BugReport>(*BT, os.str(), N);
         if (const Expr *Ex = FindBlockDeclRefExpr(BE->getBody(), VD))
           R->addRange(Ex->getSourceRange());
         R->addVisitor(llvm::make_unique<FindLastStoreBRVisitor>(
Index: lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp	(working copy)
@@ -53,7 +53,7 @@
     BT.reset(new BuiltinBug(this, "Array subscript is undefined"));
 
   // Generate a report for this bug.
-  BugReport *R = new BugReport(*BT, BT->getName(), N);
+  auto R = std::make_unique<BugReport>(*BT, BT->getName(), N);
   R->addRange(A->getIdx()->getSourceRange());
   bugreporter::trackNullOrUndefValue(N, A->getIdx(), *R);
   C.emitReport(R);
Index: lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp	(working copy)
@@ -83,7 +83,7 @@
     break;
   }
 
-  BugReport *R = new BugReport(*BT, str, N);
+  auto R = std::make_unique<BugReport>(*BT, str, N);
   if (ex) {
     R->addRange(ex->getSourceRange());
     bugreporter::trackNullOrUndefValue(N, ex, *R);
Index: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp	(working copy)
@@ -84,7 +84,7 @@
          << BinaryOperator::getOpcodeStr(B->getOpcode())
          << "' expression is undefined";
     }
-    BugReport *report = new BugReport(*BT, OS.str(), N);
+    auto report = std::make_unique<BugReport>(*BT, OS.str(), N);
     if (Ex) {
       report->addRange(Ex->getSourceRange());
       bugreporter::trackNullOrUndefValue(N, Ex, *report);
Index: lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp	(working copy)
@@ -83,7 +83,7 @@
 
   LazyInitialize(BT_open, "Improper use of 'open'");
 
-  BugReport *Report = new BugReport(*BT_open, Msg, N);
+  auto Report = std::make_unique<BugReport>(*BT_open, Msg, N);
   Report->addRange(SR);
   C.emitReport(Report);
 }
@@ -200,7 +200,7 @@
 
   LazyInitialize(BT_pthreadOnce, "Improper use of 'pthread_once'");
 
-  BugReport *report = new BugReport(*BT_pthreadOnce, os.str(), N);
+  auto report = std::make_unique<BugReport>(*BT_pthreadOnce, os.str(), N);
   report->addRange(CE->getArg(0)->getSourceRange());
   C.emitReport(report);
 }
@@ -241,7 +241,7 @@
   SmallString<256> S;
   llvm::raw_svector_ostream os(S);    
   os << "Call to '" << fn_name << "' has an allocation size of 0 bytes";
-  BugReport *report = new BugReport(*BT_mallocZero, os.str(), N);
+  auto report = std::make_unique<BugReport>(*BT_mallocZero, os.str(), N);
 
   report->addRange(arg->getSourceRange());
   bugreporter::trackNullOrUndefValue(N, arg, *report);
Index: lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp	(working copy)
@@ -72,7 +72,7 @@
     break;
   }
 
-  BugReport *report = new BugReport(*BT, os.str(), N);
+  auto report = std::make_unique<BugReport>(*BT, os.str(), N);
   report->addRange(SizeE->getSourceRange());
   bugreporter::trackNullOrUndefValue(N, SizeE, *report);
   C.emitReport(report);
Index: lib/StaticAnalyzer/Core/BugReporter.cpp
===================================================================
--- lib/StaticAnalyzer/Core/BugReporter.cpp	(revision 240274)
+++ lib/StaticAnalyzer/Core/BugReporter.cpp	(working copy)
@@ -3224,11 +3224,8 @@
   BugTypes = F.add(BugTypes, BT);
 }
 
-void BugReporter::emitReport(BugReport* R) {
-  // To guarantee memory release.
-  std::unique_ptr<BugReport> UniqueR(R);
-
-  if (const ExplodedNode *E = R->getErrorNode()) {
+void BugReporter::emitReport(std::unique_ptr<BugReport> &UniqueR) {
+  if (const ExplodedNode *E = UniqueR->getErrorNode()) {
     const AnalysisDeclContext *DeclCtx =
         E->getLocationContext()->getAnalysisDeclContext();
     // The source of autosynthesized body can be handcrafted AST or a model
@@ -3240,7 +3237,7 @@
       return;
   }
   
-  bool ValidSourceLoc = R->getLocation(getSourceManager()).isValid();
+  bool ValidSourceLoc = UniqueR->getLocation(getSourceManager()).isValid();
   assert(ValidSourceLoc);
   // If we mess up in a release build, we'd still prefer to just drop the bug
   // instead of trying to go on.
@@ -3249,13 +3246,13 @@
 
   // Compute the bug report's hash to determine its equivalence class.
   llvm::FoldingSetNodeID ID;
-  R->Profile(ID);
+  UniqueR->Profile(ID);
 
   // Lookup the equivance class.  If there isn't one, create it.
-  BugType& BT = R->getBugType();
+  BugType& BT = UniqueR->getBugType();
   Register(&BT);
   void *InsertPos;
-  BugReportEquivClass* EQ = EQClasses.FindNodeOrInsertPos(ID, InsertPos);
+  BugReportEquivClass *EQ = EQClasses.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!EQ) {
     EQ = new BugReportEquivClass(std::move(UniqueR));
@@ -3462,7 +3459,7 @@
 
   // 'BT' is owned by BugReporter.
   BugType *BT = getBugTypeForName(CheckName, name, category);
-  BugReport *R = new BugReport(*BT, str, Loc);
+  auto R = std::make_unique<BugReport>(*BT, str, Loc);
   R->setDeclWithIssue(DeclWithIssue);
   for (ArrayRef<SourceRange>::iterator I = Ranges.begin(), E = Ranges.end();
        I != E; ++I)
