[llvm] [Coroutines] Improve use of unique_ptr (PR #111870)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 10 09:56:59 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-coroutines

Author: Tyler Nowicki (TylerNowicki)

<details>
<summary>Changes</summary>

* Replace usage of unique_ptr<>(new ...) -> make_unique<>();

---
Full diff: https://github.com/llvm/llvm-project/pull/111870.diff


2 Files Affected:

- (modified) llvm/lib/Transforms/Coroutines/CoroSplit.cpp (+4-8) 
- (modified) llvm/unittests/Transforms/Coroutines/ExtraRematTest.cpp (+1-1) 


``````````diff
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index 88ce331c8cfb64..0395ee62ae988b 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -2211,17 +2211,13 @@ CreateNewABI(Function &F, coro::Shape &S,
 
   switch (S.ABI) {
   case coro::ABI::Switch:
-    return std::unique_ptr<coro::BaseABI>(
-        new coro::SwitchABI(F, S, IsMatCallback));
+    return std::make_unique<coro::SwitchABI>(F, S, IsMatCallback);
   case coro::ABI::Async:
-    return std::unique_ptr<coro::BaseABI>(
-        new coro::AsyncABI(F, S, IsMatCallback));
+    return std::make_unique<coro::AsyncABI>(F, S, IsMatCallback);
   case coro::ABI::Retcon:
-    return std::unique_ptr<coro::BaseABI>(
-        new coro::AnyRetconABI(F, S, IsMatCallback));
+    return std::make_unique<coro::AnyRetconABI>(F, S, IsMatCallback);
   case coro::ABI::RetconOnce:
-    return std::unique_ptr<coro::BaseABI>(
-        new coro::AnyRetconABI(F, S, IsMatCallback));
+    return std::make_unique<coro::AnyRetconABI>(F, S, IsMatCallback);
   }
   llvm_unreachable("Unknown ABI");
 }
diff --git a/llvm/unittests/Transforms/Coroutines/ExtraRematTest.cpp b/llvm/unittests/Transforms/Coroutines/ExtraRematTest.cpp
index c3394fdaa940ba..68bf640334b5f2 100644
--- a/llvm/unittests/Transforms/Coroutines/ExtraRematTest.cpp
+++ b/llvm/unittests/Transforms/Coroutines/ExtraRematTest.cpp
@@ -247,7 +247,7 @@ TEST_F(ExtraRematTest, TestCoroRematWithCustomABI) {
   ASSERT_TRUE(M);
 
   CoroSplitPass::BaseABITy GenCustomABI = [](Function &F, coro::Shape &S) {
-    return std::unique_ptr<coro::BaseABI>(new ExtraCustomABI(F, S));
+    return std::make_unique<ExtraCustomABI>(F, S);
   };
 
   CGSCCPassManager CGPM;

``````````

</details>


https://github.com/llvm/llvm-project/pull/111870


More information about the llvm-commits mailing list