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

This commit is contained in:
Mehdi Amini 2022-01-14 01:35:30 +00:00
parent d19f89b5d2
commit 59d8740f2f
16 changed files with 42 additions and 46 deletions

View File

@ -25,7 +25,7 @@ namespace mlir {
/// representable by 64-bit integers.
struct Fraction {
/// Default constructor initializes the represented rational number to zero.
Fraction() : num(0), den(1) {}
Fraction() {}
/// Construct a Fraction from a numerator and denominator.
Fraction(int64_t oNum, int64_t oDen) : num(oNum), den(oDen) {
@ -37,7 +37,7 @@ struct Fraction {
/// The numerator and denominator, respectively. The denominator is always
/// positive.
int64_t num, den;
int64_t num{0}, den{1};
};
/// Three-way comparison between two fractions.

View File

@ -21,9 +21,7 @@ class OperationPass;
/// This should kept in sync with VectorToLLVM options defined for the
/// ConvertVectorToLLVM pass in include/mlir/Conversion/Passes.td
struct LowerVectorToLLVMOptions {
LowerVectorToLLVMOptions()
: reassociateFPReductions(false), indexOptimizations(true),
armNeon(false), armSVE(false), amx(false), x86Vector(false) {}
LowerVectorToLLVMOptions() {}
LowerVectorToLLVMOptions &enableReassociateFPReductions(bool b = true) {
reassociateFPReductions = b;
@ -50,12 +48,12 @@ struct LowerVectorToLLVMOptions {
return *this;
}
bool reassociateFPReductions;
bool indexOptimizations;
bool armNeon;
bool armSVE;
bool amx;
bool x86Vector;
bool reassociateFPReductions{false};
bool indexOptimizations{true};
bool armNeon{false};
bool armSVE{false};
bool amx{false};
bool x86Vector{false};
};
/// Collect a set of patterns to convert from Vector contractions to LLVM Matrix

View File

@ -47,20 +47,20 @@ public:
///
/// If the original scalar type has less than 32-bit, a multiple of its
/// values will be packed into one 32-bit value to be memory efficient.
bool emulateNon32BitScalarTypes;
bool emulateNon32BitScalarTypes{true};
/// Use 64-bit integers to convert index types.
bool use64bitIndex;
bool use64bitIndex{false};
/// The number of bits to store a boolean value. It is eight bits by
/// default.
unsigned boolNumBits;
unsigned boolNumBits{8};
// Note: we need this instead of inline initializers because of
// https://bugs.llvm.org/show_bug.cgi?id=36684
Options()
: emulateNon32BitScalarTypes(true), use64bitIndex(false),
boolNumBits(8) {}
{}
};
explicit SPIRVTypeConverter(spirv::TargetEnvAttr targetAttr,

View File

@ -69,7 +69,7 @@ class AffineExpr {
public:
using ImplType = detail::AffineExprStorage;
constexpr AffineExpr() : expr(nullptr) {}
constexpr AffineExpr() {}
/* implicit */ AffineExpr(const ImplType *expr)
: expr(const_cast<ImplType *>(expr)) {}
@ -195,7 +195,7 @@ public:
}
protected:
ImplType *expr;
ImplType *expr{nullptr};
};
/// Affine binary operation expression. An affine binary operation could be an

View File

@ -39,7 +39,7 @@ class AffineMap {
public:
using ImplType = detail::AffineMapStorage;
constexpr AffineMap() : map(nullptr) {}
constexpr AffineMap() {}
explicit AffineMap(ImplType *map) : map(map) {}
/// Returns a zero result affine map with no dimensions or symbols: () -> ().
@ -309,7 +309,7 @@ public:
}
private:
ImplType *map;
ImplType *map{nullptr};
static AffineMap getImpl(unsigned dimCount, unsigned symbolCount,
ArrayRef<AffineExpr> results, MLIRContext *context);

View File

@ -33,7 +33,7 @@ public:
using ValueType = void;
using AbstractTy = AbstractAttribute;
constexpr Attribute() : impl(nullptr) {}
constexpr Attribute() {}
/* implicit */ Attribute(const ImplType *impl)
: impl(const_cast<ImplType *>(impl)) {}
@ -96,7 +96,7 @@ public:
}
protected:
ImplType *impl;
ImplType *impl{nullptr};
};
inline raw_ostream &operator<<(raw_ostream &os, Attribute attr) {

View File

@ -45,7 +45,7 @@ class IntegerSet {
public:
using ImplType = detail::IntegerSetStorage;
constexpr IntegerSet() : set(nullptr) {}
constexpr IntegerSet() {}
explicit IntegerSet(ImplType *set) : set(set) {}
static IntegerSet get(unsigned dimCount, unsigned symbolCount,
@ -116,7 +116,7 @@ public:
}
private:
ImplType *set;
ImplType *set{nullptr};
};
// Make AffineExpr hashable.

View File

@ -126,7 +126,7 @@ public:
protected:
/// Initialize the printer with no internal implementation. In this case, all
/// virtual methods of this class must be overriden.
AsmPrinter() : impl(nullptr) {}
AsmPrinter() {}
private:
AsmPrinter(const AsmPrinter &) = delete;
@ -141,7 +141,7 @@ private:
virtual LogicalResult printAlias(Type type);
/// The internal implementation of the printer.
Impl *impl;
Impl *impl{nullptr};
};
template <typename AsmPrinterT>

View File

@ -33,7 +33,7 @@ class PatternBenefit {
enum { ImpossibleToMatchSentinel = 65535 };
public:
PatternBenefit() : representation(ImpossibleToMatchSentinel) {}
PatternBenefit() {}
PatternBenefit(unsigned benefit);
PatternBenefit(const PatternBenefit &) = default;
PatternBenefit &operator=(const PatternBenefit &) = default;
@ -57,7 +57,7 @@ public:
bool operator>=(const PatternBenefit &rhs) const { return !(*this < rhs); }
private:
unsigned short representation;
unsigned short representation{ImpossibleToMatchSentinel};
};
//===----------------------------------------------------------------------===//
@ -402,7 +402,7 @@ public:
/// Construct a new PDL value.
PDLValue(const PDLValue &other) = default;
PDLValue(std::nullptr_t = nullptr) : value(nullptr), kind(Kind::Attribute) {}
PDLValue(std::nullptr_t = nullptr) {}
PDLValue(Attribute value)
: value(value.getAsOpaquePointer()), kind(Kind::Attribute) {}
PDLValue(Operation *value) : value(value), kind(Kind::Operation) {}
@ -486,9 +486,9 @@ private:
}
/// The internal opaque representation of a PDLValue.
const void *value;
const void *value{nullptr};
/// The kind of the opaque value.
Kind kind;
Kind kind{Kind::Attribute};
};
inline raw_ostream &operator<<(raw_ostream &os, PDLValue value) {

View File

@ -131,7 +131,7 @@ public:
protected:
/// This constructor is used by derived classes as part of the TypeUniquer.
TypeStorage() : abstractType(nullptr) {}
TypeStorage() {}
private:
/// Set the abstract type for this storage instance. This is used by the
@ -141,7 +141,7 @@ private:
}
/// The abstract description for this type.
AbstractType *abstractType;
AbstractType *abstractType{nullptr};
};
/// Default storage type for types that require no additional initialization or

View File

@ -81,7 +81,7 @@ public:
using AbstractTy = AbstractType;
constexpr Type() : impl(nullptr) {}
constexpr Type() {}
/* implicit */ Type(const ImplType *impl)
: impl(const_cast<ImplType *>(impl)) {}
@ -179,7 +179,7 @@ public:
const AbstractTy &getAbstractType() { return impl->getAbstractType(); }
protected:
ImplType *impl;
ImplType *impl{nullptr};
};
inline raw_ostream &operator<<(raw_ostream &os, Type type) {

View File

@ -68,8 +68,7 @@ public:
: region(region), inputs(regionInputs) {}
/// Initialize a successor that branches back to/out of the parent operation.
RegionSuccessor(Optional<Operation::result_range> results = {})
: region(nullptr), inputs(results ? ValueRange(*results) : ValueRange()) {
}
: inputs(results ? ValueRange(*results) : ValueRange()) {}
/// Return the given region successor. Returns nullptr if the successor is the
/// parent operation.
@ -83,7 +82,7 @@ public:
ValueRange getSuccessorInputs() const { return inputs; }
private:
Region *region;
Region *region{nullptr};
ValueRange inputs;
};

View File

@ -41,7 +41,7 @@ class ShapedTypeComponents {
public:
/// Default construction is an unranked shape.
ShapedTypeComponents() : elementType(nullptr), attr(nullptr), ranked(false){};
ShapedTypeComponents() : elementType(nullptr), attr(nullptr){};
ShapedTypeComponents(Type elementType)
: elementType(elementType), attr(nullptr), ranked(false) {}
ShapedTypeComponents(ShapedType shapedType) : attr(nullptr) {
@ -83,7 +83,7 @@ private:
ShapeStorageT dims;
Type elementType;
Attribute attr;
bool ranked;
bool ranked{false};
};
/// Adaptor class to abstract the differences between whether value is from

View File

@ -54,11 +54,10 @@ private:
/// This struct represents a specific counter being tracked.
struct Counter {
Counter(int64_t countToSkip = 0, int64_t countToStopAfter = -1)
: count(0), countToSkip(countToSkip),
countToStopAfter(countToStopAfter) {}
: countToSkip(countToSkip), countToStopAfter(countToStopAfter) {}
/// The current count of this counter.
int64_t count;
int64_t count{0};
/// The number of initial executions of this counter to skip.
int64_t countToSkip;
/// The number of times to execute this counter before stopping.

View File

@ -34,7 +34,7 @@ namespace tblgen {
class Pred {
public:
// Constructs the null Predicate (e.g., always true).
explicit Pred() : def(nullptr) {}
explicit Pred() {}
// Construct a Predicate from a record.
explicit Pred(const llvm::Record *record);
// Construct a Predicate from an initializer.
@ -69,7 +69,7 @@ public:
protected:
// The TableGen definition of this predicate.
const llvm::Record *def;
const llvm::Record *def{nullptr};
};
// A logical predicate wrapping a C expression. This class must closely follow

View File

@ -28,7 +28,7 @@ Pred::Pred(const llvm::Record *record) : def(record) {
}
// Construct a Predicate from an initializer.
Pred::Pred(const llvm::Init *init) : def(nullptr) {
Pred::Pred(const llvm::Init *init) {
if (const auto *defInit = dyn_cast_or_null<llvm::DefInit>(init))
def = defInit->getDef();
}