From 38f13eadc7058831255c950aefe577d691da0901 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 8 Oct 2017 15:59:35 +0000 Subject: [PATCH] Make more constructors constexpr or use =default. 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 | 2 +- include/llvm/ADT/PointerIntPair.h | 2 +- include/llvm/ADT/PointerSumType.h | 2 +- include/llvm/CodeGen/SlotIndexes.h | 2 +- include/llvm/IR/CallSite.h | 2 +- include/llvm/MC/MCValue.h | 9 +++++---- include/llvm/Support/ScaledNumber.h | 8 ++++---- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/llvm/ADT/ArrayRef.h b/include/llvm/ADT/ArrayRef.h index 925ebafc3fe..5f7a769ddac 100644 --- a/include/llvm/ADT/ArrayRef.h +++ b/include/llvm/ADT/ArrayRef.h @@ -294,7 +294,7 @@ namespace llvm { using reverse_iterator = std::reverse_iterator; /// Construct an empty MutableArrayRef. - /*implicit*/ MutableArrayRef() : ArrayRef() {} + /*implicit*/ MutableArrayRef() = default; /// Construct an empty MutableArrayRef from None. /*implicit*/ MutableArrayRef(NoneType) : ArrayRef() {} diff --git a/include/llvm/ADT/PointerIntPair.h b/include/llvm/ADT/PointerIntPair.h index f7e100bb4e1..eb5a3369900 100644 --- a/include/llvm/ADT/PointerIntPair.h +++ b/include/llvm/ADT/PointerIntPair.h @@ -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); } diff --git a/include/llvm/ADT/PointerSumType.h b/include/llvm/ADT/PointerSumType.h index 062544eedf8..1a49e062dc2 100644 --- a/include/llvm/ADT/PointerSumType.h +++ b/include/llvm/ADT/PointerSumType.h @@ -65,7 +65,7 @@ template class PointerSumType { typedef detail::PointerSumTypeHelper HelperT; public: - PointerSumType() : Value(0) {} + constexpr PointerSumType() : Value(0) {} /// A typed constructor for a specific tagged member of the sum type. template diff --git a/include/llvm/CodeGen/SlotIndexes.h b/include/llvm/CodeGen/SlotIndexes.h index a7b16e7a9ed..3a91e363f92 100644 --- a/include/llvm/CodeGen/SlotIndexes.h +++ b/include/llvm/CodeGen/SlotIndexes.h @@ -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)) { diff --git a/include/llvm/IR/CallSite.h b/include/llvm/IR/CallSite.h index 01aa03e59ff..f1af2e43663 100644 --- a/include/llvm/IR/CallSite.h +++ b/include/llvm/IR/CallSite.h @@ -62,7 +62,7 @@ class CallSiteBase { protected: PointerIntPair 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); } diff --git a/include/llvm/MC/MCValue.h b/include/llvm/MC/MCValue.h index aa1eaf022c5..ff223f70303 100644 --- a/include/llvm/MC/MCValue.h +++ b/include/llvm/MC/MCValue.h @@ -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; } diff --git a/include/llvm/Support/ScaledNumber.h b/include/llvm/Support/ScaledNumber.h index 91017473299..cfbdbc75161 100644 --- a/include/llvm/Support/ScaledNumber.h +++ b/include/llvm/Support/ScaledNumber.h @@ -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: -- 2.49.0