Skip to content

Commit 671e30a

Browse files
committed
Apply clang-tidy fixes for modernize-use-default-member-init to MLIR (NFC)
1 parent e6e36b9 commit 671e30a

File tree

12 files changed

+32
-37
lines changed

12 files changed

+32
-37
lines changed

mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,8 +1355,8 @@ namespace {
13551355
struct Conv1DNwcGenerator : public StructuredGenerator<LinalgOp> {
13561356
Conv1DNwcGenerator(OpBuilder &builder, LinalgOp linalgOp, int strideW,
13571357
int dilationW)
1358-
: StructuredGenerator<LinalgOp>(builder, linalgOp), valid(false),
1359-
strideW(strideW), dilationW(dilationW) {
1358+
: StructuredGenerator<LinalgOp>(builder, linalgOp), strideW(strideW),
1359+
dilationW(dilationW) {
13601360
// Determine whether `linalgOp` can be generated with this generator
13611361
if (linalgOp.getNumInputs() != 2 || linalgOp.getNumOutputs() != 1)
13621362
return;
@@ -1665,7 +1665,7 @@ struct Conv1DNwcGenerator : public StructuredGenerator<LinalgOp> {
16651665
}
16661666

16671667
private:
1668-
bool valid;
1668+
bool valid = false;
16691669
int strideW, dilationW;
16701670
Value lhsShaped, rhsShaped, resShaped;
16711671
ShapedType lhsShapedType, rhsShapedType, resShapedType;

mlir/lib/Dialect/Linalg/Utils/Utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace {
5757
// `d0 + 2 * d1 + d3` is tiled by [0, 0, 0, 2] but not by [0, 0, 2, 0]
5858
//
5959
struct TileCheck : public AffineExprVisitor<TileCheck> {
60-
TileCheck(ValueRange tileSizes) : isTiled(false), tileSizes(tileSizes) {}
60+
TileCheck(ValueRange tileSizes) : tileSizes(tileSizes) {}
6161

6262
void visitDimExpr(AffineDimExpr expr) {
6363
isTiled |= !isZero(tileSizes[expr.getPosition()]);
@@ -69,7 +69,7 @@ struct TileCheck : public AffineExprVisitor<TileCheck> {
6969
assert(expr.getRHS().cast<AffineConstantExpr>().getValue() > 0 &&
7070
"nonpositive multiplying coefficient");
7171
}
72-
bool isTiled;
72+
bool isTiled = false;
7373
ValueRange tileSizes;
7474
};
7575

mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@ struct CodeGen {
5252
indices(numTensors, std::vector<Value>(numLoops)),
5353
highs(numTensors, std::vector<Value>(numLoops)),
5454
pidxs(numTensors, std::vector<Value>(numLoops)),
55-
idxs(numTensors, std::vector<Value>(numLoops)), redExp(-1u), redVal(),
56-
redKind(kNoReduc), sparseOut(op), outerParNest(nest), lexIdx(),
57-
expValues(), expFilled(), expAdded(), expCount(), curVecLength(1),
58-
curVecMask() {}
55+
idxs(numTensors, std::vector<Value>(numLoops)), redVal(), sparseOut(op),
56+
outerParNest(nest), lexIdx(), expValues(), expFilled(), expAdded(),
57+
expCount(), curVecMask() {}
5958
/// Sparsification options.
6059
SparsificationOptions options;
6160
/// Universal dense indices and upper bounds (by index). The loops array
@@ -77,9 +76,9 @@ struct CodeGen {
7776
std::vector<std::vector<Value>> idxs;
7877
/// Current reduction, updated during code generation. When indices of a
7978
/// reduction are exhausted, all inner loops can use a scalarized reduction.
80-
unsigned redExp;
79+
unsigned redExp = -1u;
8180
Value redVal;
82-
Reduction redKind;
81+
Reduction redKind = kNoReduc;
8382
// Sparse tensor as output. Implemented either through direct injective
8483
// insertion in lexicographic index order (where indices are updated
8584
// in the temporary array `lexIdx`) or through access pattern expansion
@@ -92,7 +91,7 @@ struct CodeGen {
9291
Value expAdded;
9392
Value expCount;
9493
// Current vector length and mask.
95-
unsigned curVecLength;
94+
unsigned curVecLength = 1;
9695
Value curVecMask;
9796
};
9897

mlir/lib/IR/Diagnostics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ struct ParallelDiagnosticHandlerImpl : public llvm::PrettyStackTraceEntry {
844844
Diagnostic diag;
845845
};
846846

847-
ParallelDiagnosticHandlerImpl(MLIRContext *ctx) : handlerID(0), context(ctx) {
847+
ParallelDiagnosticHandlerImpl(MLIRContext *ctx) : context(ctx) {
848848
handlerID = ctx->getDiagEngine().registerHandler([this](Diagnostic &diag) {
849849
uint64_t tid = llvm::get_threadid();
850850
llvm::sys::SmartScopedLock<true> lock(mutex);
@@ -942,7 +942,7 @@ struct ParallelDiagnosticHandlerImpl : public llvm::PrettyStackTraceEntry {
942942
mutable std::vector<ThreadDiagnostic> diagnostics;
943943

944944
/// The unique id for the parallel handler.
945-
DiagnosticEngine::HandlerID handlerID;
945+
DiagnosticEngine::HandlerID handlerID = 0;
946946

947947
/// The context to emit the diagnostics to.
948948
MLIRContext *context;

mlir/lib/Parser/AffineParser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class AffineParser : public Parser {
4848
AffineParser(ParserState &state, bool allowParsingSSAIds = false,
4949
function_ref<ParseResult(bool)> parseElement = nullptr)
5050
: Parser(state), allowParsingSSAIds(allowParsingSSAIds),
51-
parseElement(parseElement), numDimOperands(0), numSymbolOperands(0) {}
51+
parseElement(parseElement) {}
5252

5353
AffineMap parseAffineMapRange(unsigned numDims, unsigned numSymbols);
5454
ParseResult parseAffineMapOrIntegerSetInline(AffineMap &map, IntegerSet &set);
@@ -92,8 +92,8 @@ class AffineParser : public Parser {
9292
private:
9393
bool allowParsingSSAIds;
9494
function_ref<ParseResult(bool)> parseElement;
95-
unsigned numDimOperands;
96-
unsigned numSymbolOperands;
95+
unsigned numDimOperands = 0;
96+
unsigned numSymbolOperands = 0;
9797
SmallVector<std::pair<StringRef, AffineExpr>, 4> dimsAndSymbols;
9898
};
9999
} // namespace

mlir/lib/Pass/PassRegistry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,11 @@ class TextualPipeline {
326326
/// the name is the name of a pass, the InnerPipeline is empty, since passes
327327
/// cannot contain inner pipelines.
328328
struct PipelineElement {
329-
PipelineElement(StringRef name) : name(name), registryEntry(nullptr) {}
329+
PipelineElement(StringRef name) : name(name) {}
330330

331331
StringRef name;
332332
StringRef options;
333-
const PassRegistryEntry *registryEntry;
333+
const PassRegistryEntry *registryEntry = nullptr;
334334
std::vector<PipelineElement> innerPipeline;
335335
};
336336

mlir/lib/Tools/PDLL/Parser/Parser.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ class Parser {
4343
public:
4444
Parser(ast::Context &ctx, llvm::SourceMgr &sourceMgr)
4545
: ctx(ctx), lexer(sourceMgr, ctx.getDiagEngine()),
46-
curToken(lexer.lexToken()), curDeclScope(nullptr),
47-
valueTy(ast::ValueType::get(ctx)),
46+
curToken(lexer.lexToken()), valueTy(ast::ValueType::get(ctx)),
4847
valueRangeTy(ast::ValueRangeType::get(ctx)),
4948
typeTy(ast::TypeType::get(ctx)),
5049
typeRangeTy(ast::TypeRangeType::get(ctx)),
@@ -469,7 +468,7 @@ class Parser {
469468
Token curToken;
470469

471470
/// The most recently defined decl scope.
472-
ast::DeclScope *curDeclScope;
471+
ast::DeclScope *curDeclScope = nullptr;
473472
llvm::SpecificBumpPtrAllocator<ast::DeclScope> scopeAllocator;
474473

475474
/// The current context of the parser.

mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ class MLIRTextFile {
716716
int64_t version;
717717

718718
/// The number of lines in the file.
719-
int64_t totalNumLines;
719+
int64_t totalNumLines = 0;
720720

721721
/// The chunks of this file. The order of these chunks is the order in which
722722
/// they appear in the text file.
@@ -728,7 +728,7 @@ MLIRTextFile::MLIRTextFile(const lsp::URIForFile &uri, StringRef fileContents,
728728
int64_t version, DialectRegistry &registry,
729729
std::vector<lsp::Diagnostic> &diagnostics)
730730
: context(registry, MLIRContext::Threading::DISABLED),
731-
contents(fileContents.str()), version(version), totalNumLines(0) {
731+
contents(fileContents.str()), version(version) {
732732
context.allowUnregisteredDialects();
733733

734734
// Split the file into separate MLIR documents.

mlir/lib/Transforms/CSE.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ struct CSE : public CSEBase<CSE> {
6363
/// Represents a single entry in the depth first traversal of a CFG.
6464
struct CFGStackNode {
6565
CFGStackNode(ScopedMapTy &knownValues, DominanceInfoNode *node)
66-
: scope(knownValues), node(node), childIterator(node->begin()),
67-
processed(false) {}
66+
: scope(knownValues), node(node), childIterator(node->begin()) {}
6867

6968
/// Scope for the known values.
7069
ScopedMapTy::ScopeTy scope;
@@ -73,7 +72,7 @@ struct CSE : public CSEBase<CSE> {
7372
DominanceInfoNode::const_iterator childIterator;
7473

7574
/// If this node has been fully processed yet or not.
76-
bool processed;
75+
bool processed = false;
7776
};
7877

7978
/// Attempt to eliminate a redundant operation. Returns success if the

mlir/lib/Transforms/Utils/ControlFlowSinkUtils.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ class Sinker {
3535
/// Create an operation sinker with given dominance info.
3636
Sinker(function_ref<bool(Operation *, Region *)> shouldMoveIntoRegion,
3737
DominanceInfo &domInfo)
38-
: shouldMoveIntoRegion(shouldMoveIntoRegion), domInfo(domInfo),
39-
numSunk(0) {}
38+
: shouldMoveIntoRegion(shouldMoveIntoRegion), domInfo(domInfo) {}
4039

4140
/// Given a list of regions, find operations to sink and sink them. Return the
4241
/// number of operations sunk.
@@ -65,7 +64,7 @@ class Sinker {
6564
/// Dominance info to determine op user dominance with respect to regions.
6665
DominanceInfo &domInfo;
6766
/// The number of operations sunk.
68-
size_t numSunk;
67+
size_t numSunk = 0;
6968
};
7069
} // end anonymous namespace
7170

mlir/tools/mlir-tblgen/OpFormatGen.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ struct OperationFormat {
301301
};
302302

303303
OperationFormat(const Operator &op)
304-
: allOperands(false), allOperandTypes(false), allResultTypes(false),
305-
infersResultTypes(false) {
304+
305+
{
306306
operandTypes.resize(op.getNumOperands(), TypeResolution());
307307
resultTypes.resize(op.getNumResults(), TypeResolution());
308308

@@ -346,10 +346,10 @@ struct OperationFormat {
346346

347347
/// A flag indicating if all operand/result types were seen. If the format
348348
/// contains these, it can not contain individual type resolvers.
349-
bool allOperands, allOperandTypes, allResultTypes;
349+
bool allOperands = false, allOperandTypes = false, allResultTypes = false;
350350

351351
/// A flag indicating if this operation infers its result types
352-
bool infersResultTypes;
352+
bool infersResultTypes = false;
353353

354354
/// A flag indicating if this operation has the SingleBlockImplicitTerminator
355355
/// trait.

mlir/tools/mlir-tblgen/RewriterGen.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class PatternEmitter {
243243
StaticMatcherHelper &staticMatcherHelper;
244244

245245
// The next unused ID for newly created values.
246-
unsigned nextValueId;
246+
unsigned nextValueId = 0;
247247

248248
raw_indented_ostream os;
249249

@@ -333,8 +333,7 @@ class StaticMatcherHelper {
333333
PatternEmitter::PatternEmitter(Record *pat, RecordOperatorMap *mapper,
334334
raw_ostream &os, StaticMatcherHelper &helper)
335335
: loc(pat->getLoc()), opMap(mapper), pattern(pat, mapper),
336-
symbolInfoMap(pat->getLoc()), staticMatcherHelper(helper), nextValueId(0),
337-
os(os) {
336+
symbolInfoMap(pat->getLoc()), staticMatcherHelper(helper), os(os) {
338337
fmtCtx.withBuilder("rewriter");
339338
}
340339

0 commit comments

Comments
 (0)