aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMehdi Amini <joker.eph@gmail.com>2021-12-22 00:19:53 +0000
committerMehdi Amini <joker.eph@gmail.com>2021-12-22 20:53:11 +0000
commite5639b3fa45f68c53e8e676749b0f1aacd16b41d (patch)
tree8b22ad24b39cf84ece9e3ec8eb16570f45d30692
parentdcb3e8083a3229b44e23d5d1c19453f0777f3aa2 (diff)
downloadllvm-e5639b3fa45f68c53e8e676749b0f1aacd16b41d.zip
llvm-e5639b3fa45f68c53e8e676749b0f1aacd16b41d.tar.gz
llvm-e5639b3fa45f68c53e8e676749b0f1aacd16b41d.tar.bz2
Fix more clang-tidy cleanups in mlir/ (NFC)
-rw-r--r--mlir/lib/Analysis/DataFlowAnalysis.cpp4
-rw-r--r--mlir/lib/Analysis/Liveness.cpp4
-rw-r--r--mlir/lib/Analysis/LoopAnalysis.cpp3
-rw-r--r--mlir/lib/Analysis/Utils.cpp19
-rw-r--r--mlir/lib/Bindings/Python/IRAffine.cpp2
-rw-r--r--mlir/lib/Bindings/Python/IRAttributes.cpp12
-rw-r--r--mlir/lib/Bindings/Python/IRInterfaces.cpp3
-rw-r--r--mlir/lib/Bindings/Python/IRModule.cpp2
-rw-r--r--mlir/lib/CAPI/IR/Diagnostics.cpp2
-rw-r--r--mlir/lib/Conversion/PDLToPDLInterp/Predicate.cpp2
-rw-r--r--mlir/lib/Dialect/Affine/IR/AffineValueMap.cpp2
-rw-r--r--mlir/lib/Dialect/Affine/Transforms/AffineParallelize.cpp2
-rw-r--r--mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp4
-rw-r--r--mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp4
-rw-r--r--mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp2
-rw-r--r--mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp4
-rw-r--r--mlir/lib/Dialect/Tosa/Transforms/TosaOptimization.cpp2
-rw-r--r--mlir/lib/Dialect/Vector/VectorOps.cpp2
-rw-r--r--mlir/lib/ExecutionEngine/AsyncRuntime.cpp8
-rw-r--r--mlir/lib/ExecutionEngine/CRunnerUtils.cpp2
-rw-r--r--mlir/lib/ExecutionEngine/SparseTensorUtils.cpp8
-rw-r--r--mlir/lib/IR/AsmPrinter.cpp14
-rw-r--r--mlir/lib/IR/Builders.cpp2
-rw-r--r--mlir/lib/IR/Diagnostics.cpp6
-rw-r--r--mlir/lib/IR/Dialect.cpp6
-rw-r--r--mlir/lib/IR/MLIRContext.cpp2
-rw-r--r--mlir/lib/Parser/AsmParserState.cpp2
-rw-r--r--mlir/lib/Parser/AttributeParser.cpp2
-rw-r--r--mlir/lib/Parser/DialectSymbolParser.cpp2
-rw-r--r--mlir/lib/Parser/Parser.cpp3
-rw-r--r--mlir/lib/Pass/IRPrinting.cpp2
-rw-r--r--mlir/lib/Pass/Pass.cpp14
-rw-r--r--mlir/lib/Pass/PassCrashRecovery.cpp2
-rw-r--r--mlir/lib/Pass/PassRegistry.cpp8
-rw-r--r--mlir/lib/Pass/PassStatistics.cpp2
-rw-r--r--mlir/lib/Reducer/ReductionNode.cpp2
-rw-r--r--mlir/lib/Reducer/Tester.cpp2
-rw-r--r--mlir/lib/Rewrite/FrozenRewritePatternSet.cpp2
-rw-r--r--mlir/lib/Rewrite/PatternApplicator.cpp2
-rw-r--r--mlir/lib/Support/StorageUniquer.cpp2
-rw-r--r--mlir/lib/Support/Timing.cpp2
-rw-r--r--mlir/lib/TableGen/Attribute.cpp2
-rw-r--r--mlir/lib/TableGen/Pass.cpp4
-rw-r--r--mlir/lib/TableGen/Pattern.cpp2
-rw-r--r--mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp2
-rw-r--r--mlir/lib/Target/LLVMIR/TypeToLLVM.cpp2
-rw-r--r--mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp2
-rw-r--r--mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp2
-rw-r--r--mlir/lib/Transforms/LoopFusion.cpp2
-rw-r--r--mlir/lib/Transforms/Utils/DialectConversion.cpp2
-rw-r--r--mlir/lib/Transforms/Utils/LoopUtils.cpp12
-rw-r--r--mlir/test/lib/Analysis/TestAliasAnalysis.cpp4
-rw-r--r--mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp14
-rw-r--r--mlir/test/lib/IR/TestDiagnostics.cpp2
-rw-r--r--mlir/test/lib/IR/TestOpaqueLoc.cpp4
-rw-r--r--mlir/test/lib/Pass/TestDynamicPipeline.cpp2
-rw-r--r--mlir/test/lib/Transforms/TestLoopMapping.cpp2
-rw-r--r--mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp2
-rw-r--r--mlir/tools/mlir-tblgen/PassGen.cpp4
-rw-r--r--mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp2
-rw-r--r--mlir/unittests/Pass/PassManagerTest.cpp4
61 files changed, 122 insertions, 122 deletions
diff --git a/mlir/lib/Analysis/DataFlowAnalysis.cpp b/mlir/lib/Analysis/DataFlowAnalysis.cpp
index c664211..ca17e95 100644
--- a/mlir/lib/Analysis/DataFlowAnalysis.cpp
+++ b/mlir/lib/Analysis/DataFlowAnalysis.cpp
@@ -756,13 +756,13 @@ void ForwardDataFlowSolver::join(Operation *owner, AbstractLatticeElement &to,
// AbstractLatticeElement
//===----------------------------------------------------------------------===//
-AbstractLatticeElement::~AbstractLatticeElement() {}
+AbstractLatticeElement::~AbstractLatticeElement() = default;
//===----------------------------------------------------------------------===//
// ForwardDataFlowAnalysisBase
//===----------------------------------------------------------------------===//
-ForwardDataFlowAnalysisBase::~ForwardDataFlowAnalysisBase() {}
+ForwardDataFlowAnalysisBase::~ForwardDataFlowAnalysisBase() = default;
AbstractLatticeElement &
ForwardDataFlowAnalysisBase::getLatticeElement(Value value) {
diff --git a/mlir/lib/Analysis/Liveness.cpp b/mlir/lib/Analysis/Liveness.cpp
index 3906167..64ff321 100644
--- a/mlir/lib/Analysis/Liveness.cpp
+++ b/mlir/lib/Analysis/Liveness.cpp
@@ -27,7 +27,7 @@ struct BlockInfoBuilder {
using ValueSetT = Liveness::ValueSetT;
/// Constructs an empty block builder.
- BlockInfoBuilder() : block(nullptr) {}
+ BlockInfoBuilder() {}
/// Fills the block builder with initial liveness information.
BlockInfoBuilder(Block *block) : block(block) {
@@ -104,7 +104,7 @@ struct BlockInfoBuilder {
}
/// The current block.
- Block *block;
+ Block *block{nullptr};
/// The set of all live in values.
ValueSetT inValues;
diff --git a/mlir/lib/Analysis/LoopAnalysis.cpp b/mlir/lib/Analysis/LoopAnalysis.cpp
index 478b212..e6c9863 100644
--- a/mlir/lib/Analysis/LoopAnalysis.cpp
+++ b/mlir/lib/Analysis/LoopAnalysis.cpp
@@ -182,8 +182,7 @@ static bool isAccessIndexInvariant(Value iv, Value index) {
DenseSet<Value> mlir::getInvariantAccesses(Value iv, ArrayRef<Value> indices) {
DenseSet<Value> res;
- for (unsigned idx = 0, n = indices.size(); idx < n; ++idx) {
- auto val = indices[idx];
+ for (auto val : indices) {
if (isAccessIndexInvariant(iv, val)) {
res.insert(val);
}
diff --git a/mlir/lib/Analysis/Utils.cpp b/mlir/lib/Analysis/Utils.cpp
index 097828e..a9697ca 100644
--- a/mlir/lib/Analysis/Utils.cpp
+++ b/mlir/lib/Analysis/Utils.cpp
@@ -817,15 +817,15 @@ mlir::computeSliceUnion(ArrayRef<Operation *> opsA, ArrayRef<Operation *> opsB,
FlatAffineValueConstraints sliceUnionCst;
assert(sliceUnionCst.getNumDimAndSymbolIds() == 0);
std::vector<std::pair<Operation *, Operation *>> dependentOpPairs;
- for (unsigned i = 0, numOpsA = opsA.size(); i < numOpsA; ++i) {
- MemRefAccess srcAccess(opsA[i]);
- for (unsigned j = 0, numOpsB = opsB.size(); j < numOpsB; ++j) {
- MemRefAccess dstAccess(opsB[j]);
+ for (auto i : opsA) {
+ MemRefAccess srcAccess(i);
+ for (auto j : opsB) {
+ MemRefAccess dstAccess(j);
if (srcAccess.memref != dstAccess.memref)
continue;
// Check if 'loopDepth' exceeds nesting depth of src/dst ops.
- if ((!isBackwardSlice && loopDepth > getNestingDepth(opsA[i])) ||
- (isBackwardSlice && loopDepth > getNestingDepth(opsB[j]))) {
+ if ((!isBackwardSlice && loopDepth > getNestingDepth(i)) ||
+ (isBackwardSlice && loopDepth > getNestingDepth(j))) {
LLVM_DEBUG(llvm::dbgs() << "Invalid loop depth\n");
return SliceComputationResult::GenericFailure;
}
@@ -844,13 +844,12 @@ mlir::computeSliceUnion(ArrayRef<Operation *> opsA, ArrayRef<Operation *> opsB,
}
if (result.value == DependenceResult::NoDependence)
continue;
- dependentOpPairs.push_back({opsA[i], opsB[j]});
+ dependentOpPairs.emplace_back(i, j);
// Compute slice bounds for 'srcAccess' and 'dstAccess'.
ComputationSliceState tmpSliceState;
- mlir::getComputationSliceState(opsA[i], opsB[j], &dependenceConstraints,
- loopDepth, isBackwardSlice,
- &tmpSliceState);
+ mlir::getComputationSliceState(i, j, &dependenceConstraints, loopDepth,
+ isBackwardSlice, &tmpSliceState);
if (sliceUnionCst.getNumDimAndSymbolIds() == 0) {
// Initialize 'sliceUnionCst' with the bounds computed in previous step.
diff --git a/mlir/lib/Bindings/Python/IRAffine.cpp b/mlir/lib/Bindings/Python/IRAffine.cpp
index faf01e5..c7cdc82 100644
--- a/mlir/lib/Bindings/Python/IRAffine.cpp
+++ b/mlir/lib/Bindings/Python/IRAffine.cpp
@@ -676,7 +676,7 @@ void mlir::python::populateIRAffine(py::module &m) {
std::vector<PyAffineMap> res;
res.reserve(compressed.size());
for (auto m : compressed)
- res.push_back(PyAffineMap(context->getRef(), m));
+ res.emplace_back(context->getRef(), m);
return res;
})
.def_property_readonly(
diff --git a/mlir/lib/Bindings/Python/IRAttributes.cpp b/mlir/lib/Bindings/Python/IRAttributes.cpp
index f120661..56d16b3 100644
--- a/mlir/lib/Bindings/Python/IRAttributes.cpp
+++ b/mlir/lib/Bindings/Python/IRAttributes.cpp
@@ -524,7 +524,8 @@ public:
mlirIntegerTypeIsSigned(elementType)) {
// i32
return bufferInfo<int32_t>(shapedType);
- } else if (mlirIntegerTypeIsUnsigned(elementType)) {
+ }
+ if (mlirIntegerTypeIsUnsigned(elementType)) {
// unsigned i32
return bufferInfo<uint32_t>(shapedType);
}
@@ -534,7 +535,8 @@ public:
mlirIntegerTypeIsSigned(elementType)) {
// i64
return bufferInfo<int64_t>(shapedType);
- } else if (mlirIntegerTypeIsUnsigned(elementType)) {
+ }
+ if (mlirIntegerTypeIsUnsigned(elementType)) {
// unsigned i64
return bufferInfo<uint64_t>(shapedType);
}
@@ -544,7 +546,8 @@ public:
mlirIntegerTypeIsSigned(elementType)) {
// i8
return bufferInfo<int8_t>(shapedType);
- } else if (mlirIntegerTypeIsUnsigned(elementType)) {
+ }
+ if (mlirIntegerTypeIsUnsigned(elementType)) {
// unsigned i8
return bufferInfo<uint8_t>(shapedType);
}
@@ -554,7 +557,8 @@ public:
mlirIntegerTypeIsSigned(elementType)) {
// i16
return bufferInfo<int16_t>(shapedType);
- } else if (mlirIntegerTypeIsUnsigned(elementType)) {
+ }
+ if (mlirIntegerTypeIsUnsigned(elementType)) {
// unsigned i16
return bufferInfo<uint16_t>(shapedType);
}
diff --git a/mlir/lib/Bindings/Python/IRInterfaces.cpp b/mlir/lib/Bindings/Python/IRInterfaces.cpp
index c3d41c4..564f36b 100644
--- a/mlir/lib/Bindings/Python/IRInterfaces.cpp
+++ b/mlir/lib/Bindings/Python/IRInterfaces.cpp
@@ -175,8 +175,7 @@ public:
auto *data = static_cast<AppendResultsCallbackData *>(userData);
data->inferredTypes.reserve(data->inferredTypes.size() + nTypes);
for (intptr_t i = 0; i < nTypes; ++i) {
- data->inferredTypes.push_back(
- PyType(data->pyMlirContext.getRef(), types[i]));
+ data->inferredTypes.emplace_back(data->pyMlirContext.getRef(), types[i]);
}
}
diff --git a/mlir/lib/Bindings/Python/IRModule.cpp b/mlir/lib/Bindings/Python/IRModule.cpp
index 7008e54..633ffe4 100644
--- a/mlir/lib/Bindings/Python/IRModule.cpp
+++ b/mlir/lib/Bindings/Python/IRModule.cpp
@@ -29,7 +29,7 @@ PyGlobals::PyGlobals() {
instance = this;
// The default search path include {mlir.}dialects, where {mlir.} is the
// package prefix configured at compile time.
- dialectSearchPrefixes.push_back(MAKE_MLIR_PYTHON_QUALNAME("dialects"));
+ dialectSearchPrefixes.emplace_back(MAKE_MLIR_PYTHON_QUALNAME("dialects"));
}
PyGlobals::~PyGlobals() { instance = nullptr; }
diff --git a/mlir/lib/CAPI/IR/Diagnostics.cpp b/mlir/lib/CAPI/IR/Diagnostics.cpp
index 2ed05a5..40639c7 100644
--- a/mlir/lib/CAPI/IR/Diagnostics.cpp
+++ b/mlir/lib/CAPI/IR/Diagnostics.cpp
@@ -57,7 +57,7 @@ MlirDiagnosticHandlerID mlirContextAttachDiagnosticHandler(
MlirContext context, MlirDiagnosticHandler handler, void *userData,
void (*deleteUserData)(void *)) {
assert(handler && "unexpected null diagnostic handler");
- if (deleteUserData == NULL)
+ if (deleteUserData == nullptr)
deleteUserData = deleteUserDataNoop;
std::shared_ptr<void> sharedUserData(userData, deleteUserData);
DiagnosticEngine::HandlerID id =
diff --git a/mlir/lib/Conversion/PDLToPDLInterp/Predicate.cpp b/mlir/lib/Conversion/PDLToPDLInterp/Predicate.cpp
index 8d6d877..07fa5c7 100644
--- a/mlir/lib/Conversion/PDLToPDLInterp/Predicate.cpp
+++ b/mlir/lib/Conversion/PDLToPDLInterp/Predicate.cpp
@@ -15,7 +15,7 @@ using namespace mlir::pdl_to_pdl_interp;
// Positions
//===----------------------------------------------------------------------===//
-Position::~Position() {}
+Position::~Position() = default;
/// Returns the depth of the first ancestor operation position.
unsigned Position::getOperationDepth() const {
diff --git a/mlir/lib/Dialect/Affine/IR/AffineValueMap.cpp b/mlir/lib/Dialect/Affine/IR/AffineValueMap.cpp
index a17eb41..7e2dfaf 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineValueMap.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineValueMap.cpp
@@ -99,4 +99,4 @@ ArrayRef<Value> AffineValueMap::getOperands() const {
AffineMap AffineValueMap::getAffineMap() const { return map.getAffineMap(); }
-AffineValueMap::~AffineValueMap() {}
+AffineValueMap::~AffineValueMap() = default;
diff --git a/mlir/lib/Dialect/Affine/Transforms/AffineParallelize.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineParallelize.cpp
index 237094d..add9a80 100644
--- a/mlir/lib/Dialect/Affine/Transforms/AffineParallelize.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/AffineParallelize.cpp
@@ -56,7 +56,7 @@ void AffineParallelize::runOnFunction() {
f.walk<WalkOrder::PreOrder>([&](AffineForOp loop) {
SmallVector<LoopReduction> reductions;
if (isLoopParallel(loop, parallelReductions ? &reductions : nullptr))
- parallelizableLoops.push_back({loop, std::move(reductions)});
+ parallelizableLoops.emplace_back(loop, std::move(reductions));
});
for (const ParallelizationCandidate &candidate : parallelizableLoops) {
diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp
index f876153..5063d8c 100644
--- a/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp
@@ -41,8 +41,8 @@ struct LoopUnroll : public AffineLoopUnrollBase<LoopUnroll> {
LoopUnroll() : getUnrollFactor(nullptr) {}
LoopUnroll(const LoopUnroll &other)
- : AffineLoopUnrollBase<LoopUnroll>(other),
- getUnrollFactor(other.getUnrollFactor) {}
+
+ = default;
explicit LoopUnroll(
Optional<unsigned> unrollFactor = None, bool unrollUpToFactor = false,
bool unrollFull = false,
diff --git a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
index 0e41d02..9d59b89 100644
--- a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
@@ -1494,7 +1494,7 @@ getMatchedAffineLoopsRec(NestedMatch match, unsigned currentLevel,
// Add a new empty level to the output if it doesn't exist already.
assert(currentLevel <= loops.size() && "Unexpected currentLevel");
if (currentLevel == loops.size())
- loops.push_back(SmallVector<AffineForOp, 2>());
+ loops.emplace_back();
// Add current match and recursively visit its children.
loops[currentLevel].push_back(cast<AffineForOp>(match.getMatchedOperation()));
@@ -1631,7 +1631,7 @@ static void computeIntersectionBuckets(
// it.
if (!intersects) {
bucketRoots.push_back(matchRoot);
- intersectionBuckets.push_back(SmallVector<NestedMatch, 8>());
+ intersectionBuckets.emplace_back();
intersectionBuckets.back().push_back(match);
}
}
diff --git a/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp b/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp
index 5255bd2..61a9f1b 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp
@@ -33,7 +33,7 @@ namespace {
struct LinalgComprehensiveModuleBufferize
: public LinalgComprehensiveModuleBufferizeBase<
LinalgComprehensiveModuleBufferize> {
- LinalgComprehensiveModuleBufferize() {}
+ LinalgComprehensiveModuleBufferize() = default;
LinalgComprehensiveModuleBufferize(
const LinalgComprehensiveModuleBufferize &p) {}
diff --git a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
index 4858ffd..024d380 100644
--- a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
+++ b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
@@ -61,8 +61,8 @@ Attribute SparseTensorEncodingAttr::parse(AsmParser &parser, Type type) {
"expected an array for dimension level types");
return {};
}
- for (unsigned i = 0, e = arrayAttr.size(); i < e; i++) {
- auto strAttr = arrayAttr[i].dyn_cast<StringAttr>();
+ for (auto i : arrayAttr) {
+ auto strAttr = i.dyn_cast<StringAttr>();
if (!strAttr) {
parser.emitError(parser.getNameLoc(),
"expected a string value in dimension level types");
diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaOptimization.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaOptimization.cpp
index e0ed33b..9a19b63 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaOptimization.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaOptimization.cpp
@@ -215,7 +215,7 @@ struct DepthwiseConv2DIsMul : public OpRewritePattern<tosa::DepthwiseConv2DOp> {
class TosaOptimization : public PassWrapper<TosaOptimization, FunctionPass> {
public:
- explicit TosaOptimization() {}
+ explicit TosaOptimization() = default;
void runOnFunction() override;
StringRef getArgument() const final { return PASS_NAME; }
diff --git a/mlir/lib/Dialect/Vector/VectorOps.cpp b/mlir/lib/Dialect/Vector/VectorOps.cpp
index 7b6534f..8c724f8 100644
--- a/mlir/lib/Dialect/Vector/VectorOps.cpp
+++ b/mlir/lib/Dialect/Vector/VectorOps.cpp
@@ -702,7 +702,7 @@ getDimMap(ArrayRef<AffineMap> indexingMaps, ArrayAttr iteratorTypes,
int64_t lhsDim = getResultIndex(indexingMaps[0], targetExpr);
int64_t rhsDim = getResultIndex(indexingMaps[1], targetExpr);
if (lhsDim >= 0 && rhsDim >= 0)
- dimMap.push_back({lhsDim, rhsDim});
+ dimMap.emplace_back(lhsDim, rhsDim);
}
return dimMap;
}
diff --git a/mlir/lib/ExecutionEngine/AsyncRuntime.cpp b/mlir/lib/ExecutionEngine/AsyncRuntime.cpp
index 1cf593b..0324370 100644
--- a/mlir/lib/ExecutionEngine/AsyncRuntime.cpp
+++ b/mlir/lib/ExecutionEngine/AsyncRuntime.cpp
@@ -289,7 +289,7 @@ extern "C" int64_t mlirAsyncRuntimeAddTokenToGroup(AsyncToken *token,
// then, and re-ackquire the lock.
group->addRef();
- token->awaiters.push_back([group, onTokenReady]() {
+ token->awaiters.emplace_back([group, onTokenReady]() {
// Make sure that `dropRef` does not destroy the mutex owned by the lock.
{
std::unique_lock<std::mutex> lockGroup(group->mu);
@@ -408,7 +408,7 @@ extern "C" void mlirAsyncRuntimeAwaitTokenAndExecute(AsyncToken *token,
lock.unlock();
execute();
} else {
- token->awaiters.push_back([execute]() { execute(); });
+ token->awaiters.emplace_back([execute]() { execute(); });
}
}
@@ -421,7 +421,7 @@ extern "C" void mlirAsyncRuntimeAwaitValueAndExecute(AsyncValue *value,
lock.unlock();
execute();
} else {
- value->awaiters.push_back([execute]() { execute(); });
+ value->awaiters.emplace_back([execute]() { execute(); });
}
}
@@ -434,7 +434,7 @@ extern "C" void mlirAsyncRuntimeAwaitAllInGroupAndExecute(AsyncGroup *group,
lock.unlock();
execute();
} else {
- group->awaiters.push_back([execute]() { execute(); });
+ group->awaiters.emplace_back([execute]() { execute(); });
}
}
diff --git a/mlir/lib/ExecutionEngine/CRunnerUtils.cpp b/mlir/lib/ExecutionEngine/CRunnerUtils.cpp
index 889d8c7..da28429 100644
--- a/mlir/lib/ExecutionEngine/CRunnerUtils.cpp
+++ b/mlir/lib/ExecutionEngine/CRunnerUtils.cpp
@@ -109,7 +109,7 @@ extern "C" void print_flops(double flops) {
extern "C" double rtclock() {
#ifndef _WIN32
struct timeval tp;
- int stat = gettimeofday(&tp, NULL);
+ int stat = gettimeofday(&tp, nullptr);
if (stat != 0)
fprintf(stderr, "Error returning time from gettimeofday: %d\n", stat);
return (tp.tv_sec + tp.tv_usec * 1.0e-6);
diff --git a/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp b/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
index 99d467e..5cc4066 100644
--- a/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
+++ b/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
@@ -217,7 +217,7 @@ public:
/// Finishes insertion.
virtual void endInsert() = 0;
- virtual ~SparseTensorStorageBase() {}
+ virtual ~SparseTensorStorageBase() = default;
private:
void fatal(const char *tp) {
@@ -277,7 +277,7 @@ public:
}
}
- virtual ~SparseTensorStorage() {}
+ virtual ~SparseTensorStorage() = default;
/// Get the rank of the tensor.
uint64_t getRank() const { return sizes.size(); }
@@ -574,7 +574,7 @@ static void readMMEHeader(FILE *file, char *filename, char *line,
exit(1);
}
// Skip comments.
- while (1) {
+ while (true) {
if (!fgets(line, kColWidth, file)) {
fprintf(stderr, "Cannot find data in %s\n", filename);
exit(1);
@@ -598,7 +598,7 @@ static void readMMEHeader(FILE *file, char *filename, char *line,
static void readExtFROSTTHeader(FILE *file, char *filename, char *line,
uint64_t *idata) {
// Skip comments.
- while (1) {
+ while (true) {
if (!fgets(line, kColWidth, file)) {
fprintf(stderr, "Cannot find data in %s\n", filename);
exit(1);
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 0b28106..376e5c1 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -54,9 +54,9 @@ void OperationName::dump() const { print(llvm::errs()); }
// AsmParser
//===--------------------------------------------------------------------===//
-AsmParser::~AsmParser() {}
-DialectAsmParser::~DialectAsmParser() {}
-OpAsmParser::~OpAsmParser() {}
+AsmParser::~AsmParser() = default;
+DialectAsmParser::~DialectAsmParser() = default;
+OpAsmParser::~OpAsmParser() = default;
MLIRContext *AsmParser::getContext() const { return getBuilder().getContext(); }
@@ -64,13 +64,13 @@ MLIRContext *AsmParser::getContext() const { return getBuilder().getContext(); }
// DialectAsmPrinter
//===----------------------------------------------------------------------===//
-DialectAsmPrinter::~DialectAsmPrinter() {}
+DialectAsmPrinter::~DialectAsmPrinter() = default;
//===----------------------------------------------------------------------===//
// OpAsmPrinter
//===----------------------------------------------------------------------===//
-OpAsmPrinter::~OpAsmPrinter() {}
+OpAsmPrinter::~OpAsmPrinter() = default;
void OpAsmPrinter::printFunctionalType(Operation *op) {
auto &os = getStream();
@@ -1221,7 +1221,7 @@ private:
AsmState::AsmState(Operation *op, const OpPrintingFlags &printerFlags,
LocationMap *locationMap)
: impl(std::make_unique<AsmStateImpl>(op, printerFlags, locationMap)) {}
-AsmState::~AsmState() {}
+AsmState::~AsmState() = default;
//===----------------------------------------------------------------------===//
// AsmPrinter::Impl
@@ -2116,7 +2116,7 @@ void AsmPrinter::Impl::printDialectType(Type type) {
// AsmPrinter
//===--------------------------------------------------------------------===//
-AsmPrinter::~AsmPrinter() {}
+AsmPrinter::~AsmPrinter() = default;
raw_ostream &AsmPrinter::getStream() const {
assert(impl && "expected AsmPrinter::getStream to be overriden");
diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp
index 9b91054..3d3e835 100644
--- a/mlir/lib/IR/Builders.cpp
+++ b/mlir/lib/IR/Builders.cpp
@@ -342,7 +342,7 @@ AffineMap Builder::getShiftedAffineMap(AffineMap map, int64_t shift) {
// OpBuilder
//===----------------------------------------------------------------------===//
-OpBuilder::Listener::~Listener() {}
+OpBuilder::Listener::~Listener() = default;
/// Insert the given operation at the current insertion point and return it.
Operation *OpBuilder::insert(Operation *op) {
diff --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp
index fc25258..327264a 100644
--- a/mlir/lib/IR/Diagnostics.cpp
+++ b/mlir/lib/IR/Diagnostics.cpp
@@ -257,7 +257,7 @@ void DiagnosticEngineImpl::emit(Diagnostic diag) {
//===----------------------------------------------------------------------===//
DiagnosticEngine::DiagnosticEngine() : impl(new DiagnosticEngineImpl()) {}
-DiagnosticEngine::~DiagnosticEngine() {}
+DiagnosticEngine::~DiagnosticEngine() = default;
/// Register a new handler for diagnostics to the engine. This function returns
/// a unique identifier for the registered handler, which can be used to
@@ -434,7 +434,7 @@ SourceMgrDiagnosticHandler::SourceMgrDiagnosticHandler(
: SourceMgrDiagnosticHandler(mgr, ctx, llvm::errs(),
std::move(shouldShowLocFn)) {}
-SourceMgrDiagnosticHandler::~SourceMgrDiagnosticHandler() {}
+SourceMgrDiagnosticHandler::~SourceMgrDiagnosticHandler() = default;
void SourceMgrDiagnosticHandler::emitDiagnostic(Location loc, Twine message,
DiagnosticSeverity kind,
@@ -952,7 +952,7 @@ struct ParallelDiagnosticHandlerImpl : public llvm::PrettyStackTraceEntry {
ParallelDiagnosticHandler::ParallelDiagnosticHandler(MLIRContext *ctx)
: impl(new ParallelDiagnosticHandlerImpl(ctx)) {}
-ParallelDiagnosticHandler::~ParallelDiagnosticHandler() {}
+ParallelDiagnosticHandler::~ParallelDiagnosticHandler() = default;
/// Set the order id for the current thread.
void ParallelDiagnosticHandler::setOrderIDForThread(size_t orderID) {
diff --git a/mlir/lib/IR/Dialect.cpp b/mlir/lib/IR/Dialect.cpp
index 631dc41..6d1d48e 100644
--- a/mlir/lib/IR/Dialect.cpp
+++ b/mlir/lib/IR/Dialect.cpp
@@ -124,7 +124,7 @@ Dialect::Dialect(StringRef name, MLIRContext *context, TypeID id)
assert(isValidNamespace(name) && "invalid dialect namespace");
}
-Dialect::~Dialect() {}
+Dialect::~Dialect() = default;
/// Verify an attribute from this dialect on the argument at 'argIndex' for
/// the region at 'regionIndex' on the given operation. Returns failure if
@@ -196,7 +196,7 @@ void Dialect::addInterface(std::unique_ptr<DialectInterface> interface) {
// Dialect Interface
//===----------------------------------------------------------------------===//
-DialectInterface::~DialectInterface() {}
+DialectInterface::~DialectInterface() = default;
DialectInterfaceCollectionBase::DialectInterfaceCollectionBase(
MLIRContext *ctx, TypeID interfaceKind) {
@@ -208,7 +208,7 @@ DialectInterfaceCollectionBase::DialectInterfaceCollectionBase(
}
}
-DialectInterfaceCollectionBase::~DialectInterfaceCollectionBase() {}
+DialectInterfaceCollectionBase::~DialectInterfaceCollectionBase() = default;
/// Get the interface for the dialect of given operation, or null if one
/// is not registered.
diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp
index 666ce301..96fe76e 100644
--- a/mlir/lib/IR/MLIRContext.cpp
+++ b/mlir/lib/IR/MLIRContext.cpp
@@ -321,7 +321,7 @@ MLIRContext::MLIRContext(const DialectRegistry &registry, Threading setting)
impl->affineUniquer.registerParametricStorageType<IntegerSetStorage>();
}
-MLIRContext::~MLIRContext() {}
+MLIRContext::~MLIRContext() = default;
/// Copy the specified array of elements into memory managed by the provided
/// bump pointer allocator. This assumes the elements are all PODs.
diff --git a/mlir/lib/Parser/AsmParserState.cpp b/mlir/lib/Parser/AsmParserState.cpp
index 95f6491..c5c0c9c 100644
--- a/mlir/lib/Parser/AsmParserState.cpp
+++ b/mlir/lib/Parser/AsmParserState.cpp
@@ -91,7 +91,7 @@ void AsmParserState::Impl::resolveSymbolUses() {
//===----------------------------------------------------------------------===//
AsmParserState::AsmParserState() : impl(std::make_unique<Impl>()) {}
-AsmParserState::~AsmParserState() {}
+AsmParserState::~AsmParserState() = default;
AsmParserState &AsmParserState::operator=(AsmParserState &&other) {
impl = std::move(other.impl);
return *this;
diff --git a/mlir/lib/Parser/AttributeParser.cpp b/mlir/lib/Parser/AttributeParser.cpp
index 13da92c..881e5b6 100644
--- a/mlir/lib/Parser/AttributeParser.cpp
+++ b/mlir/lib/Parser/AttributeParser.cpp
@@ -670,7 +670,7 @@ DenseElementsAttr TensorLiteralParser::getStringAttr(llvm::SMLoc loc,
for (auto val : storage) {
stringValues.push_back(val.second.getStringValue());
- stringRefValues.push_back(stringValues.back());
+ stringRefValues.emplace_back(stringValues.back());
}
return DenseStringElementsAttr::get(type, stringRefValues);
diff --git a/mlir/lib/Parser/DialectSymbolParser.cpp b/mlir/lib/Parser/DialectSymbolParser.cpp
index 36f583c..ded29d9 100644
--- a/mlir/lib/Parser/DialectSymbolParser.cpp
+++ b/mlir/lib/Parser/DialectSymbolParser.cpp
@@ -32,7 +32,7 @@ public:
CustomDialectAsmParser(StringRef fullSpec, Parser &parser)
: AsmParserImpl<DialectAsmParser>(parser.getToken().getLoc(), parser),
fullSpec(fullSpec) {}
- ~CustomDialectAsmParser() override {}
+ ~CustomDialectAsmParser() override = default;
/// Returns the full specification of the symbol being parsed. This allows
/// for using a separate parser if necessary.
diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp
index 87d8f4b..da765b6 100644
--- a/mlir/lib/Parser/Parser.cpp
+++ b/mlir/lib/Parser/Parser.cpp
@@ -1233,8 +1233,7 @@ public:
std::pair<StringRef, unsigned>
getResultName(unsigned resultNo) const override {
// Scan for the resultID that contains this result number.
- for (unsigned nameID = 0, e = resultIDs.size(); nameID != e; ++nameID) {
- const auto &entry = resultIDs[nameID];
+ for (const auto &entry : resultIDs) {
if (resultNo < std::get<1>(entry)) {
// Don't pass on the leading %.
StringRef name = std::get<0>(entry).drop_front();
diff --git a/mlir/lib/Pass/IRPrinting.cpp b/mlir/lib/Pass/IRPrinting.cpp
index 403d88d..e3d22f2 100644
--- a/mlir/lib/Pass/IRPrinting.cpp
+++ b/mlir/lib/Pass/IRPrinting.cpp
@@ -188,7 +188,7 @@ PassManager::IRPrinterConfig::IRPrinterConfig(bool printModuleScope,
printAfterOnlyOnChange(printAfterOnlyOnChange),
printAfterOnlyOnFailure(printAfterOnlyOnFailure),
opPrintingFlags(opPrintingFlags) {}
-PassManager::IRPrinterConfig::~IRPrinterConfig() {}
+PassManager::IRPrinterConfig::~IRPrinterConfig() = default;
/// A hook that may be overridden by a derived config that checks if the IR
/// of 'operation' should be dumped *before* the pass 'pass' has been
diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp
index 9117536..fff0083 100644
--- a/mlir/lib/Pass/Pass.cpp
+++ b/mlir/lib/Pass/Pass.cpp
@@ -182,9 +182,9 @@ void OpPassManagerImpl::coalesceAdjacentAdaptorPasses() {
// Walk the pass list and merge adjacent adaptors.
OpToOpPassAdaptor *lastAdaptor = nullptr;
- for (auto it = passes.begin(), e = passes.end(); it != e; ++it) {
+ for (auto &passe : passes) {
// Check to see if this pass is an adaptor.
- if (auto *currentAdaptor = dyn_cast<OpToOpPassAdaptor>(it->get())) {
+ if (auto *currentAdaptor = dyn_cast<OpToOpPassAdaptor>(passe.get())) {
// If it is the first adaptor in a possible chain, remember it and
// continue.
if (!lastAdaptor) {
@@ -194,7 +194,7 @@ void OpPassManagerImpl::coalesceAdjacentAdaptorPasses() {
// Otherwise, merge into the existing adaptor and delete the current one.
currentAdaptor->mergeInto(*lastAdaptor);
- it->reset();
+ passe.reset();
} else if (lastAdaptor) {
// If this pass is not an adaptor, then coalesce and forget any existing
// adaptor.
@@ -236,7 +236,7 @@ OpPassManager &OpPassManager::operator=(const OpPassManager &rhs) {
return *this;
}
-OpPassManager::~OpPassManager() {}
+OpPassManager::~OpPassManager() = default;
OpPassManager::pass_iterator OpPassManager::begin() {
return MutableArrayRef<std::unique_ptr<Pass>>{impl->passes}.begin();
@@ -634,7 +634,7 @@ PassManager::PassManager(MLIRContext *ctx, Nesting nesting,
initializationKey(DenseMapInfo<llvm::hash_code>::getTombstoneKey()),
passTiming(false), verifyPasses(true) {}
-PassManager::~PassManager() {}
+PassManager::~PassManager() = default;
void PassManager::enableVerifier(bool enabled) { verifyPasses = enabled; }
@@ -771,7 +771,7 @@ void detail::NestedAnalysisMap::invalidate(
// PassInstrumentation
//===----------------------------------------------------------------------===//
-PassInstrumentation::~PassInstrumentation() {}
+PassInstrumentation::~PassInstrumentation() = default;
//===----------------------------------------------------------------------===//
// PassInstrumentor
@@ -790,7 +790,7 @@ struct PassInstrumentorImpl {
} // namespace mlir
PassInstrumentor::PassInstrumentor() : impl(new PassInstrumentorImpl()) {}
-PassInstrumentor::~PassInstrumentor() {}
+PassInstrumentor::~PassInstrumentor() = default;
/// See PassInstrumentation::runBeforePipeline for details.
void PassInstrumentor::runBeforePipeline(
diff --git a/mlir/lib/Pass/PassCrashRecovery.cpp b/mlir/lib/Pass/PassCrashRecovery.cpp
index 46fec82..ea642ce 100644
--- a/mlir/lib/Pass/PassCrashRecovery.cpp
+++ b/mlir/lib/Pass/PassCrashRecovery.cpp
@@ -196,7 +196,7 @@ struct PassCrashReproducerGenerator::Impl {
PassCrashReproducerGenerator::PassCrashReproducerGenerator(
PassManager::ReproducerStreamFactory &streamFactory, bool localReproducer)
: impl(std::make_unique<Impl>(streamFactory, localReproducer)) {}
-PassCrashReproducerGenerator::~PassCrashReproducerGenerator() {}
+PassCrashReproducerGenerator::~PassCrashReproducerGenerator() = default;
void PassCrashReproducerGenerator::initialize(
iterator_range<PassManager::pass_iterator> passes, Operation *op,
diff --git a/mlir/lib/Pass/PassRegistry.cpp b/mlir/lib/Pass/PassRegistry.cpp
index eae5091..e86a315 100644
--- a/mlir/lib/Pass/PassRegistry.cpp
+++ b/mlir/lib/Pass/PassRegistry.cpp
@@ -505,13 +505,13 @@ namespace {
/// This struct represents the possible data entries in a parsed pass pipeline
/// list.
struct PassArgData {
- PassArgData() : registryEntry(nullptr) {}
+ PassArgData() {}
PassArgData(const PassRegistryEntry *registryEntry)
: registryEntry(registryEntry) {}
/// This field is used when the parsed option corresponds to a registered pass
/// or pass pipeline.
- const PassRegistryEntry *registryEntry;
+ const PassRegistryEntry *registryEntry{nullptr};
/// This field is set when instance specific pass options have been provided
/// on the command line.
@@ -694,7 +694,7 @@ struct PassPipelineCLParserImpl {
PassPipelineCLParser::PassPipelineCLParser(StringRef arg, StringRef description)
: impl(std::make_unique<detail::PassPipelineCLParserImpl>(
arg, description, /*passNamesOnly=*/false)) {}
-PassPipelineCLParser::~PassPipelineCLParser() {}
+PassPipelineCLParser::~PassPipelineCLParser() = default;
/// Returns true if this parser contains any valid options to add.
bool PassPipelineCLParser::hasAnyOccurrences() const {
@@ -737,7 +737,7 @@ PassNameCLParser::PassNameCLParser(StringRef arg, StringRef description)
arg, description, /*passNamesOnly=*/true)) {
impl->passList.setMiscFlag(llvm::cl::CommaSeparated);
}
-PassNameCLParser::~PassNameCLParser() {}
+PassNameCLParser::~PassNameCLParser() = default;
/// Returns true if this parser contains any valid options to add.
bool PassNameCLParser::hasAnyOccurrences() const {
diff --git a/mlir/lib/Pass/PassStatistics.cpp b/mlir/lib/Pass/PassStatistics.cpp
index 8b1b020..aa46ada 100644
--- a/mlir/lib/Pass/PassStatistics.cpp
+++ b/mlir/lib/Pass/PassStatistics.cpp
@@ -92,7 +92,7 @@ static void printResultsAsList(raw_ostream &os, OpPassManager &pm) {
// Sort the statistics by pass name and then by record name.
std::vector<std::pair<StringRef, std::vector<Statistic>>> passAndStatistics;
for (auto &passIt : mergedStats)
- passAndStatistics.push_back({passIt.first(), std::move(passIt.second)});
+ passAndStatistics.emplace_back(passIt.first(), std::move(passIt.second));
llvm::sort(passAndStatistics, [](const auto &lhs, const auto &rhs) {
return lhs.first.compare(rhs.first) < 0;
});
diff --git a/mlir/lib/Reducer/ReductionNode.cpp b/mlir/lib/Reducer/ReductionNode.cpp
index a9d1743..05d4c59 100644
--- a/mlir/lib/Reducer/ReductionNode.cpp
+++ b/mlir/lib/Reducer/ReductionNode.cpp
@@ -111,7 +111,7 @@ void ReductionNode::update(std::pair<Tester::Interestingness, size_t> result) {
if (interesting == Tester::Interestingness::True) {
// This module may has been updated. Reset the range.
ranges.clear();
- ranges.push_back({0, std::distance(region->op_begin(), region->op_end())});
+ ranges.emplace_back(0, std::distance(region->op_begin(), region->op_end()));
} else {
// Release the uninteresting module to save some memory.
module.release()->erase();
diff --git a/mlir/lib/Reducer/Tester.cpp b/mlir/lib/Reducer/Tester.cpp
index e519741..367ba4f 100644
--- a/mlir/lib/Reducer/Tester.cpp
+++ b/mlir/lib/Reducer/Tester.cpp
@@ -62,7 +62,7 @@ Tester::Interestingness Tester::isInteresting(StringRef testCase) const {
testerArgs.push_back(testCase);
for (const std::string &arg : testScriptArgs)
- testerArgs.push_back(arg);
+ testerArgs.emplace_back(arg);
testerArgs.push_back(testCase);
diff --git a/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp b/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp
index 20c71b5..7988150 100644
--- a/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp
+++ b/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp
@@ -133,4 +133,4 @@ FrozenRewritePatternSet::FrozenRewritePatternSet(
pdlPatterns.takeRewriteFunctions());
}
-FrozenRewritePatternSet::~FrozenRewritePatternSet() {}
+FrozenRewritePatternSet::~FrozenRewritePatternSet() = default;
diff --git a/mlir/lib/Rewrite/PatternApplicator.cpp b/mlir/lib/Rewrite/PatternApplicator.cpp
index ae8beff..d5a98fe 100644
--- a/mlir/lib/Rewrite/PatternApplicator.cpp
+++ b/mlir/lib/Rewrite/PatternApplicator.cpp
@@ -28,7 +28,7 @@ PatternApplicator::PatternApplicator(
bytecode->initializeMutableState(*mutableByteCodeState);
}
}
-PatternApplicator::~PatternApplicator() {}
+PatternApplicator::~PatternApplicator() = default;
#ifndef NDEBUG
/// Log a message for a pattern that is impossible to match.
diff --git a/mlir/lib/Support/StorageUniquer.cpp b/mlir/lib/Support/StorageUniquer.cpp
index 9291199..a33eb53 100644
--- a/mlir/lib/Support/StorageUniquer.cpp
+++ b/mlir/lib/Support/StorageUniquer.cpp
@@ -332,7 +332,7 @@ struct StorageUniquerImpl {
} // namespace mlir
StorageUniquer::StorageUniquer() : impl(new StorageUniquerImpl()) {}
-StorageUniquer::~StorageUniquer() {}
+StorageUniquer::~StorageUniquer() = default;
/// Set the flag specifying if multi-threading is disabled within the uniquer.
void StorageUniquer::disableMultithreading(bool disable) {
diff --git a/mlir/lib/Support/Timing.cpp b/mlir/lib/Support/Timing.cpp
index 63e0732..7277e48 100644
--- a/mlir/lib/Support/Timing.cpp
+++ b/mlir/lib/Support/Timing.cpp
@@ -60,7 +60,7 @@ public:
TimingManager::TimingManager() : impl(std::make_unique<TimingManagerImpl>()) {}
-TimingManager::~TimingManager() {}
+TimingManager::~TimingManager() = default;
/// Get the root timer of this timing manager.
Timer TimingManager::getRootTimer() {
diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp
index 630a920..ac62220 100644
--- a/mlir/lib/TableGen/Attribute.cpp
+++ b/mlir/lib/TableGen/Attribute.cpp
@@ -219,7 +219,7 @@ std::vector<EnumAttrCase> EnumAttr::getAllCases() const {
cases.reserve(inits->size());
for (const llvm::Init *init : *inits) {
- cases.push_back(EnumAttrCase(cast<llvm::DefInit>(init)));
+ cases.emplace_back(cast<llvm::DefInit>(init));
}
return cases;
diff --git a/mlir/lib/TableGen/Pass.cpp b/mlir/lib/TableGen/Pass.cpp
index f961806..84b3f01 100644
--- a/mlir/lib/TableGen/Pass.cpp
+++ b/mlir/lib/TableGen/Pass.cpp
@@ -66,9 +66,9 @@ StringRef PassStatistic::getDescription() const {
Pass::Pass(const llvm::Record *def) : def(def) {
for (auto *init : def->getValueAsListOfDefs("options"))
- options.push_back(PassOption(init));
+ options.emplace_back(init);
for (auto *init : def->getValueAsListOfDefs("statistics"))
- statistics.push_back(PassStatistic(init));
+ statistics.emplace_back(init);
for (StringRef dialect : def->getValueAsListOfStrings("dependentDialects"))
dependentDialects.push_back(dialect);
}
diff --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp
index b459af3..92cd681 100644
--- a/mlir/lib/TableGen/Pattern.cpp
+++ b/mlir/lib/TableGen/Pattern.cpp
@@ -663,7 +663,7 @@ std::vector<AppliedConstraint> Pattern::getConstraints() const {
&def,
"operands to additional constraints can only be symbol references");
}
- entities.push_back(std::string(argName->getValue()));
+ entities.emplace_back(argName->getValue());
}
ret.emplace_back(cast<llvm::DefInit>(dagInit->getOperator())->getDef(),
diff --git a/mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp b/mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp
index c987198..4efb533 100644
--- a/mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp
+++ b/mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp
@@ -157,7 +157,7 @@ private:
LLVM::TypeFromLLVMIRTranslator::TypeFromLLVMIRTranslator(MLIRContext &context)
: impl(new detail::TypeFromLLVMIRTranslatorImpl(context)) {}
-LLVM::TypeFromLLVMIRTranslator::~TypeFromLLVMIRTranslator() {}
+LLVM::TypeFromLLVMIRTranslator::~TypeFromLLVMIRTranslator() = default;
Type LLVM::TypeFromLLVMIRTranslator::translateType(llvm::Type *type) {
return impl->translateType(type);
diff --git a/mlir/lib/Target/LLVMIR/TypeToLLVM.cpp b/mlir/lib/Target/LLVMIR/TypeToLLVM.cpp
index 3d67984..2cd9869 100644
--- a/mlir/lib/Target/LLVMIR/TypeToLLVM.cpp
+++ b/mlir/lib/Target/LLVMIR/TypeToLLVM.cpp
@@ -180,7 +180,7 @@ private:
LLVM::TypeToLLVMIRTranslator::TypeToLLVMIRTranslator(llvm::LLVMContext &context)
: impl(new detail::TypeToLLVMIRTranslatorImpl(context)) {}
-LLVM::TypeToLLVMIRTranslator::~TypeToLLVMIRTranslator() {}
+LLVM::TypeToLLVMIRTranslator::~TypeToLLVMIRTranslator() = default;
llvm::Type *LLVM::TypeToLLVMIRTranslator::translateType(Type type) {
return impl->translateType(type);
diff --git a/mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp b/mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp
index 0d043ba..9360046 100644
--- a/mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp
+++ b/mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp
@@ -198,7 +198,7 @@ void LSPServer::Impl::onDocumentSymbol(
LSPServer::LSPServer(MLIRServer &server, JSONTransport &transport)
: impl(std::make_unique<Impl>(server, transport)) {}
-LSPServer::~LSPServer() {}
+LSPServer::~LSPServer() = default;
LogicalResult LSPServer::run() {
MessageHandler messageHandler(impl->transport);
diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
index 88aa462..046368a 100644
--- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
+++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
@@ -878,7 +878,7 @@ struct lsp::MLIRServer::Impl {
lsp::MLIRServer::MLIRServer(DialectRegistry &registry)
: impl(std::make_unique<Impl>(registry)) {}
-lsp::MLIRServer::~MLIRServer() {}
+lsp::MLIRServer::~MLIRServer() = default;
void lsp::MLIRServer::addOrUpdateDocument(
const URIForFile &uri, StringRef contents, int64_t version,
diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp
index 801268e..e6db0cf 100644
--- a/mlir/lib/Transforms/LoopFusion.cpp
+++ b/mlir/lib/Transforms/LoopFusion.cpp
@@ -198,7 +198,7 @@ public:
// The next unique identifier to use for newly created graph nodes.
unsigned nextNodeId = 0;
- MemRefDependenceGraph() {}
+ MemRefDependenceGraph() = default;
// Initializes the dependence graph based on operations in 'f'.
// Returns true on success, false otherwise.
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 97c6a4d..a299b8c 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -1492,7 +1492,7 @@ LogicalResult ConversionPatternRewriterImpl::notifyMatchFailure(
ConversionPatternRewriter::ConversionPatternRewriter(MLIRContext *ctx)
: PatternRewriter(ctx),
impl(new detail::ConversionPatternRewriterImpl(*this)) {}
-ConversionPatternRewriter::~ConversionPatternRewriter() {}
+ConversionPatternRewriter::~ConversionPatternRewriter() = default;
void ConversionPatternRewriter::replaceOpWithIf(
Operation *op, ValueRange newValues, bool *allUsesReplaced,
diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp
index c0eb9cd..fbb79b5 100644
--- a/mlir/lib/Transforms/Utils/LoopUtils.cpp
+++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp
@@ -407,7 +407,7 @@ LogicalResult mlir::affineForOpBodySkew(AffineForOp forOp,
lbShift = d * step;
}
// Augment the list of operations that get into the current open interval.
- opGroupQueue.push_back({d, sortedOpGroups[d]});
+ opGroupQueue.emplace_back(d, sortedOpGroups[d]);
}
// Those operations groups left in the queue now need to be processed (FIFO)
@@ -1370,7 +1370,7 @@ struct JamBlockGatherer {
while (it != e && !isa<AffineForOp>(&*it))
++it;
if (it != subBlockStart)
- subBlocks.push_back({subBlockStart, std::prev(it)});
+ subBlocks.emplace_back(subBlockStart, std::prev(it));
// Process all for ops that appear next.
while (it != e && isa<AffineForOp>(&*it))
walk(&*it++);
@@ -1608,8 +1608,7 @@ static bool checkLoopInterchangeDependences(
// lexicographically negative.
// Example 1: [-1, 1][0, 0]
// Example 2: [0, 0][-1, 1]
- for (unsigned i = 0, e = depCompsVec.size(); i < e; ++i) {
- const SmallVector<DependenceComponent, 2> &depComps = depCompsVec[i];
+ for (const auto &depComps : depCompsVec) {
assert(depComps.size() >= maxLoopDepth);
// Check if the first non-zero dependence component is positive.
// This iterates through loops in the desired order.
@@ -1748,8 +1747,7 @@ AffineForOp mlir::sinkSequentialLoops(AffineForOp forOp) {
// Mark loops as either parallel or sequential.
SmallVector<bool, 8> isParallelLoop(maxLoopDepth, true);
- for (unsigned i = 0, e = depCompsVec.size(); i < e; ++i) {
- SmallVector<DependenceComponent, 2> &depComps = depCompsVec[i];
+ for (auto &depComps : depCompsVec) {
assert(depComps.size() >= maxLoopDepth);
for (unsigned j = 0; j < maxLoopDepth; ++j) {
DependenceComponent &depComp = depComps[j];
@@ -3181,7 +3179,7 @@ gatherLoopsInBlock(Block *block, unsigned currLoopDepth,
// Add a new empty level to output if it doesn't exist level already.
assert(currLoopDepth <= depthToLoops.size() && "Unexpected currLoopDepth");
if (currLoopDepth == depthToLoops.size())
- depthToLoops.push_back(SmallVector<AffineForOp, 2>());
+ depthToLoops.emplace_back();
for (auto &op : *block) {
if (auto forOp = dyn_cast<AffineForOp>(op)) {
diff --git a/mlir/test/lib/Analysis/TestAliasAnalysis.cpp b/mlir/test/lib/Analysis/TestAliasAnalysis.cpp
index 081bc89e..01ab395 100644
--- a/mlir/test/lib/Analysis/TestAliasAnalysis.cpp
+++ b/mlir/test/lib/Analysis/TestAliasAnalysis.cpp
@@ -108,11 +108,11 @@ struct TestAliasAnalysisModRefPass
});
// Check for aliasing behavior between each of the values.
- for (auto it = valsToCheck.begin(), e = valsToCheck.end(); it != e; ++it) {
+ for (auto &it : valsToCheck) {
getOperation()->walk([&](Operation *op) {
if (!op->getAttr("test.ptr"))
return;
- printModRefResult(aliasAnalysis.getModRef(op, *it), op, *it);
+ printModRefResult(aliasAnalysis.getModRef(op, it), op, it);
});
}
}
diff --git a/mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp b/mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp
index d3e6788..01fba3a 100644
--- a/mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp
+++ b/mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp
@@ -48,18 +48,18 @@ getDirectionVectorStr(bool ret, unsigned numCommonLoops, unsigned loopNestDepth,
if (dependenceComponents.empty() || loopNestDepth > numCommonLoops)
return "true";
std::string result;
- for (unsigned i = 0, e = dependenceComponents.size(); i < e; ++i) {
+ for (const auto &dependenceComponent : dependenceComponents) {
std::string lbStr = "-inf";
- if (dependenceComponents[i].lb.hasValue() &&
- dependenceComponents[i].lb.getValue() !=
+ if (dependenceComponent.lb.hasValue() &&
+ dependenceComponent.lb.getValue() !=
std::numeric_limits<int64_t>::min())
- lbStr = std::to_string(dependenceComponents[i].lb.getValue());
+ lbStr = std::to_string(dependenceComponent.lb.getValue());
std::string ubStr = "+inf";
- if (dependenceComponents[i].ub.hasValue() &&
- dependenceComponents[i].ub.getValue() !=
+ if (dependenceComponent.ub.hasValue() &&
+ dependenceComponent.ub.getValue() !=
std::numeric_limits<int64_t>::max())
- ubStr = std::to_string(dependenceComponents[i].ub.getValue());
+ ubStr = std::to_string(dependenceComponent.ub.getValue());
result += "[" + lbStr + ", " + ubStr + "]";
}
diff --git a/mlir/test/lib/IR/TestDiagnostics.cpp b/mlir/test/lib/IR/TestDiagnostics.cpp
index 8bff82a..e6bb5f9 100644
--- a/mlir/test/lib/IR/TestDiagnostics.cpp
+++ b/mlir/test/lib/IR/TestDiagnostics.cpp
@@ -23,7 +23,7 @@ struct TestDiagnosticFilterPass
StringRef getDescription() const final {
return "Test diagnostic filtering support.";
}
- TestDiagnosticFilterPass() {}
+ TestDiagnosticFilterPass() = default;
TestDiagnosticFilterPass(const TestDiagnosticFilterPass &) {}
void runOnOperation() override {
diff --git a/mlir/test/lib/IR/TestOpaqueLoc.cpp b/mlir/test/lib/IR/TestOpaqueLoc.cpp
index 92a5c5a..0b24126 100644
--- a/mlir/test/lib/IR/TestOpaqueLoc.cpp
+++ b/mlir/test/lib/IR/TestOpaqueLoc.cpp
@@ -26,11 +26,11 @@ struct TestOpaqueLoc
/// A simple structure which is used for testing as an underlying location in
/// OpaqueLoc.
struct MyLocation {
- MyLocation() : id(42) {}
+ MyLocation() = default;
MyLocation(int id) : id(id) {}
int getId() { return id; }
- int id;
+ int id{42};
};
void runOnOperation() override {
diff --git a/mlir/test/lib/Pass/TestDynamicPipeline.cpp b/mlir/test/lib/Pass/TestDynamicPipeline.cpp
index d10dd4a..90b8820 100644
--- a/mlir/test/lib/Pass/TestDynamicPipeline.cpp
+++ b/mlir/test/lib/Pass/TestDynamicPipeline.cpp
@@ -32,7 +32,7 @@ public:
pm.getDependentDialects(registry);
}
- TestDynamicPipelinePass(){};
+ TestDynamicPipelinePass() = default;
TestDynamicPipelinePass(const TestDynamicPipelinePass &) {}
void runOnOperation() override {
diff --git a/mlir/test/lib/Transforms/TestLoopMapping.cpp b/mlir/test/lib/Transforms/TestLoopMapping.cpp
index ebd7398..721e697 100644
--- a/mlir/test/lib/Transforms/TestLoopMapping.cpp
+++ b/mlir/test/lib/Transforms/TestLoopMapping.cpp
@@ -32,7 +32,7 @@ public:
StringRef getDescription() const final {
return "test mapping a single loop on a virtual processor grid";
}
- explicit TestLoopMappingPass() {}
+ explicit TestLoopMappingPass() = default;
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<AffineDialect, scf::SCFDialect>();
diff --git a/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp b/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp
index 1a92f4a..e098e89 100644
--- a/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp
+++ b/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp
@@ -205,7 +205,7 @@ public:
std::vector<LLVMEnumAttrCase> cases;
for (auto &c : tblgen::EnumAttr::getAllCases())
- cases.push_back(LLVMEnumAttrCase(c));
+ cases.emplace_back(c);
return cases;
}
diff --git a/mlir/tools/mlir-tblgen/PassGen.cpp b/mlir/tools/mlir-tblgen/PassGen.cpp
index 1edd4db..7d98a60 100644
--- a/mlir/tools/mlir-tblgen/PassGen.cpp
+++ b/mlir/tools/mlir-tblgen/PassGen.cpp
@@ -94,7 +94,7 @@ static void emitPassOptionDecls(const Pass &pass, raw_ostream &os) {
os.indent(2) << "::mlir::Pass::"
<< (opt.isListOption() ? "ListOption" : "Option");
- os << llvm::formatv("<{0}> {1}{{*this, \"{2}\", ::llvm::cl::desc(\"{3}\")",
+ os << llvm::formatv(R"(<{0}> {1}{{*this, "{2}", ::llvm::cl::desc("{3}"))",
opt.getType(), opt.getCppVariableName(),
opt.getArgument(), opt.getDescription());
if (Optional<StringRef> defaultVal = opt.getDefaultValue())
@@ -198,7 +198,7 @@ static void emitDecls(const llvm::RecordKeeper &recordKeeper, raw_ostream &os) {
os << "/* Autogenerated by mlir-tblgen; don't manually edit */\n";
std::vector<Pass> passes;
for (const auto *def : recordKeeper.getAllDerivedDefinitions("PassBase"))
- passes.push_back(Pass(def));
+ passes.emplace_back(def);
emitPassDecls(passes, os);
emitRegistration(passes, os);
diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
index 2a290bb..ad0b05e 100644
--- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
+++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
@@ -1103,7 +1103,7 @@ emitExtendedSetDeserializationDispatch(const RecordKeeper &recordKeeper,
Operator op(def);
auto setName = def->getValueAsString("extendedInstSetName");
if (!extensionSets.count(setName)) {
- extensionSetNames.push_back("");
+ extensionSetNames.emplace_back("");
extensionSets.try_emplace(setName, extensionSetNames.back());
auto &setos = extensionSets.find(setName)->second;
setos << formatv(" if ({0} == \"{1}\") {{\n", extensionSetName, setName);
diff --git a/mlir/unittests/Pass/PassManagerTest.cpp b/mlir/unittests/Pass/PassManagerTest.cpp
index bd6ef04..ff1cda2 100644
--- a/mlir/unittests/Pass/PassManagerTest.cpp
+++ b/mlir/unittests/Pass/PassManagerTest.cpp
@@ -12,6 +12,8 @@
#include "mlir/Pass/Pass.h"
#include "gtest/gtest.h"
+#include <memory>
+
using namespace mlir;
using namespace mlir::detail;
@@ -105,7 +107,7 @@ TEST(PassManagerTest, InvalidPass) {
// check it later.
std::unique_ptr<Diagnostic> diagnostic;
context.getDiagEngine().registerHandler([&](Diagnostic &diag) {
- diagnostic.reset(new Diagnostic(std::move(diag)));
+ diagnostic = std::make_unique<Diagnostic>(std::move(diag));
});
// Instantiate and run our pass.