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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-fir-hlfir

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

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.


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


1 Files Affected:

- (modified) flang/lib/Optimizer/Builder/TemporaryStorage.cpp (+3-4) 


``````````diff
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(

``````````

</details>


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


More information about the flang-commits mailing list