[Mlir-commits] [mlir] e5639b3 - Fix more clang-tidy cleanups in mlir/ (NFC)

Mehdi Amini llvmlistbot at llvm.org
Wed Dec 22 12:53:23 PST 2021


Author: Mehdi Amini
Date: 2021-12-22T20:53:11Z
New Revision: e5639b3fa45f68c53e8e676749b0f1aacd16b41d

URL: https://github.com/llvm/llvm-project/commit/e5639b3fa45f68c53e8e676749b0f1aacd16b41d
DIFF: https://github.com/llvm/llvm-project/commit/e5639b3fa45f68c53e8e676749b0f1aacd16b41d.diff

LOG: Fix more clang-tidy cleanups in mlir/ (NFC)

Added: 
    

Modified: 
    mlir/lib/Analysis/DataFlowAnalysis.cpp
    mlir/lib/Analysis/Liveness.cpp
    mlir/lib/Analysis/LoopAnalysis.cpp
    mlir/lib/Analysis/Utils.cpp
    mlir/lib/Bindings/Python/IRAffine.cpp
    mlir/lib/Bindings/Python/IRAttributes.cpp
    mlir/lib/Bindings/Python/IRInterfaces.cpp
    mlir/lib/Bindings/Python/IRModule.cpp
    mlir/lib/CAPI/IR/Diagnostics.cpp
    mlir/lib/Conversion/PDLToPDLInterp/Predicate.cpp
    mlir/lib/Dialect/Affine/IR/AffineValueMap.cpp
    mlir/lib/Dialect/Affine/Transforms/AffineParallelize.cpp
    mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp
    mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
    mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp
    mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
    mlir/lib/Dialect/Tosa/Transforms/TosaOptimization.cpp
    mlir/lib/Dialect/Vector/VectorOps.cpp
    mlir/lib/ExecutionEngine/AsyncRuntime.cpp
    mlir/lib/ExecutionEngine/CRunnerUtils.cpp
    mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
    mlir/lib/IR/AsmPrinter.cpp
    mlir/lib/IR/Builders.cpp
    mlir/lib/IR/Diagnostics.cpp
    mlir/lib/IR/Dialect.cpp
    mlir/lib/IR/MLIRContext.cpp
    mlir/lib/Parser/AsmParserState.cpp
    mlir/lib/Parser/AttributeParser.cpp
    mlir/lib/Parser/DialectSymbolParser.cpp
    mlir/lib/Parser/Parser.cpp
    mlir/lib/Pass/IRPrinting.cpp
    mlir/lib/Pass/Pass.cpp
    mlir/lib/Pass/PassCrashRecovery.cpp
    mlir/lib/Pass/PassRegistry.cpp
    mlir/lib/Pass/PassStatistics.cpp
    mlir/lib/Reducer/ReductionNode.cpp
    mlir/lib/Reducer/Tester.cpp
    mlir/lib/Rewrite/FrozenRewritePatternSet.cpp
    mlir/lib/Rewrite/PatternApplicator.cpp
    mlir/lib/Support/StorageUniquer.cpp
    mlir/lib/Support/Timing.cpp
    mlir/lib/TableGen/Attribute.cpp
    mlir/lib/TableGen/Pass.cpp
    mlir/lib/TableGen/Pattern.cpp
    mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp
    mlir/lib/Target/LLVMIR/TypeToLLVM.cpp
    mlir/lib/Tools/mlir-lsp-server/LSPServer.cpp
    mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
    mlir/lib/Transforms/LoopFusion.cpp
    mlir/lib/Transforms/Utils/DialectConversion.cpp
    mlir/lib/Transforms/Utils/LoopUtils.cpp
    mlir/test/lib/Analysis/TestAliasAnalysis.cpp
    mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp
    mlir/test/lib/IR/TestDiagnostics.cpp
    mlir/test/lib/IR/TestOpaqueLoc.cpp
    mlir/test/lib/Pass/TestDynamicPipeline.cpp
    mlir/test/lib/Transforms/TestLoopMapping.cpp
    mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp
    mlir/tools/mlir-tblgen/PassGen.cpp
    mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
    mlir/unittests/Pass/PassManagerTest.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Analysis/DataFlowAnalysis.cpp b/mlir/lib/Analysis/DataFlowAnalysis.cpp
index c6642112e8cbf..ca17e953e9904 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 39061679e295d..64ff321cb1e69 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 478b212c3b520..e6c9863887b3f 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 097828e077e75..a9697ca83a5a7 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 faf01e5c5f11d..c7cdc8243479c 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 f1206617d0690..56d16b337c072 100644
--- a/mlir/lib/Bindings/Python/IRAttributes.cpp
+++ b/mlir/lib/Bindings/Python/IRAttributes.cpp
@@ -524,7 +524,8 @@ class PyDenseElementsAttribute
           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 @@ class PyDenseElementsAttribute
           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 @@ class PyDenseElementsAttribute
           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 @@ class PyDenseElementsAttribute
           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 c3d41c4d84d79..564f36b9dac38 100644
--- a/mlir/lib/Bindings/Python/IRInterfaces.cpp
+++ b/mlir/lib/Bindings/Python/IRInterfaces.cpp
@@ -175,8 +175,7 @@ class PyInferTypeOpInterface
     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 7008e54bd0460..633ffe4e111bc 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 2ed05a5a06e69..40639c7ba31b7 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 8d6d8776bde32..07fa5c77c13fe 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 a17eb411acc89..7e2dfaf4db21c 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 237094d400062..add9a802ad785 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 f876153834bbd..5063d8c66977a 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 0e41d02d3c278..9d59b89ea1a2c 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 5255bd2d7b000..61a9f1b0cdb3b 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 4858ffd657eb8..024d380454d31 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 e0ed33bbe692a..9a19b63ed1983 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 7b6534ff1faa0..8c724f8ef0be8 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 1cf593bd4a4bc..03243700e9ecb 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 889d8c76964d7..da284294df373 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 99d467e34e2cd..5cc40665a8af1 100644
--- a/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
+++ b/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
@@ -217,7 +217,7 @@ class SparseTensorStorageBase {
   /// Finishes insertion.
   virtual void endInsert() = 0;
 
-  virtual ~SparseTensorStorageBase() {}
+  virtual ~SparseTensorStorageBase() = default;
 
 private:
   void fatal(const char *tp) {
@@ -277,7 +277,7 @@ class SparseTensorStorage : public SparseTensorStorageBase {
     }
   }
 
-  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 0b281069823c6..376e5c16fe6c3 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 @@ class AsmStateImpl {
 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 9b91054104dd4..3d3e835f4abff 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 fc252585dd212..327264a046c88 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 631dc410632ad..6d1d48edbefd6 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 666ce3013f984..96fe76eaac28d 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 95f64910541fe..c5c0c9cb9a2c7 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 13da92c05ff73..881e5b6d0e6db 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 36f583c602117..ded29d9d1f6b1 100644
--- a/mlir/lib/Parser/DialectSymbolParser.cpp
+++ b/mlir/lib/Parser/DialectSymbolParser.cpp
@@ -32,7 +32,7 @@ class CustomDialectAsmParser : public AsmParserImpl<DialectAsmParser> {
   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 87d8f4bcf4de3..da765b61243ba 100644
--- a/mlir/lib/Parser/Parser.cpp
+++ b/mlir/lib/Parser/Parser.cpp
@@ -1233,8 +1233,7 @@ class CustomOpAsmParser : public AsmParserImpl<OpAsmParser> {
   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 403d88d2d2933..e3d22f2b1cb0a 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 911753650d5eb..fff008330c793 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 46fec825d3d95..ea642ce44f5de 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 eae50918dbeaf..e86a315dc3559 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 8b1b020746c06..aa46adaf76e9c 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 a9d17431defed..05d4c594100b5 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 e5197418f3e59..367ba4f76b055 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 20c71b51c5f81..7988150bcba56 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 ae8beff061c85..d5a98fef09e72 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 9291199fdce15..a33eb53d4d480 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 63e07324c0b13..7277e48595822 100644
--- a/mlir/lib/Support/Timing.cpp
+++ b/mlir/lib/Support/Timing.cpp
@@ -60,7 +60,7 @@ class TimingManagerImpl {
 
 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 630a9205fc6c4..ac62220d85e47 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 f96180689c55a..84b3f01d1255c 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 b459af368fc53..92cd681620930 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 c987198f0c129..4efb5332cced5 100644
--- a/mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp
+++ b/mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp
@@ -157,7 +157,7 @@ class TypeFromLLVMIRTranslatorImpl {
 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 3d67984d7e41f..2cd98691e0c3b 100644
--- a/mlir/lib/Target/LLVMIR/TypeToLLVM.cpp
+++ b/mlir/lib/Target/LLVMIR/TypeToLLVM.cpp
@@ -180,7 +180,7 @@ class TypeToLLVMIRTranslatorImpl {
 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 0d043ba6ccbe5..93600465abcff 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 88aa4626b42f1..046368a3c4294 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 801268efdddbe..e6db0cf6927b8 100644
--- a/mlir/lib/Transforms/LoopFusion.cpp
+++ b/mlir/lib/Transforms/LoopFusion.cpp
@@ -198,7 +198,7 @@ struct MemRefDependenceGraph {
   // 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 97c6a4daaf82a..a299b8c5b6603 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 c0eb9cdfaf842..fbb79b5af3f86 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 081bc89e87478..01ab39503e9f0 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 d3e6788711d8c..01fba3acfa7d9 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 8bff82a22e625..e6bb5f90f57e1 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 92a5c5a41b2cc..0b24126d062b3 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 d10dd4a200fdb..90b88202f7e54 100644
--- a/mlir/test/lib/Pass/TestDynamicPipeline.cpp
+++ b/mlir/test/lib/Pass/TestDynamicPipeline.cpp
@@ -32,7 +32,7 @@ class TestDynamicPipelinePass
     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 ebd7398852369..721e697dd902d 100644
--- a/mlir/test/lib/Transforms/TestLoopMapping.cpp
+++ b/mlir/test/lib/Transforms/TestLoopMapping.cpp
@@ -32,7 +32,7 @@ class TestLoopMappingPass
   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 1a92f4a162ee2..e098e89da39d8 100644
--- a/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp
+++ b/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp
@@ -205,7 +205,7 @@ class LLVMEnumAttr : public tblgen::EnumAttr {
     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 1edd4db551cda..7d98a600519f8 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 2a290bb86b270..ad0b05e4c47b4 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 bd6ef0462a71e..ff1cda2116ba9 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.


        


More information about the Mlir-commits mailing list