[Mlir-commits] [mlir] 376c138 - [mlir] Use empty() calls where possible.
Adrian Kuegel
llvmlistbot at llvm.org
Thu Oct 21 03:47:21 PDT 2021
Author: Adrian Kuegel
Date: 2021-10-21T12:45:37+02:00
New Revision: 376c1389f6f33615871cbbe986b75372cd411616
URL: https://github.com/llvm/llvm-project/commit/376c1389f6f33615871cbbe986b75372cd411616
DIFF: https://github.com/llvm/llvm-project/commit/376c1389f6f33615871cbbe986b75372cd411616.diff
LOG: [mlir] Use empty() calls where possible.
These are based on findings from the ClangTidy
readability-container-size-empty check.
Added:
Modified:
mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
index babda7db877d2..db9c859a58761 100644
--- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
+++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
@@ -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();
More information about the Mlir-commits
mailing list