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. /// representable by 64-bit integers.
struct Fraction { struct Fraction {
/// Default constructor initializes the represented rational number to zero. /// Default constructor initializes the represented rational number to zero.
Fraction() : num(0), den(1) {} Fraction() {}
/// Construct a Fraction from a numerator and denominator. /// Construct a Fraction from a numerator and denominator.
Fraction(int64_t oNum, int64_t oDen) : num(oNum), den(oDen) { 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 /// The numerator and denominator, respectively. The denominator is always
/// positive. /// positive.
int64_t num, den; int64_t num{0}, den{1};
}; };
/// Three-way comparison between two fractions. /// 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 /// This should kept in sync with VectorToLLVM options defined for the
/// ConvertVectorToLLVM pass in include/mlir/Conversion/Passes.td /// ConvertVectorToLLVM pass in include/mlir/Conversion/Passes.td
struct LowerVectorToLLVMOptions { struct LowerVectorToLLVMOptions {
LowerVectorToLLVMOptions() LowerVectorToLLVMOptions() {}
: reassociateFPReductions(false), indexOptimizations(true),
armNeon(false), armSVE(false), amx(false), x86Vector(false) {}
LowerVectorToLLVMOptions &enableReassociateFPReductions(bool b = true) { LowerVectorToLLVMOptions &enableReassociateFPReductions(bool b = true) {
reassociateFPReductions = b; reassociateFPReductions = b;
@ -50,12 +48,12 @@ struct LowerVectorToLLVMOptions {
return *this; return *this;
} }
bool reassociateFPReductions; bool reassociateFPReductions{false};
bool indexOptimizations; bool indexOptimizations{true};
bool armNeon; bool armNeon{false};
bool armSVE; bool armSVE{false};
bool amx; bool amx{false};
bool x86Vector; bool x86Vector{false};
}; };
/// Collect a set of patterns to convert from Vector contractions to LLVM Matrix /// 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 /// 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. /// 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. /// 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 /// The number of bits to store a boolean value. It is eight bits by
/// default. /// default.
unsigned boolNumBits; unsigned boolNumBits{8};
// Note: we need this instead of inline initializers because of // Note: we need this instead of inline initializers because of
// https://bugs.llvm.org/show_bug.cgi?id=36684 // https://bugs.llvm.org/show_bug.cgi?id=36684
Options() Options()
: emulateNon32BitScalarTypes(true), use64bitIndex(false),
boolNumBits(8) {} {}
}; };
explicit SPIRVTypeConverter(spirv::TargetEnvAttr targetAttr, explicit SPIRVTypeConverter(spirv::TargetEnvAttr targetAttr,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -41,7 +41,7 @@ class ShapedTypeComponents {
public: public:
/// Default construction is an unranked shape. /// Default construction is an unranked shape.
ShapedTypeComponents() : elementType(nullptr), attr(nullptr), ranked(false){}; ShapedTypeComponents() : elementType(nullptr), attr(nullptr){};
ShapedTypeComponents(Type elementType) ShapedTypeComponents(Type elementType)
: elementType(elementType), attr(nullptr), ranked(false) {} : elementType(elementType), attr(nullptr), ranked(false) {}
ShapedTypeComponents(ShapedType shapedType) : attr(nullptr) { ShapedTypeComponents(ShapedType shapedType) : attr(nullptr) {
@ -83,7 +83,7 @@ private:
ShapeStorageT dims; ShapeStorageT dims;
Type elementType; Type elementType;
Attribute attr; Attribute attr;
bool ranked; bool ranked{false};
}; };
/// Adaptor class to abstract the differences between whether value is from /// 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. /// This struct represents a specific counter being tracked.
struct Counter { struct Counter {
Counter(int64_t countToSkip = 0, int64_t countToStopAfter = -1) Counter(int64_t countToSkip = 0, int64_t countToStopAfter = -1)
: count(0), countToSkip(countToSkip), : countToSkip(countToSkip), countToStopAfter(countToStopAfter) {}
countToStopAfter(countToStopAfter) {}
/// The current count of this counter. /// The current count of this counter.
int64_t count; int64_t count{0};
/// The number of initial executions of this counter to skip. /// The number of initial executions of this counter to skip.
int64_t countToSkip; int64_t countToSkip;
/// The number of times to execute this counter before stopping. /// The number of times to execute this counter before stopping.

View File

@ -34,7 +34,7 @@ namespace tblgen {
class Pred { class Pred {
public: public:
// Constructs the null Predicate (e.g., always true). // Constructs the null Predicate (e.g., always true).
explicit Pred() : def(nullptr) {} explicit Pred() {}
// Construct a Predicate from a record. // Construct a Predicate from a record.
explicit Pred(const llvm::Record *record); explicit Pred(const llvm::Record *record);
// Construct a Predicate from an initializer. // Construct a Predicate from an initializer.
@ -69,7 +69,7 @@ public:
protected: protected:
// The TableGen definition of this predicate. // 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 // 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. // 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)) if (const auto *defInit = dyn_cast_or_null<llvm::DefInit>(init))
def = defInit->getDef(); def = defInit->getDef();
} }