Apply clang-tidy fixes for modernize-use-default-member-init to MLIR (NFC)

This commit is contained in:
Mehdi Amini 2022-03-07 10:12:43 +00:00
parent e6e36b9c20
commit 671e30a12f
12 changed files with 32 additions and 37 deletions

View File

@ -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;

View File

@ -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;
};

View File

@ -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;
};

View File

@ -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;

View File

@ -48,7 +48,7 @@ public:
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 @@ private:
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

View File

@ -326,11 +326,11 @@ private:
/// 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;
};

View File

@ -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 @@ private:
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.

View File

@ -716,7 +716,7 @@ private:
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 &registry,
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.

View File

@ -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

View File

@ -35,8 +35,7 @@ public:
/// 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 @@ private:
/// 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

View File

@ -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.

View File

@ -243,7 +243,7 @@ private:
StaticMatcherHelper &staticMatcherHelper;
// The next unused ID for newly created values.
unsigned nextValueId;
unsigned nextValueId = 0;
raw_indented_ostream os;
@ -333,8 +333,7 @@ private:
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");
}