[flang-commits] [flang] [flang] Use std::make_unique (NFC) (PR #97238)

Kazu Hirata via flang-commits flang-commits at lists.llvm.org
Sun Jun 30 15:30:05 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/97238

This patch is based on clang-tidy's modernize-make-unique but limited
to those cases where type names are mentioned twice like
std::unique_ptr<Type>(new Type()), which is a bit mouthful.


>From 2cdab1e89f2e78dae8dc3b95b95457f934ffc9b8 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 30 Jun 2024 15:26:17 -0700
Subject: [PATCH] [flang] Use std::make_unique (NFC)

This patch is based on clang-tidy's modernize-make-unique but limited
to those cases where type names are mentioned twice like
std::unique_ptr<Type>(new Type()), which is a bit mouthful.
---
 flang/lib/Optimizer/Builder/TemporaryStorage.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/flang/lib/Optimizer/Builder/TemporaryStorage.cpp b/flang/lib/Optimizer/Builder/TemporaryStorage.cpp
index d34dad52c28b0..4c59574dd433a 100644
--- a/flang/lib/Optimizer/Builder/TemporaryStorage.cpp
+++ b/flang/lib/Optimizer/Builder/TemporaryStorage.cpp
@@ -305,8 +305,7 @@ fir::factory::AnyVectorSubscriptStack::AnyVectorSubscriptStack(
     mlir::Type variableStaticType, bool shapeCanBeSavedAsRegister, int rank)
     : AnyVariableStack{loc, builder, variableStaticType} {
   if (shapeCanBeSavedAsRegister) {
-    shapeTemp =
-        std::unique_ptr<TemporaryStorage>(new TemporaryStorage{SSARegister{}});
+    shapeTemp = std::make_unique<TemporaryStorage>(SSARegister{});
     return;
   }
   // The shape will be tracked as the dimension inside a descriptor because
@@ -315,8 +314,8 @@ fir::factory::AnyVectorSubscriptStack::AnyVectorSubscriptStack(
   mlir::Type type =
       fir::BoxType::get(builder.getVarLenSeqTy(builder.getI32Type(), rank));
   boxType = type;
-  shapeTemp = std::unique_ptr<TemporaryStorage>(
-      new TemporaryStorage{AnyVariableStack{loc, builder, type}});
+  shapeTemp =
+      std::make_unique<TemporaryStorage>(AnyVariableStack{loc, builder, type});
 }
 
 void fir::factory::AnyVectorSubscriptStack::pushShape(



More information about the flang-commits mailing list