Skip to content

Commit e5639b3

Browse files
committed
Fix more clang-tidy cleanups in mlir/ (NFC)
1 parent dcb3e80 commit e5639b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+122
-122
lines changed

mlir/lib/Analysis/DataFlowAnalysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,13 +756,13 @@ void ForwardDataFlowSolver::join(Operation *owner, AbstractLatticeElement &to,
756756
// AbstractLatticeElement
757757
//===----------------------------------------------------------------------===//
758758

759-
AbstractLatticeElement::~AbstractLatticeElement() {}
759+
AbstractLatticeElement::~AbstractLatticeElement() = default;
760760

761761
//===----------------------------------------------------------------------===//
762762
// ForwardDataFlowAnalysisBase
763763
//===----------------------------------------------------------------------===//
764764

765-
ForwardDataFlowAnalysisBase::~ForwardDataFlowAnalysisBase() {}
765+
ForwardDataFlowAnalysisBase::~ForwardDataFlowAnalysisBase() = default;
766766

767767
AbstractLatticeElement &
768768
ForwardDataFlowAnalysisBase::getLatticeElement(Value value) {

mlir/lib/Analysis/Liveness.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct BlockInfoBuilder {
2727
using ValueSetT = Liveness::ValueSetT;
2828

2929
/// Constructs an empty block builder.
30-
BlockInfoBuilder() : block(nullptr) {}
30+
BlockInfoBuilder() {}
3131

3232
/// Fills the block builder with initial liveness information.
3333
BlockInfoBuilder(Block *block) : block(block) {
@@ -104,7 +104,7 @@ struct BlockInfoBuilder {
104104
}
105105

106106
/// The current block.
107-
Block *block;
107+
Block *block{nullptr};
108108

109109
/// The set of all live in values.
110110
ValueSetT inValues;

mlir/lib/Analysis/LoopAnalysis.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ static bool isAccessIndexInvariant(Value iv, Value index) {
182182

183183
DenseSet<Value> mlir::getInvariantAccesses(Value iv, ArrayRef<Value> indices) {
184184
DenseSet<Value> res;
185-
for (unsigned idx = 0, n = indices.size(); idx < n; ++idx) {
186-
auto val = indices[idx];
185+
for (auto val : indices) {
187186
if (isAccessIndexInvariant(iv, val)) {
188187
res.insert(val);
189188
}

mlir/lib/Analysis/Utils.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -817,15 +817,15 @@ mlir::computeSliceUnion(ArrayRef<Operation *> opsA, ArrayRef<Operation *> opsB,
817817
FlatAffineValueConstraints sliceUnionCst;
818818
assert(sliceUnionCst.getNumDimAndSymbolIds() == 0);
819819
std::vector<std::pair<Operation *, Operation *>> dependentOpPairs;
820-
for (unsigned i = 0, numOpsA = opsA.size(); i < numOpsA; ++i) {
821-
MemRefAccess srcAccess(opsA[i]);
822-
for (unsigned j = 0, numOpsB = opsB.size(); j < numOpsB; ++j) {
823-
MemRefAccess dstAccess(opsB[j]);
820+
for (auto i : opsA) {
821+
MemRefAccess srcAccess(i);
822+
for (auto j : opsB) {
823+
MemRefAccess dstAccess(j);
824824
if (srcAccess.memref != dstAccess.memref)
825825
continue;
826826
// Check if 'loopDepth' exceeds nesting depth of src/dst ops.
827-
if ((!isBackwardSlice && loopDepth > getNestingDepth(opsA[i])) ||
828-
(isBackwardSlice && loopDepth > getNestingDepth(opsB[j]))) {
827+
if ((!isBackwardSlice && loopDepth > getNestingDepth(i)) ||
828+
(isBackwardSlice && loopDepth > getNestingDepth(j))) {
829829
LLVM_DEBUG(llvm::dbgs() << "Invalid loop depth\n");
830830
return SliceComputationResult::GenericFailure;
831831
}
@@ -844,13 +844,12 @@ mlir::computeSliceUnion(ArrayRef<Operation *> opsA, ArrayRef<Operation *> opsB,
844844
}
845845
if (result.value == DependenceResult::NoDependence)
846846
continue;
847-
dependentOpPairs.push_back({opsA[i], opsB[j]});
847+
dependentOpPairs.emplace_back(i, j);
848848

849849
// Compute slice bounds for 'srcAccess' and 'dstAccess'.
850850
ComputationSliceState tmpSliceState;
851-
mlir::getComputationSliceState(opsA[i], opsB[j], &dependenceConstraints,
852-
loopDepth, isBackwardSlice,
853-
&tmpSliceState);
851+
mlir::getComputationSliceState(i, j, &dependenceConstraints, loopDepth,
852+
isBackwardSlice, &tmpSliceState);
854853

855854
if (sliceUnionCst.getNumDimAndSymbolIds() == 0) {
856855
// Initialize 'sliceUnionCst' with the bounds computed in previous step.

mlir/lib/Bindings/Python/IRAffine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ void mlir::python::populateIRAffine(py::module &m) {
676676
std::vector<PyAffineMap> res;
677677
res.reserve(compressed.size());
678678
for (auto m : compressed)
679-
res.push_back(PyAffineMap(context->getRef(), m));
679+
res.emplace_back(context->getRef(), m);
680680
return res;
681681
})
682682
.def_property_readonly(

mlir/lib/Bindings/Python/IRAttributes.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,8 @@ class PyDenseElementsAttribute
524524
mlirIntegerTypeIsSigned(elementType)) {
525525
// i32
526526
return bufferInfo<int32_t>(shapedType);
527-
} else if (mlirIntegerTypeIsUnsigned(elementType)) {
527+
}
528+
if (mlirIntegerTypeIsUnsigned(elementType)) {
528529
// unsigned i32
529530
return bufferInfo<uint32_t>(shapedType);
530531
}
@@ -534,7 +535,8 @@ class PyDenseElementsAttribute
534535
mlirIntegerTypeIsSigned(elementType)) {
535536
// i64
536537
return bufferInfo<int64_t>(shapedType);
537-
} else if (mlirIntegerTypeIsUnsigned(elementType)) {
538+
}
539+
if (mlirIntegerTypeIsUnsigned(elementType)) {
538540
// unsigned i64
539541
return bufferInfo<uint64_t>(shapedType);
540542
}
@@ -544,7 +546,8 @@ class PyDenseElementsAttribute
544546
mlirIntegerTypeIsSigned(elementType)) {
545547
// i8
546548
return bufferInfo<int8_t>(shapedType);
547-
} else if (mlirIntegerTypeIsUnsigned(elementType)) {
549+
}
550+
if (mlirIntegerTypeIsUnsigned(elementType)) {
548551
// unsigned i8
549552
return bufferInfo<uint8_t>(shapedType);
550553
}
@@ -554,7 +557,8 @@ class PyDenseElementsAttribute
554557
mlirIntegerTypeIsSigned(elementType)) {
555558
// i16
556559
return bufferInfo<int16_t>(shapedType);
557-
} else if (mlirIntegerTypeIsUnsigned(elementType)) {
560+
}
561+
if (mlirIntegerTypeIsUnsigned(elementType)) {
558562
// unsigned i16
559563
return bufferInfo<uint16_t>(shapedType);
560564
}

mlir/lib/Bindings/Python/IRInterfaces.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ class PyInferTypeOpInterface
175175
auto *data = static_cast<AppendResultsCallbackData *>(userData);
176176
data->inferredTypes.reserve(data->inferredTypes.size() + nTypes);
177177
for (intptr_t i = 0; i < nTypes; ++i) {
178-
data->inferredTypes.push_back(
179-
PyType(data->pyMlirContext.getRef(), types[i]));
178+
data->inferredTypes.emplace_back(data->pyMlirContext.getRef(), types[i]);
180179
}
181180
}
182181

mlir/lib/Bindings/Python/IRModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ PyGlobals::PyGlobals() {
2929
instance = this;
3030
// The default search path include {mlir.}dialects, where {mlir.} is the
3131
// package prefix configured at compile time.
32-
dialectSearchPrefixes.push_back(MAKE_MLIR_PYTHON_QUALNAME("dialects"));
32+
dialectSearchPrefixes.emplace_back(MAKE_MLIR_PYTHON_QUALNAME("dialects"));
3333
}
3434

3535
PyGlobals::~PyGlobals() { instance = nullptr; }

mlir/lib/CAPI/IR/Diagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ MlirDiagnosticHandlerID mlirContextAttachDiagnosticHandler(
5757
MlirContext context, MlirDiagnosticHandler handler, void *userData,
5858
void (*deleteUserData)(void *)) {
5959
assert(handler && "unexpected null diagnostic handler");
60-
if (deleteUserData == NULL)
60+
if (deleteUserData == nullptr)
6161
deleteUserData = deleteUserDataNoop;
6262
std::shared_ptr<void> sharedUserData(userData, deleteUserData);
6363
DiagnosticEngine::HandlerID id =

mlir/lib/Conversion/PDLToPDLInterp/Predicate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ using namespace mlir::pdl_to_pdl_interp;
1515
// Positions
1616
//===----------------------------------------------------------------------===//
1717

18-
Position::~Position() {}
18+
Position::~Position() = default;
1919

2020
/// Returns the depth of the first ancestor operation position.
2121
unsigned Position::getOperationDepth() const {

0 commit comments

Comments
 (0)