[llvm] 71cdb8c - [ADT] Use default member initialization (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 23 10:50:32 PDT 2022


Author: Kazu Hirata
Date: 2022-07-23T10:50:27-07:00
New Revision: 71cdb8c6f144b8f78fed1f39dc6b9c153f9023c1

URL: https://github.com/llvm/llvm-project/commit/71cdb8c6f144b8f78fed1f39dc6b9c153f9023c1
DIFF: https://github.com/llvm/llvm-project/commit/71cdb8c6f144b8f78fed1f39dc6b9c153f9023c1.diff

LOG: [ADT] Use default member initialization (NFC)

Identified with modernize-use-default-member-init.

Added: 
    

Modified: 
    llvm/include/llvm/ADT/APInt.h
    llvm/include/llvm/ADT/APSInt.h
    llvm/include/llvm/ADT/BitVector.h
    llvm/include/llvm/ADT/EpochTracker.h
    llvm/include/llvm/ADT/IntEqClasses.h
    llvm/include/llvm/ADT/Triple.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 4155cb260a2a5..5bdc1541f6302 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -147,7 +147,7 @@ class LLVM_NODISCARD APInt {
   APInt(unsigned numBits, StringRef str, uint8_t radix);
 
   /// Default constructor that creates an APInt with a 1-bit zero value.
-  explicit APInt() : BitWidth(1) { U.VAL = 0; }
+  explicit APInt() { U.VAL = 0; }
 
   /// Copy Constructor.
   APInt(const APInt &that) : BitWidth(that.BitWidth) {
@@ -1824,7 +1824,7 @@ class LLVM_NODISCARD APInt {
     uint64_t *pVal; ///< Used to store the >64 bits integer value.
   } U;
 
-  unsigned BitWidth; ///< The number of bits in this APInt.
+  unsigned BitWidth = 1; ///< The number of bits in this APInt.
 
   friend struct DenseMapInfo<APInt, void>;
   friend class APSInt;

diff  --git a/llvm/include/llvm/ADT/APSInt.h b/llvm/include/llvm/ADT/APSInt.h
index 7b6af436f5776..727d95ed8c1ca 100644
--- a/llvm/include/llvm/ADT/APSInt.h
+++ b/llvm/include/llvm/ADT/APSInt.h
@@ -21,11 +21,11 @@ namespace llvm {
 
 /// An arbitrary precision integer that knows its signedness.
 class LLVM_NODISCARD APSInt : public APInt {
-  bool IsUnsigned;
+  bool IsUnsigned = false;
 
 public:
   /// Default constructor that creates an uninitialized APInt.
-  explicit APSInt() : IsUnsigned(false) {}
+  explicit APSInt() = default;
 
   /// Create an APSInt with the specified width, default to unsigned.
   explicit APSInt(uint32_t BitWidth, bool isUnsigned = true)

diff  --git a/llvm/include/llvm/ADT/BitVector.h b/llvm/include/llvm/ADT/BitVector.h
index 9540b39859633..2ba4857778166 100644
--- a/llvm/include/llvm/ADT/BitVector.h
+++ b/llvm/include/llvm/ADT/BitVector.h
@@ -83,7 +83,7 @@ class BitVector {
   using Storage = SmallVector<BitWord>;
 
   Storage Bits;  // Actual bits.
-  unsigned Size; // Size of bitvector in bits.
+  unsigned Size = 0; // Size of bitvector in bits.
 
 public:
   using size_type = unsigned;
@@ -135,7 +135,7 @@ class BitVector {
   }
 
   /// BitVector default ctor - Creates an empty bitvector.
-  BitVector() : Size(0) {}
+  BitVector() = default;
 
   /// BitVector ctor - Creates a bitvector of specified number of bits. All
   /// bits are initialized to the specified value.

diff  --git a/llvm/include/llvm/ADT/EpochTracker.h b/llvm/include/llvm/ADT/EpochTracker.h
index b46989bc51114..a639d1b5b3ec4 100644
--- a/llvm/include/llvm/ADT/EpochTracker.h
+++ b/llvm/include/llvm/ADT/EpochTracker.h
@@ -56,11 +56,11 @@ class DebugEpochBase {
   /// make an iterator-invalidating modification.
   ///
   class HandleBase {
-    const uint64_t *EpochAddress;
-    uint64_t EpochAtCreation;
+    const uint64_t *EpochAddress = nullptr;
+    uint64_t EpochAtCreation = UINT64_MAX;
 
   public:
-    HandleBase() : EpochAddress(nullptr), EpochAtCreation(UINT64_MAX) {}
+    HandleBase() = default;
 
     explicit HandleBase(const DebugEpochBase *Parent)
         : EpochAddress(&Parent->Epoch), EpochAtCreation(Parent->Epoch) {}

diff  --git a/llvm/include/llvm/ADT/IntEqClasses.h b/llvm/include/llvm/ADT/IntEqClasses.h
index 84bb58cb736c3..9ee8a46be411e 100644
--- a/llvm/include/llvm/ADT/IntEqClasses.h
+++ b/llvm/include/llvm/ADT/IntEqClasses.h
@@ -35,11 +35,11 @@ class IntEqClasses {
 
   /// NumClasses - The number of equivalence classes when compressed, or 0 when
   /// uncompressed.
-  unsigned NumClasses;
+  unsigned NumClasses = 0;
 
 public:
   /// IntEqClasses - Create an equivalence class mapping for 0 .. N-1.
-  IntEqClasses(unsigned N = 0) : NumClasses(0) { grow(N); }
+  IntEqClasses(unsigned N = 0) { grow(N); }
 
   /// grow - Increase capacity to hold 0 .. N-1, putting new integers in unique
   /// equivalence classes.

diff  --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index 9d85a28fbf040..ba4584dc60faf 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -283,22 +283,22 @@ class Triple {
   std::string Data;
 
   /// The parsed arch type.
-  ArchType Arch;
+  ArchType Arch{};
 
   /// The parsed subarchitecture type.
-  SubArchType SubArch;
+  SubArchType SubArch{};
 
   /// The parsed vendor type.
-  VendorType Vendor;
+  VendorType Vendor{};
 
   /// The parsed OS type.
-  OSType OS;
+  OSType OS{};
 
   /// The parsed Environment type.
-  EnvironmentType Environment;
+  EnvironmentType Environment{};
 
   /// The object format type.
-  ObjectFormatType ObjectFormat;
+  ObjectFormatType ObjectFormat{};
 
 public:
   /// @name Constructors
@@ -306,7 +306,7 @@ class Triple {
 
   /// Default constructor is the same as an empty string and leaves all
   /// triple fields unknown.
-  Triple() : Arch(), SubArch(), Vendor(), OS(), Environment(), ObjectFormat() {}
+  Triple() = default;
 
   explicit Triple(const Twine &Str);
   Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr);


        


More information about the llvm-commits mailing list