]> granicus.if.org Git - llvm/commitdiff
Make more constructors constexpr or use =default.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sun, 8 Oct 2017 15:59:35 +0000 (15:59 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sun, 8 Oct 2017 15:59:35 +0000 (15:59 +0000)
This lets the compiler reason about the type more easily. No
functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315180 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/ArrayRef.h
include/llvm/ADT/PointerIntPair.h
include/llvm/ADT/PointerSumType.h
include/llvm/CodeGen/SlotIndexes.h
include/llvm/IR/CallSite.h
include/llvm/MC/MCValue.h
include/llvm/Support/ScaledNumber.h

index 925ebafc3feda7e7a3bf16a17d19f4371b3c2d9f..5f7a769ddac443f95839b68f853a8bb4d5b09e8e 100644 (file)
@@ -294,7 +294,7 @@ namespace llvm {
     using reverse_iterator = std::reverse_iterator<iterator>;
 
     /// Construct an empty MutableArrayRef.
-    /*implicit*/ MutableArrayRef() : ArrayRef<T>() {}
+    /*implicit*/ MutableArrayRef() = default;
 
     /// Construct an empty MutableArrayRef from None.
     /*implicit*/ MutableArrayRef(NoneType) : ArrayRef<T>() {}
index f7e100bb4e12c05b4e2161b8585dc45478c506c7..eb5a3369900072e45e370fe54d01125d652d4d8a 100644 (file)
@@ -47,7 +47,7 @@ class PointerIntPair {
   intptr_t Value;
 
 public:
-  PointerIntPair() : Value(0) {}
+  constexpr PointerIntPair() : Value(0) {}
   PointerIntPair(PointerTy PtrVal, IntType IntVal) {
     setPointerAndInt(PtrVal, IntVal);
   }
index 062544eedf84b0647bbdab160e84cfe731094694..1a49e062dc2a62a6a03f11d1d44f91cbc7af52fd 100644 (file)
@@ -65,7 +65,7 @@ template <typename TagT, typename... MemberTs> class PointerSumType {
   typedef detail::PointerSumTypeHelper<TagT, MemberTs...> HelperT;
 
 public:
-  PointerSumType() : Value(0) {}
+  constexpr PointerSumType() : Value(0) {}
 
   /// A typed constructor for a specific tagged member of the sum type.
   template <TagT N>
index a7b16e7a9ed229ef8f719e5e43b4360b3b16d5b1..3a91e363f923156457d3961aa628c0bb75686b01 100644 (file)
@@ -139,7 +139,7 @@ class raw_ostream;
     };
 
     /// Construct an invalid index.
-    SlotIndex() : lie(nullptr, 0) {}
+    SlotIndex() = default;
 
     // Construct a new slot index from the given one, and set the slot.
     SlotIndex(const SlotIndex &li, Slot s) : lie(li.listEntry(), unsigned(s)) {
index 01aa03e59ff5cfcc2cbe4ce1959303140251e249..f1af2e436631e0f2657263c3fc08b04f9bb4e552 100644 (file)
@@ -62,7 +62,7 @@ class CallSiteBase {
 protected:
   PointerIntPair<InstrTy*, 1, bool> I;
 
-  CallSiteBase() : I(nullptr, false) {}
+  CallSiteBase() = default;
   CallSiteBase(CallTy *CI) : I(CI, true) { assert(CI); }
   CallSiteBase(InvokeTy *II) : I(II, false) { assert(II); }
   explicit CallSiteBase(ValTy *II) { *this = get(II); }
index aa1eaf022c555b420fce5a6e19e634d1b474e0a1..ff223f70303bc43a7229281e4f70c7d54d2abd36 100644 (file)
@@ -38,11 +38,12 @@ class raw_ostream;
 /// Note that this class must remain a simple POD value class, because we need
 /// it to live in unions etc.
 class MCValue {
-  const MCSymbolRefExpr *SymA, *SymB;
-  int64_t Cst;
-  uint32_t RefKind;
+  const MCSymbolRefExpr *SymA = nullptr, *SymB = nullptr;
+  int64_t Cst = 0;
+  uint32_t RefKind = 0;
+
 public:
-  MCValue() : SymA(nullptr), SymB(nullptr), Cst(0), RefKind(0) {}
+  MCValue() = default;
   int64_t getConstant() const { return Cst; }
   const MCSymbolRefExpr *getSymA() const { return SymA; }
   const MCSymbolRefExpr *getSymB() const { return SymB; }
index 910174732994c1db803a0fd26311cce4a0125f9c..cfbdbc7516178b67996f83e2dc92bad895e3b6e6 100644 (file)
@@ -504,13 +504,13 @@ private:
   static_assert(Width <= 64, "invalid integer width for digits");
 
 private:
-  DigitsType Digits;
-  int16_t Scale;
+  DigitsType Digits = 0;
+  int16_t Scale = 0;
 
 public:
-  ScaledNumber() : Digits(0), Scale(0) {}
+  ScaledNumber() = default;
 
-  ScaledNumber(DigitsType Digits, int16_t Scale)
+  constexpr ScaledNumber(DigitsType Digits, int16_t Scale)
       : Digits(Digits), Scale(Scale) {}
 
 private: