Subzero: Use C++11 member initializers where practical.
Also change the pattern "foo() {}" into "foo() = default;" for ctors and dtors.
Generally avoids initializing unique_ptr<> members to nullptr in a .h file, because that requires knowing the definition of the underlying class which may not be available to all includers.
BUG= none
R=jpp@chromium.org
Review URL: https://codereview.chromium.org/1197223002
diff --git a/src/IceTargetLowering.h b/src/IceTargetLowering.h
index 8ce2c2f..205e573 100644
--- a/src/IceTargetLowering.h
+++ b/src/IceTargetLowering.h
@@ -39,8 +39,8 @@
LoweringContext &operator=(const LoweringContext &) = delete;
public:
- LoweringContext() : Node(nullptr), LastInserted(nullptr) {}
- ~LoweringContext() {}
+ LoweringContext() = default;
+ ~LoweringContext() = default;
void init(CfgNode *Node);
Inst *getNextInst() const {
if (Next == End)
@@ -67,8 +67,8 @@
private:
// Node is the argument to Inst::updateVars().
- CfgNode *Node;
- Inst *LastInserted;
+ CfgNode *Node = nullptr;
+ Inst *LastInserted = nullptr;
// Cur points to the current instruction being considered. It is
// guaranteed to point to a non-deleted instruction, or to be End.
InstList::iterator Cur;
@@ -226,7 +226,7 @@
virtual void addProlog(CfgNode *Node) = 0;
virtual void addEpilog(CfgNode *Node) = 0;
- virtual ~TargetLowering() {}
+ virtual ~TargetLowering() = default;
protected:
explicit TargetLowering(Cfg *Func);
@@ -323,12 +323,12 @@
Cfg *Func;
GlobalContext *Ctx;
- bool HasComputedFrame;
- bool CallsReturnsTwice;
+ bool HasComputedFrame = false;
+ bool CallsReturnsTwice = false;
// StackAdjustment keeps track of the current stack offset from its
// natural location, as arguments are pushed for a function call.
- int32_t StackAdjustment;
- SizeT NextLabelNumber;
+ int32_t StackAdjustment = 0;
+ SizeT NextLabelNumber = 0;
LoweringContext Context;
// Runtime helper function names
@@ -366,7 +366,7 @@
const static constexpr char *H_urem_i64 = "__umoddi3";
private:
- int32_t SnapshotStackAdjustment;
+ int32_t SnapshotStackAdjustment = 0;
};
// TargetDataLowering is used for "lowering" data including initializers