r342767 - [analyzer] [NFC] Prefer make_unique over "new"

George Karpenkov via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 21 13:36:21 PDT 2018


Author: george.karpenkov
Date: Fri Sep 21 13:36:21 2018
New Revision: 342767

URL: http://llvm.org/viewvc/llvm-project?rev=342767&view=rev
Log:
[analyzer] [NFC] Prefer make_unique over "new"

Differential Revision: https://reviews.llvm.org/D52336

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=342767&r1=342766&r2=342767&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp Fri Sep 21 13:36:21 2018
@@ -750,9 +750,8 @@ void RetainCountChecker::processNonLeakE
   }
 
   assert(BT);
-  auto report = std::unique_ptr<BugReport>(
-      new CFRefReport(*BT, C.getASTContext().getLangOpts(),
-                      SummaryLog, N, Sym));
+  auto report = llvm::make_unique<CFRefReport>(
+      *BT, C.getASTContext().getLangOpts(), SummaryLog, N, Sym);
   report->addRange(ErrorRange);
   C.emitReport(std::move(report));
 }
@@ -951,9 +950,9 @@ void RetainCountChecker::checkReturnWith
         ExplodedNode *N = C.addTransition(state, Pred, &ReturnOwnLeakTag);
         if (N) {
           const LangOptions &LOpts = C.getASTContext().getLangOpts();
-          C.emitReport(std::unique_ptr<BugReport>(new CFRefLeakReport(
-              *getLeakAtReturnBug(LOpts), LOpts,
-              SummaryLog, N, Sym, C, IncludeAllocationLine)));
+          C.emitReport(llvm::make_unique<CFRefLeakReport>(
+              *getLeakAtReturnBug(LOpts), LOpts, SummaryLog, N, Sym, C,
+              IncludeAllocationLine));
         }
       }
     }
@@ -978,9 +977,9 @@ void RetainCountChecker::checkReturnWith
           if (!returnNotOwnedForOwned)
             returnNotOwnedForOwned.reset(new ReturnedNotOwnedForOwned(this));
 
-          C.emitReport(std::unique_ptr<BugReport>(new CFRefReport(
+          C.emitReport(llvm::make_unique<CFRefReport>(
               *returnNotOwnedForOwned, C.getASTContext().getLangOpts(),
-              SummaryLog, N, Sym)));
+              SummaryLog, N, Sym));
         }
       }
     }
@@ -1182,9 +1181,8 @@ RetainCountChecker::handleAutoreleaseCou
       overAutorelease.reset(new OverAutorelease(this));
 
     const LangOptions &LOpts = Ctx.getASTContext().getLangOpts();
-    Ctx.emitReport(std::unique_ptr<BugReport>(
-        new CFRefReport(*overAutorelease, LOpts,
-                        SummaryLog, N, Sym, os.str())));
+    Ctx.emitReport(llvm::make_unique<CFRefReport>(
+        *overAutorelease, LOpts, SummaryLog, N, Sym, os.str()));
   }
 
   return nullptr;
@@ -1235,9 +1233,8 @@ RetainCountChecker::processLeaks(Program
                           : getLeakAtReturnBug(LOpts);
       assert(BT && "BugType not initialized.");
 
-      Ctx.emitReport(std::unique_ptr<BugReport>(
-          new CFRefLeakReport(*BT, LOpts, SummaryLog, N, *I, Ctx,
-                              IncludeAllocationLine)));
+      Ctx.emitReport(llvm::make_unique<CFRefLeakReport>(
+          *BT, LOpts, SummaryLog, N, *I, Ctx, IncludeAllocationLine));
     }
   }
 




More information about the cfe-commits mailing list