[llvm] 1252623 - [Coroutines] Improve use of unique_ptr (#111870)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 12:11:34 PDT 2024
Author: Tyler Nowicki
Date: 2024-10-10T15:11:27-04:00
New Revision: 125262312f366bd776b668b24026dbbc8e6b4c75
URL: https://github.com/llvm/llvm-project/commit/125262312f366bd776b668b24026dbbc8e6b4c75
DIFF: https://github.com/llvm/llvm-project/commit/125262312f366bd776b668b24026dbbc8e6b4c75.diff
LOG: [Coroutines] Improve use of unique_ptr (#111870)
* Replace usage of unique_ptr<>(new ...) -> make_unique<>();
Added:
Modified:
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/unittests/Transforms/Coroutines/ExtraRematTest.cpp
Removed:
################################################################################
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;
More information about the llvm-commits
mailing list