[llvm] r315180 - Make more constructors constexpr or use =default.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 8 08:59:35 PDT 2017
Author: d0k
Date: Sun Oct 8 08:59:35 2017
New Revision: 315180
URL: http://llvm.org/viewvc/llvm-project?rev=315180&view=rev
Log:
Make more constructors constexpr or use =default.
This lets the compiler reason about the type more easily. No
functionality change intended.
Modified:
llvm/trunk/include/llvm/ADT/ArrayRef.h
llvm/trunk/include/llvm/ADT/PointerIntPair.h
llvm/trunk/include/llvm/ADT/PointerSumType.h
llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
llvm/trunk/include/llvm/IR/CallSite.h
llvm/trunk/include/llvm/MC/MCValue.h
llvm/trunk/include/llvm/Support/ScaledNumber.h
Modified: llvm/trunk/include/llvm/ADT/ArrayRef.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ArrayRef.h?rev=315180&r1=315179&r2=315180&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/ArrayRef.h (original)
+++ llvm/trunk/include/llvm/ADT/ArrayRef.h Sun Oct 8 08:59:35 2017
@@ -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>() {}
Modified: llvm/trunk/include/llvm/ADT/PointerIntPair.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PointerIntPair.h?rev=315180&r1=315179&r2=315180&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/PointerIntPair.h (original)
+++ llvm/trunk/include/llvm/ADT/PointerIntPair.h Sun Oct 8 08:59:35 2017
@@ -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);
}
Modified: llvm/trunk/include/llvm/ADT/PointerSumType.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PointerSumType.h?rev=315180&r1=315179&r2=315180&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/PointerSumType.h (original)
+++ llvm/trunk/include/llvm/ADT/PointerSumType.h Sun Oct 8 08:59:35 2017
@@ -65,7 +65,7 @@ template <typename TagT, typename... Mem
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>
Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=315180&r1=315179&r2=315180&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Sun Oct 8 08:59:35 2017
@@ -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)) {
Modified: llvm/trunk/include/llvm/IR/CallSite.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/CallSite.h?rev=315180&r1=315179&r2=315180&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/CallSite.h (original)
+++ llvm/trunk/include/llvm/IR/CallSite.h Sun Oct 8 08:59:35 2017
@@ -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); }
Modified: llvm/trunk/include/llvm/MC/MCValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCValue.h?rev=315180&r1=315179&r2=315180&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCValue.h (original)
+++ llvm/trunk/include/llvm/MC/MCValue.h Sun Oct 8 08:59:35 2017
@@ -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; }
Modified: llvm/trunk/include/llvm/Support/ScaledNumber.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ScaledNumber.h?rev=315180&r1=315179&r2=315180&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ScaledNumber.h (original)
+++ llvm/trunk/include/llvm/Support/ScaledNumber.h Sun Oct 8 08:59:35 2017
@@ -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:
More information about the llvm-commits
mailing list