Skip to content

Commit 376c138

Browse files
committed
[mlir] Use empty() calls where possible.
These are based on findings from the ClangTidy readability-container-size-empty check.
1 parent 5a3556a commit 376c138

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ parseOperandList(OpAsmParser &parser, StringRef keyword,
8282
static void printOperandList(Operation::operand_range operands,
8383
StringRef listName, OpAsmPrinter &printer) {
8484

85-
if (operands.size() > 0) {
85+
if (!operands.empty()) {
8686
printer << " " << listName << "(";
8787
llvm::interleaveComma(operands, printer, [&](Value op) {
8888
printer << op << ": " << op.getType();
@@ -692,7 +692,7 @@ static LogicalResult verify(acc::DataOp dataOp) {
692692
// 2.6.5. Data Construct restriction
693693
// At least one copy, copyin, copyout, create, no_create, present, deviceptr,
694694
// attach, or default clause must appear on a data construct.
695-
if (dataOp.getOperands().size() == 0 && !dataOp.defaultAttr())
695+
if (dataOp.getOperands().empty() && !dataOp.defaultAttr())
696696
return dataOp.emitError("at least one operand or the default attribute "
697697
"must appear on the data operation");
698698
return success();
@@ -838,8 +838,7 @@ static LogicalResult verify(acc::ShutdownOp op) {
838838

839839
static LogicalResult verify(acc::UpdateOp updateOp) {
840840
// At least one of host or device should have a value.
841-
if (updateOp.hostOperands().size() == 0 &&
842-
updateOp.deviceOperands().size() == 0)
841+
if (updateOp.hostOperands().empty() && updateOp.deviceOperands().empty())
843842
return updateOp.emitError("at least one value must be present in"
844843
" hostOperands or deviceOperands");
845844

@@ -851,10 +850,10 @@ static LogicalResult verify(acc::UpdateOp updateOp) {
851850

852851
// The wait attribute represent the wait clause without values. Therefore the
853852
// attribute and operands cannot appear at the same time.
854-
if (updateOp.waitOperands().size() > 0 && updateOp.wait())
853+
if (!updateOp.waitOperands().empty() && updateOp.wait())
855854
return updateOp.emitError("wait attribute cannot appear with waitOperands");
856855

857-
if (updateOp.waitDevnum() && updateOp.waitOperands().size() == 0)
856+
if (updateOp.waitDevnum() && updateOp.waitOperands().empty())
858857
return updateOp.emitError("wait_devnum cannot appear without waitOperands");
859858

860859
return success();

0 commit comments

Comments
 (0)