[flang-commits] [flang] 009ab17 - [flang] Use *X instead of X.getValue() (NFC)

Kazu Hirata via flang-commits flang-commits at lists.llvm.org
Sat Jul 16 00:24:08 PDT 2022


Author: Kazu Hirata
Date: 2022-07-16T00:24:02-07:00
New Revision: 009ab1728db52b59b9d0eaead7c3815a35a28c37

URL: https://github.com/llvm/llvm-project/commit/009ab1728db52b59b9d0eaead7c3815a35a28c37
DIFF: https://github.com/llvm/llvm-project/commit/009ab1728db52b59b9d0eaead7c3815a35a28c37.diff

LOG: [flang] Use *X instead of X.getValue() (NFC)

Per Flang C++ Style Guide, this patch replaces X.getValue() with *X
where *X is protected by a presence test.

Added: 
    

Modified: 
    flang/include/flang/Lower/IterationSpace.h
    flang/lib/Lower/ConvertExpr.cpp
    flang/lib/Lower/IterationSpace.cpp
    flang/lib/Optimizer/CodeGen/CodeGen.cpp
    flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
    flang/lib/Optimizer/Dialect/FIROps.cpp
    flang/lib/Optimizer/Support/InternalNames.cpp
    flang/lib/Optimizer/Transforms/AbstractResult.cpp
    flang/lib/Optimizer/Transforms/AffinePromotion.cpp

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Lower/IterationSpace.h b/flang/include/flang/Lower/IterationSpace.h
index 25c3f30aa166a..7adbd94dca4a5 100644
--- a/flang/include/flang/Lower/IterationSpace.h
+++ b/flang/include/flang/Lower/IterationSpace.h
@@ -468,7 +468,7 @@ class ExplicitIterSpace {
   llvm::Optional<fir::ArrayLoadOp> getLhsLoad(size_t i) {
     assert(i < lhsBases.size());
     if (lhsBases[counter])
-      return findBinding(lhsBases[counter].getValue());
+      return findBinding(*lhsBases[counter]);
     return llvm::None;
   }
 

diff  --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index 144a3ceb27509..a45949ed6c930 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -4313,7 +4313,7 @@ class ArrayExprLowering {
     auto exv = f(iterSpace);
     iterSpace.setElement(std::move(exv));
     auto lambda = ccStoreToDest
-                      ? ccStoreToDest.getValue()
+                      ? *ccStoreToDest
                       : defaultStoreToDestination(/*substring=*/nullptr);
     mlir::Value updVal = fir::getBase(lambda(iterSpace));
     finalizeElementCtx();
@@ -4650,7 +4650,7 @@ class ArrayExprLowering {
 
     // Generate the lazy mask allocation, if one was given.
     if (ccPrelude)
-      ccPrelude.getValue()(shape);
+      (*ccPrelude)(shape);
 
     // Now handle the implicit loops.
     mlir::Value inner = explicitSpaceIsActive()
@@ -4710,7 +4710,7 @@ class ArrayExprLowering {
   createAndLoadSomeArrayTemp(mlir::Type type,
                              llvm::ArrayRef<mlir::Value> shape) {
     if (ccLoadDest)
-      return ccLoadDest.getValue()(shape);
+      return (*ccLoadDest)(shape);
     auto seqTy = type.dyn_cast<fir::SequenceType>();
     assert(seqTy && "must be an array");
     mlir::Location loc = getLoc();
@@ -6025,7 +6025,7 @@ class ArrayExprLowering {
       // end.
       destination = arrLoad;
       auto lambda = ccStoreToDest
-                        ? ccStoreToDest.getValue()
+                        ? *ccStoreToDest
                         : defaultStoreToDestination(components.substring);
       return [=](IterSpace iters) -> ExtValue { return lambda(iters); };
     }
@@ -6664,7 +6664,7 @@ class ArrayExprLowering {
     // Return the continuation.
     if (fir::isa_char(seqTy.getEleTy())) {
       if (charLen) {
-        auto len = builder.create<fir::LoadOp>(loc, charLen.getValue());
+        auto len = builder.create<fir::LoadOp>(loc, *charLen);
         return genarr(fir::CharArrayBoxValue{mem, len, extents});
       }
       return genarr(fir::CharArrayBoxValue{mem, zero, extents});
@@ -7716,7 +7716,7 @@ void Fortran::lower::createArrayLoads(
     return genArrayLoad(loc, converter, builder, x, symMap, stmtCtx);
   };
   if (esp.lhsBases[counter]) {
-    auto &base = esp.lhsBases[counter].getValue();
+    auto &base = *esp.lhsBases[counter];
     auto load = std::visit(genLoad, base);
     esp.initialArgs.push_back(load);
     esp.resetInnerArgs();
@@ -7735,13 +7735,13 @@ void Fortran::lower::createArrayMergeStores(
   // Gen the fir.array_merge_store ops for all LHS arrays.
   for (auto i : llvm::enumerate(esp.getOuterLoop().getResults()))
     if (llvm::Optional<fir::ArrayLoadOp> ldOpt = esp.getLhsLoad(i.index())) {
-      fir::ArrayLoadOp load = ldOpt.getValue();
+      fir::ArrayLoadOp load = *ldOpt;
       builder.create<fir::ArrayMergeStoreOp>(loc, load, i.value(),
                                              load.getMemref(), load.getSlice(),
                                              load.getTypeparams());
     }
   if (esp.loopCleanup) {
-    esp.loopCleanup.getValue()(builder);
+    (*esp.loopCleanup)(builder);
     esp.loopCleanup = llvm::None;
   }
   esp.initialArgs.clear();

diff  --git a/flang/lib/Lower/IterationSpace.cpp b/flang/lib/Lower/IterationSpace.cpp
index e2825632928e8..d39cb9bd69565 100644
--- a/flang/lib/Lower/IterationSpace.cpp
+++ b/flang/lib/Lower/IterationSpace.cpp
@@ -863,7 +863,7 @@ void Fortran::lower::ExplicitIterSpace::conditionalCleanup() {
 llvm::Optional<size_t>
 Fortran::lower::ExplicitIterSpace::findArgPosition(fir::ArrayLoadOp load) {
   if (lhsBases[counter]) {
-    auto ld = loadBindings.find(lhsBases[counter].getValue());
+    auto ld = loadBindings.find(*lhsBases[counter]);
     llvm::Optional<size_t> optPos;
     if (ld != loadBindings.end() && ld->second == load)
       optPos = static_cast<size_t>(0u);
@@ -920,7 +920,7 @@ Fortran::lower::operator<<(llvm::raw_ostream &s,
   for (const llvm::Optional<Fortran::lower::ExplicitIterSpace::ArrayBases> &u :
        e.lhsBases)
     if (u)
-      dump(u.getValue());
+      dump(*u);
   s << "RHS bases:\n";
   for (const llvm::SmallVector<Fortran::lower::ExplicitIterSpace::ArrayBases>
            &bases : e.rhsBases) {

diff  --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index 4a4ff04550fc8..0f61776a7215b 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -2738,7 +2738,7 @@ struct GlobalOpConversion : public FIROpConversion<fir::GlobalOp> {
   mlir::LLVM::Linkage
   convertLinkage(llvm::Optional<llvm::StringRef> optLinkage) const {
     if (optLinkage) {
-      auto name = optLinkage.getValue();
+      auto name = *optLinkage;
       if (name == "internal")
         return mlir::LLVM::Linkage::Internal;
       if (name == "linkonce")
@@ -2795,8 +2795,8 @@ static void genCondBrOp(mlir::Location loc, mlir::Value cmp, mlir::Block *dest,
                         mlir::ConversionPatternRewriter &rewriter,
                         mlir::Block *newBlock) {
   if (destOps)
-    rewriter.create<mlir::LLVM::CondBrOp>(loc, cmp, dest, destOps.getValue(),
-                                          newBlock, mlir::ValueRange());
+    rewriter.create<mlir::LLVM::CondBrOp>(loc, cmp, dest, *destOps, newBlock,
+                                          mlir::ValueRange());
   else
     rewriter.create<mlir::LLVM::CondBrOp>(loc, cmp, dest, newBlock);
 }
@@ -2805,8 +2805,7 @@ template <typename A, typename B>
 static void genBrOp(A caseOp, mlir::Block *dest, llvm::Optional<B> destOps,
                     mlir::ConversionPatternRewriter &rewriter) {
   if (destOps)
-    rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, destOps.getValue(),
-                                                  dest);
+    rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, *destOps, dest);
   else
     rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, llvm::None, dest);
 }

diff  --git a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
index 1fbcf262a9e90..30df227478912 100644
--- a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
+++ b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
@@ -318,8 +318,8 @@ class TargetRewrite : public fir::TargetRewriteBase<TargetRewrite> {
     if constexpr (std::is_same_v<std::decay_t<A>, fir::CallOp>) {
       fir::CallOp newCall;
       if (callOp.getCallee()) {
-        newCall = rewriter->create<A>(loc, callOp.getCallee().getValue(),
-                                      newResTys, newOpers);
+        newCall =
+            rewriter->create<A>(loc, *callOp.getCallee(), newResTys, newOpers);
       } else {
         // Force new type on the input operand.
         newOpers[0].setType(mlir::FunctionType::get(

diff  --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp
index 8337b16fca879..6f6eaf769bd8a 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -650,7 +650,7 @@ void fir::CallOp::print(mlir::OpAsmPrinter &p) {
   bool isDirect = getCallee().has_value();
   p << ' ';
   if (isDirect)
-    p << getCallee().getValue();
+    p << *getCallee();
   else
     p << getOperand(0);
   p << '(' << (*this)->getOperands().drop_front(isDirect ? 0 : 1) << ')';
@@ -1295,7 +1295,7 @@ mlir::ParseResult fir::GlobalOp::parse(mlir::OpAsmParser &parser,
 
 void fir::GlobalOp::print(mlir::OpAsmPrinter &p) {
   if (getLinkName())
-    p << ' ' << getLinkName().getValue();
+    p << ' ' << *getLinkName();
   p << ' ';
   p.printAttributeWithoutType(getSymrefAttr());
   if (auto val = getValueOrNull())

diff  --git a/flang/lib/Optimizer/Support/InternalNames.cpp b/flang/lib/Optimizer/Support/InternalNames.cpp
index 63fe017f3654e..19a2740a51a88 100644
--- a/flang/lib/Optimizer/Support/InternalNames.cpp
+++ b/flang/lib/Optimizer/Support/InternalNames.cpp
@@ -52,7 +52,7 @@ inline llvm::Optional<llvm::StringRef>
 convertToStringRef(const llvm::Optional<std::string> &from) {
   llvm::Optional<llvm::StringRef> to;
   if (from)
-    to = from.getValue();
+    to = *from;
   return to;
 }
 

diff  --git a/flang/lib/Optimizer/Transforms/AbstractResult.cpp b/flang/lib/Optimizer/Transforms/AbstractResult.cpp
index 7dd821474698f..a7d46839b8814 100644
--- a/flang/lib/Optimizer/Transforms/AbstractResult.cpp
+++ b/flang/lib/Optimizer/Transforms/AbstractResult.cpp
@@ -101,8 +101,8 @@ class CallOpConversion : public mlir::OpRewritePattern<fir::CallOp> {
       llvm::SmallVector<mlir::Value> newOperands = {arg};
       newOperands.append(callOp.getOperands().begin(),
                          callOp.getOperands().end());
-      rewriter.create<fir::CallOp>(loc, callOp.getCallee().getValue(),
-                                   newResultTypes, newOperands);
+      rewriter.create<fir::CallOp>(loc, *callOp.getCallee(), newResultTypes,
+                                   newOperands);
     } else {
       // Indirect calls.
       llvm::SmallVector<mlir::Type> newInputTypes = {argType};

diff  --git a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
index e9f017c9384fa..c6df98769a64b 100644
--- a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
+++ b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
@@ -189,7 +189,7 @@ struct AffineIfCondition {
   MaybeAffineExpr affineBinaryOp(mlir::AffineExprKind kind, MaybeAffineExpr lhs,
                                  MaybeAffineExpr rhs) {
     if (lhs && rhs)
-      return mlir::getAffineBinaryOpExpr(kind, lhs.getValue(), rhs.getValue());
+      return mlir::getAffineBinaryOpExpr(kind, *lhs, *rhs);
     return {};
   }
 


        


More information about the flang-commits mailing list