[Mlir-commits] [mlir] 671e30a - Apply clang-tidy fixes for modernize-use-default-member-init to MLIR (NFC)
Mehdi Amini
llvmlistbot at llvm.org
Mon Mar 7 02:42:05 PST 2022
Author: Mehdi Amini
Date: 2022-03-07T10:41:44Z
New Revision: 671e30a12f8c6efc0181741d7060e5f1fc88c4f2
URL: https://github.com/llvm/llvm-project/commit/671e30a12f8c6efc0181741d7060e5f1fc88c4f2
DIFF: https://github.com/llvm/llvm-project/commit/671e30a12f8c6efc0181741d7060e5f1fc88c4f2.diff
LOG: Apply clang-tidy fixes for modernize-use-default-member-init to MLIR (NFC)
Added:
Modified:
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
mlir/lib/Dialect/Linalg/Utils/Utils.cpp
mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
mlir/lib/IR/Diagnostics.cpp
mlir/lib/Parser/AffineParser.cpp
mlir/lib/Pass/PassRegistry.cpp
mlir/lib/Tools/PDLL/Parser/Parser.cpp
mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
mlir/lib/Transforms/CSE.cpp
mlir/lib/Transforms/Utils/ControlFlowSinkUtils.cpp
mlir/tools/mlir-tblgen/OpFormatGen.cpp
mlir/tools/mlir-tblgen/RewriterGen.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
index 5c1bce77b9a5a..9b743158a39ff 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
@@ -1355,8 +1355,8 @@ namespace {
struct Conv1DNwcGenerator : public StructuredGenerator<LinalgOp> {
Conv1DNwcGenerator(OpBuilder &builder, LinalgOp linalgOp, int strideW,
int dilationW)
- : StructuredGenerator<LinalgOp>(builder, linalgOp), valid(false),
- strideW(strideW), dilationW(dilationW) {
+ : StructuredGenerator<LinalgOp>(builder, linalgOp), strideW(strideW),
+ dilationW(dilationW) {
// Determine whether `linalgOp` can be generated with this generator
if (linalgOp.getNumInputs() != 2 || linalgOp.getNumOutputs() != 1)
return;
@@ -1665,7 +1665,7 @@ struct Conv1DNwcGenerator : public StructuredGenerator<LinalgOp> {
}
private:
- bool valid;
+ bool valid = false;
int strideW, dilationW;
Value lhsShaped, rhsShaped, resShaped;
ShapedType lhsShapedType, rhsShapedType, resShapedType;
diff --git a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp
index 35138042867d2..431c1eb0be51e 100644
--- a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp
+++ b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp
@@ -57,7 +57,7 @@ namespace {
// `d0 + 2 * d1 + d3` is tiled by [0, 0, 0, 2] but not by [0, 0, 2, 0]
//
struct TileCheck : public AffineExprVisitor<TileCheck> {
- TileCheck(ValueRange tileSizes) : isTiled(false), tileSizes(tileSizes) {}
+ TileCheck(ValueRange tileSizes) : tileSizes(tileSizes) {}
void visitDimExpr(AffineDimExpr expr) {
isTiled |= !isZero(tileSizes[expr.getPosition()]);
@@ -69,7 +69,7 @@ struct TileCheck : public AffineExprVisitor<TileCheck> {
assert(expr.getRHS().cast<AffineConstantExpr>().getValue() > 0 &&
"nonpositive multiplying coefficient");
}
- bool isTiled;
+ bool isTiled = false;
ValueRange tileSizes;
};
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
index e7a0c2d16f661..6945e54a73a05 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
@@ -52,10 +52,9 @@ struct CodeGen {
indices(numTensors, std::vector<Value>(numLoops)),
highs(numTensors, std::vector<Value>(numLoops)),
pidxs(numTensors, std::vector<Value>(numLoops)),
- idxs(numTensors, std::vector<Value>(numLoops)), redExp(-1u), redVal(),
- redKind(kNoReduc), sparseOut(op), outerParNest(nest), lexIdx(),
- expValues(), expFilled(), expAdded(), expCount(), curVecLength(1),
- curVecMask() {}
+ idxs(numTensors, std::vector<Value>(numLoops)), redVal(), sparseOut(op),
+ outerParNest(nest), lexIdx(), expValues(), expFilled(), expAdded(),
+ expCount(), curVecMask() {}
/// Sparsification options.
SparsificationOptions options;
/// Universal dense indices and upper bounds (by index). The loops array
@@ -77,9 +76,9 @@ struct CodeGen {
std::vector<std::vector<Value>> idxs;
/// Current reduction, updated during code generation. When indices of a
/// reduction are exhausted, all inner loops can use a scalarized reduction.
- unsigned redExp;
+ unsigned redExp = -1u;
Value redVal;
- Reduction redKind;
+ Reduction redKind = kNoReduc;
// Sparse tensor as output. Implemented either through direct injective
// insertion in lexicographic index order (where indices are updated
// in the temporary array `lexIdx`) or through access pattern expansion
@@ -92,7 +91,7 @@ struct CodeGen {
Value expAdded;
Value expCount;
// Current vector length and mask.
- unsigned curVecLength;
+ unsigned curVecLength = 1;
Value curVecMask;
};
diff --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp
index d9459ee4dd8e0..ea0ff5aa74955 100644
--- a/mlir/lib/IR/Diagnostics.cpp
+++ b/mlir/lib/IR/Diagnostics.cpp
@@ -844,7 +844,7 @@ struct ParallelDiagnosticHandlerImpl : public llvm::PrettyStackTraceEntry {
Diagnostic diag;
};
- ParallelDiagnosticHandlerImpl(MLIRContext *ctx) : handlerID(0), context(ctx) {
+ ParallelDiagnosticHandlerImpl(MLIRContext *ctx) : context(ctx) {
handlerID = ctx->getDiagEngine().registerHandler([this](Diagnostic &diag) {
uint64_t tid = llvm::get_threadid();
llvm::sys::SmartScopedLock<true> lock(mutex);
@@ -942,7 +942,7 @@ struct ParallelDiagnosticHandlerImpl : public llvm::PrettyStackTraceEntry {
mutable std::vector<ThreadDiagnostic> diagnostics;
/// The unique id for the parallel handler.
- DiagnosticEngine::HandlerID handlerID;
+ DiagnosticEngine::HandlerID handlerID = 0;
/// The context to emit the diagnostics to.
MLIRContext *context;
diff --git a/mlir/lib/Parser/AffineParser.cpp b/mlir/lib/Parser/AffineParser.cpp
index 7d2dd692fc41d..57a2fc296d5fe 100644
--- a/mlir/lib/Parser/AffineParser.cpp
+++ b/mlir/lib/Parser/AffineParser.cpp
@@ -48,7 +48,7 @@ class AffineParser : public Parser {
AffineParser(ParserState &state, bool allowParsingSSAIds = false,
function_ref<ParseResult(bool)> parseElement = nullptr)
: Parser(state), allowParsingSSAIds(allowParsingSSAIds),
- parseElement(parseElement), numDimOperands(0), numSymbolOperands(0) {}
+ parseElement(parseElement) {}
AffineMap parseAffineMapRange(unsigned numDims, unsigned numSymbols);
ParseResult parseAffineMapOrIntegerSetInline(AffineMap &map, IntegerSet &set);
@@ -92,8 +92,8 @@ class AffineParser : public Parser {
private:
bool allowParsingSSAIds;
function_ref<ParseResult(bool)> parseElement;
- unsigned numDimOperands;
- unsigned numSymbolOperands;
+ unsigned numDimOperands = 0;
+ unsigned numSymbolOperands = 0;
SmallVector<std::pair<StringRef, AffineExpr>, 4> dimsAndSymbols;
};
} // namespace
diff --git a/mlir/lib/Pass/PassRegistry.cpp b/mlir/lib/Pass/PassRegistry.cpp
index 5e23b9c6ffe8d..b47f538bbeb01 100644
--- a/mlir/lib/Pass/PassRegistry.cpp
+++ b/mlir/lib/Pass/PassRegistry.cpp
@@ -326,11 +326,11 @@ class TextualPipeline {
/// the name is the name of a pass, the InnerPipeline is empty, since passes
/// cannot contain inner pipelines.
struct PipelineElement {
- PipelineElement(StringRef name) : name(name), registryEntry(nullptr) {}
+ PipelineElement(StringRef name) : name(name) {}
StringRef name;
StringRef options;
- const PassRegistryEntry *registryEntry;
+ const PassRegistryEntry *registryEntry = nullptr;
std::vector<PipelineElement> innerPipeline;
};
diff --git a/mlir/lib/Tools/PDLL/Parser/Parser.cpp b/mlir/lib/Tools/PDLL/Parser/Parser.cpp
index 3da77839c9cce..167aee27f8747 100644
--- a/mlir/lib/Tools/PDLL/Parser/Parser.cpp
+++ b/mlir/lib/Tools/PDLL/Parser/Parser.cpp
@@ -43,8 +43,7 @@ class Parser {
public:
Parser(ast::Context &ctx, llvm::SourceMgr &sourceMgr)
: ctx(ctx), lexer(sourceMgr, ctx.getDiagEngine()),
- curToken(lexer.lexToken()), curDeclScope(nullptr),
- valueTy(ast::ValueType::get(ctx)),
+ curToken(lexer.lexToken()), valueTy(ast::ValueType::get(ctx)),
valueRangeTy(ast::ValueRangeType::get(ctx)),
typeTy(ast::TypeType::get(ctx)),
typeRangeTy(ast::TypeRangeType::get(ctx)),
@@ -469,7 +468,7 @@ class Parser {
Token curToken;
/// The most recently defined decl scope.
- ast::DeclScope *curDeclScope;
+ ast::DeclScope *curDeclScope = nullptr;
llvm::SpecificBumpPtrAllocator<ast::DeclScope> scopeAllocator;
/// The current context of the parser.
diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
index 97cb5f1c8fc63..c13df3425223a 100644
--- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
+++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
@@ -716,7 +716,7 @@ class MLIRTextFile {
int64_t version;
/// The number of lines in the file.
- int64_t totalNumLines;
+ int64_t totalNumLines = 0;
/// The chunks of this file. The order of these chunks is the order in which
/// they appear in the text file.
@@ -728,7 +728,7 @@ MLIRTextFile::MLIRTextFile(const lsp::URIForFile &uri, StringRef fileContents,
int64_t version, DialectRegistry ®istry,
std::vector<lsp::Diagnostic> &diagnostics)
: context(registry, MLIRContext::Threading::DISABLED),
- contents(fileContents.str()), version(version), totalNumLines(0) {
+ contents(fileContents.str()), version(version) {
context.allowUnregisteredDialects();
// Split the file into separate MLIR documents.
diff --git a/mlir/lib/Transforms/CSE.cpp b/mlir/lib/Transforms/CSE.cpp
index 235abda14f0e8..0570c910eb082 100644
--- a/mlir/lib/Transforms/CSE.cpp
+++ b/mlir/lib/Transforms/CSE.cpp
@@ -63,8 +63,7 @@ struct CSE : public CSEBase<CSE> {
/// Represents a single entry in the depth first traversal of a CFG.
struct CFGStackNode {
CFGStackNode(ScopedMapTy &knownValues, DominanceInfoNode *node)
- : scope(knownValues), node(node), childIterator(node->begin()),
- processed(false) {}
+ : scope(knownValues), node(node), childIterator(node->begin()) {}
/// Scope for the known values.
ScopedMapTy::ScopeTy scope;
@@ -73,7 +72,7 @@ struct CSE : public CSEBase<CSE> {
DominanceInfoNode::const_iterator childIterator;
/// If this node has been fully processed yet or not.
- bool processed;
+ bool processed = false;
};
/// Attempt to eliminate a redundant operation. Returns success if the
diff --git a/mlir/lib/Transforms/Utils/ControlFlowSinkUtils.cpp b/mlir/lib/Transforms/Utils/ControlFlowSinkUtils.cpp
index 0101f9026dc71..34668fa682b62 100644
--- a/mlir/lib/Transforms/Utils/ControlFlowSinkUtils.cpp
+++ b/mlir/lib/Transforms/Utils/ControlFlowSinkUtils.cpp
@@ -35,8 +35,7 @@ class Sinker {
/// Create an operation sinker with given dominance info.
Sinker(function_ref<bool(Operation *, Region *)> shouldMoveIntoRegion,
DominanceInfo &domInfo)
- : shouldMoveIntoRegion(shouldMoveIntoRegion), domInfo(domInfo),
- numSunk(0) {}
+ : shouldMoveIntoRegion(shouldMoveIntoRegion), domInfo(domInfo) {}
/// Given a list of regions, find operations to sink and sink them. Return the
/// number of operations sunk.
@@ -65,7 +64,7 @@ class Sinker {
/// Dominance info to determine op user dominance with respect to regions.
DominanceInfo &domInfo;
/// The number of operations sunk.
- size_t numSunk;
+ size_t numSunk = 0;
};
} // end anonymous namespace
diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
index 37e62880b543c..c1a2007304e4c 100644
--- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
@@ -301,8 +301,8 @@ struct OperationFormat {
};
OperationFormat(const Operator &op)
- : allOperands(false), allOperandTypes(false), allResultTypes(false),
- infersResultTypes(false) {
+
+ {
operandTypes.resize(op.getNumOperands(), TypeResolution());
resultTypes.resize(op.getNumResults(), TypeResolution());
@@ -346,10 +346,10 @@ struct OperationFormat {
/// A flag indicating if all operand/result types were seen. If the format
/// contains these, it can not contain individual type resolvers.
- bool allOperands, allOperandTypes, allResultTypes;
+ bool allOperands = false, allOperandTypes = false, allResultTypes = false;
/// A flag indicating if this operation infers its result types
- bool infersResultTypes;
+ bool infersResultTypes = false;
/// A flag indicating if this operation has the SingleBlockImplicitTerminator
/// trait.
diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp
index 9310810e86633..0159328d6453a 100644
--- a/mlir/tools/mlir-tblgen/RewriterGen.cpp
+++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp
@@ -243,7 +243,7 @@ class PatternEmitter {
StaticMatcherHelper &staticMatcherHelper;
// The next unused ID for newly created values.
- unsigned nextValueId;
+ unsigned nextValueId = 0;
raw_indented_ostream os;
@@ -333,8 +333,7 @@ class StaticMatcherHelper {
PatternEmitter::PatternEmitter(Record *pat, RecordOperatorMap *mapper,
raw_ostream &os, StaticMatcherHelper &helper)
: loc(pat->getLoc()), opMap(mapper), pattern(pat, mapper),
- symbolInfoMap(pat->getLoc()), staticMatcherHelper(helper), nextValueId(0),
- os(os) {
+ symbolInfoMap(pat->getLoc()), staticMatcherHelper(helper), os(os) {
fmtCtx.withBuilder("rewriter");
}
More information about the Mlir-commits
mailing list