[PATCH] D52336: [analyzer] [NFC] Prefer make_unique over "new"

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 24 19:44:48 PDT 2018


Looks good - thanks!

On Fri, Sep 21, 2018 at 1:40 PM George Karpenkov via Phabricator via
llvm-commits <llvm-commits at lists.llvm.org> wrote:

> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL342767: [analyzer] [NFC] Prefer make_unique over
> "new" (authored by george.karpenkov, committed by ).
> Herald added a subscriber: llvm-commits.
>
> Changed prior to commit:
>   https://reviews.llvm.org/D52336?vs=166398&id=166549#toc
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D52336
>
> Files:
>
> cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
>
>
> Index:
> cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
> ===================================================================
> ---
> cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
> +++
> cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
> @@ -750,9 +750,8 @@
>    }
>
>    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 @@
>          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 @@
>            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 @@
>        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 @@
>                            : 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));
>      }
>    }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180924/f96f0a19/attachment.html>


More information about the llvm-commits mailing list