[Mlir-commits] [mlir] 59d8740 - Apply clang-tidy fixes for modernize-use-default-member-init to MLIR (NFC)
Mehdi Amini
llvmlistbot at llvm.org
Thu Jan 13 18:27:56 PST 2022
Author: Mehdi Amini
Date: 2022-01-14T02:26:26Z
New Revision: 59d8740f2f76cdec36cf62052db8ef5324e05b3d
URL: https://github.com/llvm/llvm-project/commit/59d8740f2f76cdec36cf62052db8ef5324e05b3d
DIFF: https://github.com/llvm/llvm-project/commit/59d8740f2f76cdec36cf62052db8ef5324e05b3d.diff
LOG: Apply clang-tidy fixes for modernize-use-default-member-init to MLIR (NFC)
Added:
Modified:
mlir/include/mlir/Analysis/Presburger/Fraction.h
mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
mlir/include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h
mlir/include/mlir/IR/AffineExpr.h
mlir/include/mlir/IR/AffineMap.h
mlir/include/mlir/IR/Attributes.h
mlir/include/mlir/IR/IntegerSet.h
mlir/include/mlir/IR/OpImplementation.h
mlir/include/mlir/IR/PatternMatch.h
mlir/include/mlir/IR/TypeSupport.h
mlir/include/mlir/IR/Types.h
mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
mlir/include/mlir/Interfaces/InferTypeOpInterface.h
mlir/include/mlir/Support/DebugCounter.h
mlir/include/mlir/TableGen/Predicate.h
mlir/lib/TableGen/Predicate.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Analysis/Presburger/Fraction.h b/mlir/include/mlir/Analysis/Presburger/Fraction.h
index 61b0915e559ec..0f8ee6e01636b 100644
--- a/mlir/include/mlir/Analysis/Presburger/Fraction.h
+++ b/mlir/include/mlir/Analysis/Presburger/Fraction.h
@@ -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.
diff --git a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
index 84ca14fab48a7..92323b0a82a1e 100644
--- a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
+++ b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
@@ -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
diff --git a/mlir/include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h b/mlir/include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h
index 0a1c9696fc11b..2eede784c208a 100644
--- a/mlir/include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h
+++ b/mlir/include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h
@@ -47,20 +47,20 @@ class SPIRVTypeConverter : public TypeConverter {
///
/// 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,
diff --git a/mlir/include/mlir/IR/AffineExpr.h b/mlir/include/mlir/IR/AffineExpr.h
index 5ede7c7d123a3..962797824d95b 100644
--- a/mlir/include/mlir/IR/AffineExpr.h
+++ b/mlir/include/mlir/IR/AffineExpr.h
@@ -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 @@ class AffineExpr {
}
protected:
- ImplType *expr;
+ ImplType *expr{nullptr};
};
/// Affine binary operation expression. An affine binary operation could be an
diff --git a/mlir/include/mlir/IR/AffineMap.h b/mlir/include/mlir/IR/AffineMap.h
index fb923b5970b85..9322db10c1ce4 100644
--- a/mlir/include/mlir/IR/AffineMap.h
+++ b/mlir/include/mlir/IR/AffineMap.h
@@ -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 @@ class AffineMap {
}
private:
- ImplType *map;
+ ImplType *map{nullptr};
static AffineMap getImpl(unsigned dimCount, unsigned symbolCount,
ArrayRef<AffineExpr> results, MLIRContext *context);
diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h
index 739493486258d..9eeb5b6d08e61 100644
--- a/mlir/include/mlir/IR/Attributes.h
+++ b/mlir/include/mlir/IR/Attributes.h
@@ -33,7 +33,7 @@ class Attribute {
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 @@ class Attribute {
}
protected:
- ImplType *impl;
+ ImplType *impl{nullptr};
};
inline raw_ostream &operator<<(raw_ostream &os, Attribute attr) {
diff --git a/mlir/include/mlir/IR/IntegerSet.h b/mlir/include/mlir/IR/IntegerSet.h
index 8e61fdb78a34d..5d6aaea2388df 100644
--- a/mlir/include/mlir/IR/IntegerSet.h
+++ b/mlir/include/mlir/IR/IntegerSet.h
@@ -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 @@ class IntegerSet {
}
private:
- ImplType *set;
+ ImplType *set{nullptr};
};
// Make AffineExpr hashable.
diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h
index 2cd09abb1dc24..accaa5fb46d33 100644
--- a/mlir/include/mlir/IR/OpImplementation.h
+++ b/mlir/include/mlir/IR/OpImplementation.h
@@ -126,7 +126,7 @@ class AsmPrinter {
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 @@ class AsmPrinter {
virtual LogicalResult printAlias(Type type);
/// The internal implementation of the printer.
- Impl *impl;
+ Impl *impl{nullptr};
};
template <typename AsmPrinterT>
diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h
index 5b822201d4111..aacc411c7ca76 100644
--- a/mlir/include/mlir/IR/PatternMatch.h
+++ b/mlir/include/mlir/IR/PatternMatch.h
@@ -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 @@ class PatternBenefit {
bool operator>=(const PatternBenefit &rhs) const { return !(*this < rhs); }
private:
- unsigned short representation;
+ unsigned short representation{ImpossibleToMatchSentinel};
};
//===----------------------------------------------------------------------===//
@@ -402,7 +402,7 @@ class PDLValue {
/// 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 @@ class PDLValue {
}
/// 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) {
diff --git a/mlir/include/mlir/IR/TypeSupport.h b/mlir/include/mlir/IR/TypeSupport.h
index 2541e13c07630..6f9327003ad86 100644
--- a/mlir/include/mlir/IR/TypeSupport.h
+++ b/mlir/include/mlir/IR/TypeSupport.h
@@ -131,7 +131,7 @@ class TypeStorage : public StorageUniquer::BaseStorage {
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 @@ class TypeStorage : public StorageUniquer::BaseStorage {
}
/// The abstract description for this type.
- AbstractType *abstractType;
+ AbstractType *abstractType{nullptr};
};
/// Default storage type for types that require no additional initialization or
diff --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h
index 35135d6ca2ab6..430ed0d2215df 100644
--- a/mlir/include/mlir/IR/Types.h
+++ b/mlir/include/mlir/IR/Types.h
@@ -81,7 +81,7 @@ class Type {
using AbstractTy = AbstractType;
- constexpr Type() : impl(nullptr) {}
+ constexpr Type() {}
/* implicit */ Type(const ImplType *impl)
: impl(const_cast<ImplType *>(impl)) {}
@@ -179,7 +179,7 @@ class Type {
const AbstractTy &getAbstractType() { return impl->getAbstractType(); }
protected:
- ImplType *impl;
+ ImplType *impl{nullptr};
};
inline raw_ostream &operator<<(raw_ostream &os, Type type) {
diff --git a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
index 9d65d104aa1e6..dbbe1a30ac5ab 100644
--- a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
+++ b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
@@ -68,8 +68,7 @@ class RegionSuccessor {
: 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 @@ class RegionSuccessor {
ValueRange getSuccessorInputs() const { return inputs; }
private:
- Region *region;
+ Region *region{nullptr};
ValueRange inputs;
};
diff --git a/mlir/include/mlir/Interfaces/InferTypeOpInterface.h b/mlir/include/mlir/Interfaces/InferTypeOpInterface.h
index 3ed9dcc9d3dd7..3ddd2c16667d9 100644
--- a/mlir/include/mlir/Interfaces/InferTypeOpInterface.h
+++ b/mlir/include/mlir/Interfaces/InferTypeOpInterface.h
@@ -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 @@ class ShapedTypeComponents {
ShapeStorageT dims;
Type elementType;
Attribute attr;
- bool ranked;
+ bool ranked{false};
};
/// Adaptor class to abstract the
diff erences between whether value is from
diff --git a/mlir/include/mlir/Support/DebugCounter.h b/mlir/include/mlir/Support/DebugCounter.h
index 5913b4d665884..5b6c015aadda5 100644
--- a/mlir/include/mlir/Support/DebugCounter.h
+++ b/mlir/include/mlir/Support/DebugCounter.h
@@ -54,11 +54,10 @@ class DebugCounter : public DebugActionManager::GenericHandler {
/// 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.
diff --git a/mlir/include/mlir/TableGen/Predicate.h b/mlir/include/mlir/TableGen/Predicate.h
index 2c91588a542f8..88f118a6391d4 100644
--- a/mlir/include/mlir/TableGen/Predicate.h
+++ b/mlir/include/mlir/TableGen/Predicate.h
@@ -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 @@ class Pred {
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
diff --git a/mlir/lib/TableGen/Predicate.cpp b/mlir/lib/TableGen/Predicate.cpp
index e034e7084b8cc..f9b6f6719efef 100644
--- a/mlir/lib/TableGen/Predicate.cpp
+++ b/mlir/lib/TableGen/Predicate.cpp
@@ -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();
}
More information about the Mlir-commits
mailing list