[flang] Use value_or (NFC)

This commit is contained in:
Kazu Hirata 2022-07-16 00:51:54 -07:00
parent 685775bbab
commit c715e2ff92
2 changed files with 9 additions and 15 deletions

View File

@ -252,12 +252,10 @@ public:
rewriter.setInsertionPoint(mem);
auto toTy = typeConverter.convertType(unwrapRefType(ty));
bool isPinned = mem.getPinned();
llvm::StringRef uniqName;
if (mem.getUniqName())
uniqName = mem.getUniqName().getValue();
llvm::StringRef bindcName;
if (mem.getBindcName())
bindcName = mem.getBindcName().getValue();
llvm::StringRef uniqName =
mem.getUniqName().value_or(llvm::StringRef());
llvm::StringRef bindcName =
mem.getBindcName().value_or(llvm::StringRef());
rewriter.replaceOpWithNewOp<AllocaOp>(
mem, toTy, uniqName, bindcName, isPinned, mem.getTypeparams(),
mem.getShape());
@ -267,12 +265,10 @@ public:
if (typeConverter.needsConversion(ty)) {
rewriter.setInsertionPoint(mem);
auto toTy = typeConverter.convertType(unwrapRefType(ty));
llvm::StringRef uniqName;
if (mem.getUniqName())
uniqName = mem.getUniqName().getValue();
llvm::StringRef bindcName;
if (mem.getBindcName())
bindcName = mem.getBindcName().getValue();
llvm::StringRef uniqName =
mem.getUniqName().value_or(llvm::StringRef());
llvm::StringRef bindcName =
mem.getBindcName().value_or(llvm::StringRef());
rewriter.replaceOpWithNewOp<AllocMemOp>(
mem, toTy, uniqName, bindcName, mem.getTypeparams(),
mem.getShape());

View File

@ -2679,9 +2679,7 @@ struct GlobalOpConversion : public FIROpConversion<fir::GlobalOp> {
if (global.getType().isa<fir::BoxType>())
tyAttr = tyAttr.cast<mlir::LLVM::LLVMPointerType>().getElementType();
auto loc = global.getLoc();
mlir::Attribute initAttr;
if (global.getInitVal())
initAttr = global.getInitVal().getValue();
mlir::Attribute initAttr = global.getInitVal().value_or(mlir::Attribute());
auto linkage = convertLinkage(global.getLinkName());
auto isConst = global.getConstant().has_value();
auto g = rewriter.create<mlir::LLVM::GlobalOp>(