[mlir] Use empty() calls where possible.

These are based on findings from the ClangTidy
readability-container-size-empty check.
This commit is contained in:
Adrian Kuegel 2021-10-21 12:45:37 +02:00
parent 5a3556aa55
commit 376c1389f6
1 changed files with 5 additions and 6 deletions

View File

@ -82,7 +82,7 @@ parseOperandList(OpAsmParser &parser, StringRef keyword,
static void printOperandList(Operation::operand_range operands,
StringRef listName, OpAsmPrinter &printer) {
if (operands.size() > 0) {
if (!operands.empty()) {
printer << " " << listName << "(";
llvm::interleaveComma(operands, printer, [&](Value op) {
printer << op << ": " << op.getType();
@ -692,7 +692,7 @@ static LogicalResult verify(acc::DataOp dataOp) {
// 2.6.5. Data Construct restriction
// At least one copy, copyin, copyout, create, no_create, present, deviceptr,
// attach, or default clause must appear on a data construct.
if (dataOp.getOperands().size() == 0 && !dataOp.defaultAttr())
if (dataOp.getOperands().empty() && !dataOp.defaultAttr())
return dataOp.emitError("at least one operand or the default attribute "
"must appear on the data operation");
return success();
@ -838,8 +838,7 @@ static LogicalResult verify(acc::ShutdownOp op) {
static LogicalResult verify(acc::UpdateOp updateOp) {
// At least one of host or device should have a value.
if (updateOp.hostOperands().size() == 0 &&
updateOp.deviceOperands().size() == 0)
if (updateOp.hostOperands().empty() && updateOp.deviceOperands().empty())
return updateOp.emitError("at least one value must be present in"
" hostOperands or deviceOperands");
@ -851,10 +850,10 @@ static LogicalResult verify(acc::UpdateOp updateOp) {
// The wait attribute represent the wait clause without values. Therefore the
// attribute and operands cannot appear at the same time.
if (updateOp.waitOperands().size() > 0 && updateOp.wait())
if (!updateOp.waitOperands().empty() && updateOp.wait())
return updateOp.emitError("wait attribute cannot appear with waitOperands");
if (updateOp.waitDevnum() && updateOp.waitOperands().size() == 0)
if (updateOp.waitDevnum() && updateOp.waitOperands().empty())
return updateOp.emitError("wait_devnum cannot appear without waitOperands");
return success();