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/IceAssembler.cpp b/src/IceAssembler.cpp
index a0500d6..e160612 100644
--- a/src/IceAssembler.cpp
+++ b/src/IceAssembler.cpp
@@ -88,7 +88,7 @@
assert(size() == 0);
}
-AssemblerBuffer::~AssemblerBuffer() {}
+AssemblerBuffer::~AssemblerBuffer() = default;
void AssemblerBuffer::extendCapacity() {
intptr_t old_size = size();
diff --git a/src/IceAssembler.h b/src/IceAssembler.h
index 69faa95..de4dd86 100644
--- a/src/IceAssembler.h
+++ b/src/IceAssembler.h
@@ -155,9 +155,7 @@
Assembler &operator=(const Assembler &) = delete;
public:
- Assembler()
- : Allocator(), FunctionName(""), IsInternal(false), Preliminary(false),
- Buffer(*this) {}
+ Assembler() : Allocator(), Buffer(*this) {}
virtual ~Assembler() = default;
// Allocate a chunk of bytes using the per-Assembler allocator.
@@ -217,13 +215,13 @@
// FunctionName and IsInternal are transferred from the original Cfg
// object, since the Cfg object may be deleted by the time the
// assembler buffer is emitted.
- IceString FunctionName;
- bool IsInternal;
+ IceString FunctionName = "";
+ bool IsInternal = false;
// Preliminary indicates whether a preliminary pass is being made
// for calculating bundle padding (Preliminary=true), versus the
// final pass where all changes to label bindings, label links, and
// relocation fixups are fully committed (Preliminary=false).
- bool Preliminary;
+ bool Preliminary = false;
protected:
// Buffer's constructor uses the Allocator, so it needs to appear after it.
diff --git a/src/IceAssemblerX8632.h b/src/IceAssemblerX8632.h
index 9d8c042..48a5f0a 100644
--- a/src/IceAssemblerX8632.h
+++ b/src/IceAssemblerX8632.h
@@ -48,7 +48,7 @@
Immediate &operator=(const Immediate &) = delete;
public:
- explicit Immediate(int32_t value) : value_(value), fixup_(nullptr) {}
+ explicit Immediate(int32_t value) : value_(value) {}
Immediate(RelocOffsetT offset, AssemblerFixup *fixup)
: value_(offset), fixup_(fixup) {
@@ -73,7 +73,7 @@
private:
const int32_t value_;
- AssemblerFixup *fixup_;
+ AssemblerFixup *fixup_ = nullptr;
};
class Operand {
@@ -243,7 +243,7 @@
static Address ofConstPool(Assembler *Asm, const Constant *Imm);
private:
- Address() {} // Needed by Address::Absolute.
+ Address() = default; // Needed by Address::Absolute.
};
class Label {
@@ -251,7 +251,7 @@
Label &operator=(const Label &) = delete;
public:
- Label() : position_(0), num_unresolved_(0) {
+ Label() {
#ifndef NDEBUG
for (int i = 0; i < kMaxUnresolvedBranches; i++) {
unresolved_near_positions_[i] = -1;
@@ -259,7 +259,7 @@
#endif // !NDEBUG
}
- ~Label() {}
+ ~Label() = default;
void FinalCheck() const {
// Assert if label is being destroyed with unresolved branches pending.
@@ -323,8 +323,8 @@
static const int kMaxUnresolvedBranches = 20;
- intptr_t position_;
- intptr_t num_unresolved_;
+ intptr_t position_ = 0;
+ intptr_t num_unresolved_ = 0;
// TODO(stichnot,jvoung): Can this instead be
// llvm::SmallVector<intptr_t, kMaxUnresolvedBranches> ?
intptr_t unresolved_near_positions_[kMaxUnresolvedBranches];
diff --git a/src/IceBrowserCompileServer.cpp b/src/IceBrowserCompileServer.cpp
index ba11e01..3a879ee 100644
--- a/src/IceBrowserCompileServer.cpp
+++ b/src/IceBrowserCompileServer.cpp
@@ -118,7 +118,7 @@
} // end of anonymous namespace
-BrowserCompileServer::~BrowserCompileServer() {}
+BrowserCompileServer::~BrowserCompileServer() = default;
void BrowserCompileServer::run() {
gCompileServer = this;
diff --git a/src/IceBrowserCompileServer.h b/src/IceBrowserCompileServer.h
index 4075d9d..473889d 100644
--- a/src/IceBrowserCompileServer.h
+++ b/src/IceBrowserCompileServer.h
@@ -100,7 +100,7 @@
// A borrowed reference to the current InputStream. The compiler owns
// the actual reference so the server must be careful not to access
// after the compiler is done.
- llvm::QueueStreamer *InputStream;
+ llvm::QueueStreamer *InputStream = nullptr;
std::unique_ptr<Ostream> LogStream;
std::unique_ptr<llvm::raw_fd_ostream> EmitStream;
std::unique_ptr<StringStream> ErrorStream;
diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp
index 2cbe571..f3b04eb 100644
--- a/src/IceCfg.cpp
+++ b/src/IceCfg.cpp
@@ -34,16 +34,13 @@
Cfg::Cfg(GlobalContext *Ctx, uint32_t SequenceNumber)
: Ctx(Ctx), SequenceNumber(SequenceNumber),
- VMask(Ctx->getFlags().getVerbose()), FunctionName(""),
- ReturnType(IceType_void), IsInternalLinkage(false), HasError(false),
- FocusedTiming(false), ErrorMessage(""), Entry(nullptr),
- NextInstNumber(Inst::NumberInitial), Allocator(new ArenaAllocator<>()),
- Live(nullptr), Target(TargetLowering::createLowering(
- Ctx->getFlags().getTargetArch(), this)),
+ VMask(Ctx->getFlags().getVerbose()), NextInstNumber(Inst::NumberInitial),
+ Allocator(new ArenaAllocator<>()), Live(nullptr),
+ Target(TargetLowering::createLowering(Ctx->getFlags().getTargetArch(),
+ this)),
VMetadata(new VariablesMetadata(this)),
TargetAssembler(TargetLowering::createAssembler(
- Ctx->getFlags().getTargetArch(), this)),
- CurrentNode(nullptr) {
+ Ctx->getFlags().getTargetArch(), this)) {
assert(!Ctx->isIRGenerationDisabled() &&
"Attempt to build cfg when IR generation disabled");
}
diff --git a/src/IceCfg.h b/src/IceCfg.h
index c231860..e96804c 100644
--- a/src/IceCfg.h
+++ b/src/IceCfg.h
@@ -207,14 +207,14 @@
GlobalContext *Ctx;
uint32_t SequenceNumber; // output order for emission
VerboseMask VMask;
- IceString FunctionName;
- Type ReturnType;
- bool IsInternalLinkage;
- bool HasError;
- bool FocusedTiming;
- IceString ErrorMessage;
- CfgNode *Entry; // entry basic block
- NodeList Nodes; // linearized node list; Entry should be first
+ IceString FunctionName = "";
+ Type ReturnType = IceType_void;
+ bool IsInternalLinkage = false;
+ bool HasError = false;
+ bool FocusedTiming = false;
+ IceString ErrorMessage = "";
+ CfgNode *Entry = nullptr; // entry basic block
+ NodeList Nodes; // linearized node list; Entry should be first
std::vector<IceString> IdentifierNames;
InstNumberT NextInstNumber;
VarList Variables;
@@ -233,7 +233,7 @@
// CfgNodes maintains this, but before global operations like
// register allocation, resetCurrentNode() should be called to avoid
// spurious validation failures.
- const CfgNode *CurrentNode;
+ const CfgNode *CurrentNode = nullptr;
// Maintain a pointer in TLS to the current Cfg being translated.
// This is primarily for accessing its allocator statelessly, but
diff --git a/src/IceCfgNode.cpp b/src/IceCfgNode.cpp
index aeb54ff..ddadc57 100644
--- a/src/IceCfgNode.cpp
+++ b/src/IceCfgNode.cpp
@@ -24,8 +24,7 @@
namespace Ice {
CfgNode::CfgNode(Cfg *Func, SizeT LabelNumber)
- : Func(Func), Number(LabelNumber), NameIndex(Cfg::IdentifierIndexInvalid),
- HasReturn(false), NeedsPlacement(false), InstCountEstimate(0) {}
+ : Func(Func), Number(LabelNumber) {}
// Returns the name the node was created with. If no name was given,
// it synthesizes a (hopefully) unique name.
@@ -949,8 +948,7 @@
const InstList &Insts)
: Asm(Asm), Target(Target), End(Insts.end()), BundleLockStart(End),
BundleSize(1 << Asm->getBundleAlignLog2Bytes()),
- BundleMaskLo(BundleSize - 1), BundleMaskHi(~BundleMaskLo),
- SizeSnapshotPre(0), SizeSnapshotPost(0) {}
+ BundleMaskLo(BundleSize - 1), BundleMaskHi(~BundleMaskLo) {}
// Check whether we're currently within a bundle_lock region.
bool isInBundleLockRegion() const { return BundleLockStart != End; }
// Check whether the current bundle_lock region has the align_to_end
@@ -1050,8 +1048,8 @@
const intptr_t BundleMaskLo;
// Masking with BundleMaskHi identifies an address's bundle.
const intptr_t BundleMaskHi;
- intptr_t SizeSnapshotPre;
- intptr_t SizeSnapshotPost;
+ intptr_t SizeSnapshotPre = 0;
+ intptr_t SizeSnapshotPost = 0;
};
} // end of anonymous namespace
diff --git a/src/IceCfgNode.h b/src/IceCfgNode.h
index 473c47e..3afc446 100644
--- a/src/IceCfgNode.h
+++ b/src/IceCfgNode.h
@@ -96,15 +96,16 @@
private:
CfgNode(Cfg *Func, SizeT LabelIndex);
Cfg *const Func;
- SizeT Number; // label index
- Cfg::IdentifierIndexType NameIndex; // index into Cfg::NodeNames table
- bool HasReturn; // does this block need an epilog?
- bool NeedsPlacement;
- InstNumberT InstCountEstimate; // rough instruction count estimate
- NodeList InEdges; // in no particular order
- NodeList OutEdges; // in no particular order
- PhiList Phis; // unordered set of phi instructions
- InstList Insts; // ordered list of non-phi instructions
+ SizeT Number; // label index
+ Cfg::IdentifierIndexType NameIndex =
+ Cfg::IdentifierIndexInvalid; // index into Cfg::NodeNames table
+ bool HasReturn = false; // does this block need an epilog?
+ bool NeedsPlacement = false;
+ InstNumberT InstCountEstimate = 0; // rough instruction count estimate
+ NodeList InEdges; // in no particular order
+ NodeList OutEdges; // in no particular order
+ PhiList Phis; // unordered set of phi instructions
+ InstList Insts; // ordered list of non-phi instructions
};
} // end of namespace Ice
diff --git a/src/IceClFlagsExtra.h b/src/IceClFlagsExtra.h
index 9346d6e..6f39336 100644
--- a/src/IceClFlagsExtra.h
+++ b/src/IceClFlagsExtra.h
@@ -25,9 +25,7 @@
ClFlagsExtra &operator=(const ClFlagsExtra &) = delete;
public:
- ClFlagsExtra()
- : AlwaysExitSuccess(false), BuildOnRead(false), GenerateBuildAtts(false),
- LLVMVerboseErrors(false), InputFileFormat(llvm::LLVMFormat) {}
+ ClFlagsExtra() = default;
bool getAlwaysExitSuccess() const { return AlwaysExitSuccess; }
void setAlwaysExitSuccess(bool NewValue) { AlwaysExitSuccess = NewValue; }
@@ -61,17 +59,17 @@
}
private:
- bool AlwaysExitSuccess;
- bool BuildOnRead;
- bool GenerateBuildAtts;
- bool LLVMVerboseErrors;
+ bool AlwaysExitSuccess = false;
+ bool BuildOnRead = false;
+ bool GenerateBuildAtts = false;
+ bool LLVMVerboseErrors = false;
- llvm::NaClFileFormat InputFileFormat;
+ llvm::NaClFileFormat InputFileFormat = llvm::LLVMFormat;
- IceString AppName;
- IceString IRFilename;
- IceString LogFilename;
- IceString OutputFilename;
+ IceString AppName = "";
+ IceString IRFilename = "";
+ IceString LogFilename = "";
+ IceString OutputFilename = "";
};
} // end of namespace Ice
diff --git a/src/IceCompileServer.h b/src/IceCompileServer.h
index ed3883b..497810a 100644
--- a/src/IceCompileServer.h
+++ b/src/IceCompileServer.h
@@ -45,7 +45,7 @@
public:
explicit CompileServer(Compiler &Comp) : Comp(Comp) {}
- virtual ~CompileServer() {}
+ virtual ~CompileServer() = default;
virtual void run() = 0;
diff --git a/src/IceCompiler.h b/src/IceCompiler.h
index 87915a6..460c327 100644
--- a/src/IceCompiler.h
+++ b/src/IceCompiler.h
@@ -30,7 +30,7 @@
Compiler &operator=(const Compiler &) = delete;
public:
- Compiler() {}
+ Compiler() = default;
// Run the compiler with the given GlobalContext for compilation
// state. Upon error, the Context's error status will be set.
diff --git a/src/IceConverter.h b/src/IceConverter.h
index 208b085..84389d3 100644
--- a/src/IceConverter.h
+++ b/src/IceConverter.h
@@ -33,7 +33,7 @@
Converter(llvm::Module *Mod, GlobalContext *Ctx)
: Translator(Ctx), Mod(Mod) {}
- ~Converter() {}
+ ~Converter() = default;
/// Converts the LLVM Module to ICE. Sets exit status to false if successful,
/// true otherwise.
diff --git a/src/IceDefs.h b/src/IceDefs.h
index 0e8cdfb..64e70de 100644
--- a/src/IceDefs.h
+++ b/src/IceDefs.h
@@ -201,7 +201,7 @@
ErrorCode &operator=(const ErrorCode &) = delete;
public:
- ErrorCode() : HasError(false) {}
+ ErrorCode() = default;
void assign(ErrorCodes Code) {
if (!HasError) {
HasError = true;
@@ -211,7 +211,7 @@
void assign(int Code) { assign(static_cast<ErrorCodes>(Code)); }
private:
- bool HasError;
+ bool HasError = false;
};
// Reverse range adaptors written in terms of llvm::make_range().
diff --git a/src/IceELFObjectWriter.cpp b/src/IceELFObjectWriter.cpp
index 874b36a..d24144c 100644
--- a/src/IceELFObjectWriter.cpp
+++ b/src/IceELFObjectWriter.cpp
@@ -64,8 +64,7 @@
} // end of anonymous namespace
ELFObjectWriter::ELFObjectWriter(GlobalContext &Ctx, ELFStreamer &Out)
- : Ctx(Ctx), Str(Out), SectionNumbersAssigned(false),
- ELF64(isELF64(Ctx.getFlags().getTargetArch())) {
+ : Ctx(Ctx), Str(Out), ELF64(isELF64(Ctx.getFlags().getTargetArch())) {
// Create the special bookkeeping sections now.
const IceString NullSectionName("");
NullSection = new (Ctx.allocate<ELFSection>())
diff --git a/src/IceELFObjectWriter.h b/src/IceELFObjectWriter.h
index a9127ac..9356ee3 100644
--- a/src/IceELFObjectWriter.h
+++ b/src/IceELFObjectWriter.h
@@ -89,7 +89,7 @@
private:
GlobalContext &Ctx;
ELFStreamer &Str;
- bool SectionNumbersAssigned;
+ bool SectionNumbersAssigned = false;
bool ELF64;
// All created sections, separated into different pools.
diff --git a/src/IceELFSection.h b/src/IceELFSection.h
index c2ef9bf..ecbf555 100644
--- a/src/IceELFSection.h
+++ b/src/IceELFSection.h
@@ -44,7 +44,7 @@
// incrementally or only after the program is completely defined.
ELFSection(const IceString &Name, Elf64_Word ShType, Elf64_Xword ShFlags,
Elf64_Xword ShAddralign, Elf64_Xword ShEntsize)
- : Name(Name), Header(), Number(NoSectionNumber) {
+ : Name(Name), Header() {
Header.sh_type = ShType;
Header.sh_flags = ShFlags;
Header.sh_addralign = ShAddralign;
@@ -81,7 +81,7 @@
template <bool IsELF64> void writeHeader(ELFStreamer &Str);
protected:
- ~ELFSection() {}
+ ~ELFSection() = default;
// Name of the section in convenient string form (instead of a index
// into the Section Header String Table, which is not known till later).
@@ -92,7 +92,7 @@
Elf64_Shdr Header;
// The number of the section after laying out sections.
- SizeT Number;
+ SizeT Number = NoSectionNumber;
};
// Models text/code sections. Code is written out incrementally and the
diff --git a/src/IceFixups.h b/src/IceFixups.h
index 3b2b524..9ec72c3 100644
--- a/src/IceFixups.h
+++ b/src/IceFixups.h
@@ -28,7 +28,7 @@
AssemblerFixup &operator=(const AssemblerFixup &) = delete;
public:
- AssemblerFixup() : position_(0), kind_(0), value_(nullptr) {}
+ AssemblerFixup() = default;
AssemblerFixup(const AssemblerFixup &) = default;
intptr_t position() const { return position_; }
void set_position(intptr_t Position) { position_ = Position; }
@@ -47,9 +47,9 @@
void emit(GlobalContext *Ctx, RelocOffsetT BaseOffset) const;
private:
- intptr_t position_;
- FixupKind kind_;
- const Constant *value_;
+ intptr_t position_ = 0;
+ FixupKind kind_ = 0;
+ const Constant *value_ = nullptr;
};
typedef std::vector<AssemblerFixup> FixupList;
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp
index 9a3bedd..187ebd5 100644
--- a/src/IceGlobalContext.cpp
+++ b/src/IceGlobalContext.cpp
@@ -120,7 +120,7 @@
TypePool &operator=(const TypePool &) = delete;
public:
- TypePool() : NextPoolID(0) {}
+ TypePool() = default;
ValueType *getOrAdd(GlobalContext *Ctx, KeyType Key) {
auto Iter = Pool.find(Key);
if (Iter != Pool.end())
@@ -152,7 +152,7 @@
typedef std::unordered_map<KeyType, ValueType *, std::hash<KeyType>,
KeyCompare<KeyType>> ContainerType;
ContainerType Pool;
- uint32_t NextPoolID;
+ uint32_t NextPoolID = 0;
};
// UndefPool maps ICE types to the corresponding ConstantUndef values.
@@ -161,7 +161,7 @@
UndefPool &operator=(const UndefPool &) = delete;
public:
- UndefPool() : NextPoolID(0), Pool(IceType_NUM) {}
+ UndefPool() : Pool(IceType_NUM) {}
ConstantUndef *getOrAdd(GlobalContext *Ctx, Type Ty) {
if (Pool[Ty] == nullptr)
@@ -170,7 +170,7 @@
}
private:
- uint32_t NextPoolID;
+ uint32_t NextPoolID = 0;
std::vector<ConstantUndef *> Pool;
};
@@ -183,7 +183,7 @@
ConstantPool &operator=(const ConstantPool &) = delete;
public:
- ConstantPool() {}
+ ConstantPool() = default;
TypePool<IceType_f32, float, ConstantFloat> Floats;
TypePool<IceType_f64, double, ConstantDouble> Doubles;
TypePool<IceType_i1, int8_t, ConstantInteger32> Integers1;
@@ -224,9 +224,7 @@
// EmitQ is allowed unlimited size.
EmitQ(/*Sequential=*/Flags.isSequential()),
DataLowering(TargetDataLowering::createLowering(this)),
- HasSeenCode(false),
- ProfileBlockInfoVarDecl(VariableDeclaration::create()),
- RandomizationCookie(0) {
+ ProfileBlockInfoVarDecl(VariableDeclaration::create()) {
assert(OsDump && "OsDump is not defined for GlobalContext");
assert(OsEmit && "OsEmit is not defined for GlobalContext");
assert(OsError && "OsError is not defined for GlobalContext");
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h
index ff3b8b3..7adde9f 100644
--- a/src/IceGlobalContext.h
+++ b/src/IceGlobalContext.h
@@ -139,7 +139,7 @@
ThreadContext &operator=(const ThreadContext &) = delete;
public:
- ThreadContext() {}
+ ThreadContext() = default;
CodeStats StatsFunction;
CodeStats StatsCumulative;
TimerList Timers;
@@ -466,7 +466,7 @@
// If !HasEmittedCode, SubZero will accumulate all Globals (which are "true"
// program global variables) until the first code WorkItem is seen.
// TODO(jpp): move to EmitterContext.
- bool HasSeenCode;
+ bool HasSeenCode = false;
// TODO(jpp): move to EmitterContext.
VariableDeclarationList Globals;
// TODO(jpp): move to EmitterContext.
@@ -512,7 +512,7 @@
// Randomization Cookie
// Managed by getRandomizationCookie()
GlobalLockType RandomizationCookieLock;
- uint32_t RandomizationCookie;
+ uint32_t RandomizationCookie = 0;
public:
static void TlsInit() { ICE_TLS_INIT_FIELD(TLS); }
@@ -529,13 +529,13 @@
public:
TimerMarker(TimerIdT ID, GlobalContext *Ctx,
TimerStackIdT StackID = GlobalContext::TSK_Default)
- : ID(ID), Ctx(Ctx), StackID(StackID), Active(false) {
+ : ID(ID), Ctx(Ctx), StackID(StackID) {
if (ALLOW_DUMP)
push();
}
TimerMarker(TimerIdT ID, const Cfg *Func,
TimerStackIdT StackID = GlobalContext::TSK_Default)
- : ID(ID), Ctx(nullptr), StackID(StackID), Active(false) {
+ : ID(ID), Ctx(nullptr), StackID(StackID) {
// Ctx gets set at the beginning of pushCfg().
if (ALLOW_DUMP)
pushCfg(Func);
@@ -552,7 +552,7 @@
const TimerIdT ID;
GlobalContext *Ctx;
const TimerStackIdT StackID;
- bool Active;
+ bool Active = false;
};
// Helper class for locking the streams and then automatically
diff --git a/src/IceGlobalInits.h b/src/IceGlobalInits.h
index 754f181..824f704 100644
--- a/src/IceGlobalInits.h
+++ b/src/IceGlobalInits.h
@@ -54,7 +54,7 @@
void setLinkage(llvm::GlobalValue::LinkageTypes NewLinkage) {
Linkage = NewLinkage;
}
- virtual ~GlobalDeclaration() {}
+ virtual ~GlobalDeclaration() = default;
/// Prints out type of the global declaration.
virtual void dumpType(Ostream &Stream) const = 0;
@@ -142,7 +142,7 @@
RelocInitializerKind
};
InitializerKind getKind() const { return Kind; }
- virtual ~Initializer() {}
+ virtual ~Initializer() = default;
virtual SizeT getNumBytes() const = 0;
virtual void dump(GlobalContext *Ctx, Ostream &Stream) const = 0;
void dump(Ostream &Stream) const {
diff --git a/src/IceInst.cpp b/src/IceInst.cpp
index 30d5066..74627ad 100644
--- a/src/IceInst.cpp
+++ b/src/IceInst.cpp
@@ -70,9 +70,7 @@
} // end of anonymous namespace
Inst::Inst(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest)
- : Kind(Kind), Number(Func->newInstNumber()), Deleted(false), Dead(false),
- HasSideEffects(false), IsDestNonKillable(false), Dest(Dest),
- MaxSrcs(MaxSrcs), NumSrcs(0),
+ : Kind(Kind), Number(Func->newInstNumber()), Dest(Dest), MaxSrcs(MaxSrcs),
Srcs(Func->allocateArrayOf<Operand *>(MaxSrcs)), LiveRangesEnded(0) {}
// Assign the instruction a new number.
diff --git a/src/IceInst.h b/src/IceInst.h
index 99a8653..84bd83d 100644
--- a/src/IceInst.h
+++ b/src/IceInst.h
@@ -161,7 +161,7 @@
void dumpDest(const Cfg *Func) const;
virtual bool isRedundantAssign() const { return false; }
- virtual ~Inst() {}
+ virtual ~Inst() = default;
protected:
Inst(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest);
@@ -183,23 +183,23 @@
// Number is the instruction number for describing live ranges.
InstNumberT Number;
// Deleted means irrevocably deleted.
- bool Deleted;
+ bool Deleted = false;
// Dead means one of two things depending on context: (1) pending
// deletion after liveness analysis converges, or (2) marked for
// deletion during lowering due to a folded bool operation.
- bool Dead;
+ bool Dead = false;
// HasSideEffects means the instruction is something like a function
// call or a volatile load that can't be removed even if its Dest
// variable is not live.
- bool HasSideEffects;
+ bool HasSideEffects = false;
// IsDestNonKillable means that liveness analysis shouldn't consider
// this instruction to kill the Dest variable. This is used when
// lowering produces two assignments to the same variable.
- bool IsDestNonKillable;
+ bool IsDestNonKillable = false;
Variable *Dest;
const SizeT MaxSrcs; // only used for assert
- SizeT NumSrcs;
+ SizeT NumSrcs = 0;
Operand **Srcs;
// LiveRangesEnded marks which Variables' live ranges end in this
diff --git a/src/IceIntrinsics.cpp b/src/IceIntrinsics.cpp
index 9d520b0..354120b 100644
--- a/src/IceIntrinsics.cpp
+++ b/src/IceIntrinsics.cpp
@@ -225,7 +225,7 @@
}
}
-Intrinsics::~Intrinsics() {}
+Intrinsics::~Intrinsics() = default;
const Intrinsics::FullIntrinsicInfo *Intrinsics::find(const IceString &Name,
bool &Error) const {
diff --git a/src/IceLiveness.h b/src/IceLiveness.h
index 6af0ef0..333a904 100644
--- a/src/IceLiveness.h
+++ b/src/IceLiveness.h
@@ -34,15 +34,15 @@
LivenessNode &operator=(const LivenessNode &) = delete;
public:
- LivenessNode() : NumLocals(0), NumNonDeadPhis(0) {}
+ LivenessNode() = default;
LivenessNode(const LivenessNode &) = default;
// NumLocals is the number of Variables local to this block.
- SizeT NumLocals;
+ SizeT NumLocals = 0;
// NumNonDeadPhis tracks the number of Phi instructions that
// Inst::liveness() identified as tentatively live. If
// NumNonDeadPhis changes from the last liveness pass, then liveness
// has not yet converged.
- SizeT NumNonDeadPhis;
+ SizeT NumNonDeadPhis = 0;
// LiveToVarMap maps a liveness bitvector index to a Variable. This
// is generally just for printing/dumping. The index should be less
// than NumLocals + Liveness::NumGlobals.
@@ -59,8 +59,7 @@
};
public:
- Liveness(Cfg *Func, LivenessMode Mode)
- : Func(Func), Mode(Mode), NumGlobals(0) {}
+ Liveness(Cfg *Func, LivenessMode Mode) : Func(Func), Mode(Mode) {}
void init();
Cfg *getFunc() const { return Func; }
LivenessMode getMode() const { return Mode; }
@@ -102,7 +101,7 @@
}
Cfg *Func;
LivenessMode Mode;
- SizeT NumGlobals;
+ SizeT NumGlobals = 0;
// Size of Nodes is Cfg::Nodes.size().
std::vector<LivenessNode> Nodes;
// VarToLiveMap maps a Variable's Variable::Number to its live index
diff --git a/src/IceOperand.h b/src/IceOperand.h
index ae6668b..9e0ff7d 100644
--- a/src/IceOperand.h
+++ b/src/IceOperand.h
@@ -79,17 +79,16 @@
dump(nullptr, Str);
}
- virtual ~Operand() {}
+ virtual ~Operand() = default;
protected:
- Operand(OperandKind Kind, Type Ty)
- : Ty(Ty), Kind(Kind), NumVars(0), Vars(nullptr) {}
+ Operand(OperandKind Kind, Type Ty) : Ty(Ty), Kind(Kind) {}
const Type Ty;
const OperandKind Kind;
// Vars and NumVars are initialized by the derived class.
- SizeT NumVars;
- Variable **Vars;
+ SizeT NumVars = 0;
+ Variable **Vars = nullptr;
};
template <class StreamType>
@@ -317,7 +316,7 @@
// method that ensures that W+infinity=infinity.
class RegWeight {
public:
- RegWeight() : Weight(0) {}
+ RegWeight() = default;
explicit RegWeight(uint32_t Weight) : Weight(Weight) {}
RegWeight(const RegWeight &) = default;
RegWeight &operator=(const RegWeight &) = default;
@@ -336,7 +335,7 @@
bool isZero() const { return Weight == Zero; }
private:
- uint32_t Weight;
+ uint32_t Weight = 0;
};
Ostream &operator<<(Ostream &Str, const RegWeight &W);
bool operator<(const RegWeight &A, const RegWeight &B);
@@ -351,10 +350,10 @@
// inside a loop.
class LiveRange {
public:
- LiveRange() : Weight(0) {}
+ LiveRange() = default;
// Special constructor for building a kill set. The advantage is
// that we can reserve the right amount of space in advance.
- explicit LiveRange(const std::vector<InstNumberT> &Kills) : Weight(0) {
+ explicit LiveRange(const std::vector<InstNumberT> &Kills) {
Range.reserve(Kills.size());
for (InstNumberT I : Kills)
addSegment(I, I);
@@ -392,7 +391,7 @@
typedef std::vector<RangeElementType, CfgLocalAllocator<RangeElementType>>
RangeType;
RangeType Range;
- RegWeight Weight;
+ RegWeight Weight = RegWeight(0);
// TrimmedBegin is an optimization for the overlaps() computation.
// Since the linear-scan algorithm always calls it as overlaps(Cur)
// and Cur advances monotonically according to live range start, we
@@ -510,10 +509,7 @@
protected:
Variable(OperandKind K, Type Ty, SizeT Index)
- : Operand(K, Ty), Number(Index), NameIndex(Cfg::IdentifierIndexInvalid),
- IsArgument(false), IsImplicitArgument(false), IgnoreLiveness(false),
- StackOffset(0), RegNum(NoRegister), RegNumTmp(NoRegister), Weight(1),
- LoVar(nullptr), HiVar(nullptr) {
+ : Operand(K, Ty), Number(Index) {
Vars = VarsReal;
Vars[0] = this;
NumVars = 1;
@@ -522,22 +518,22 @@
// Number is unique across all variables, and is used as a
// (bit)vector index for liveness analysis.
const SizeT Number;
- Cfg::IdentifierIndexType NameIndex;
- bool IsArgument;
- bool IsImplicitArgument;
+ Cfg::IdentifierIndexType NameIndex = Cfg::IdentifierIndexInvalid;
+ bool IsArgument = false;
+ bool IsImplicitArgument = false;
// IgnoreLiveness means that the variable should be ignored when
// constructing and validating live ranges. This is usually
// reserved for the stack pointer.
- bool IgnoreLiveness;
+ bool IgnoreLiveness = false;
// StackOffset is the canonical location on stack (only if
// RegNum==NoRegister || IsArgument).
- int32_t StackOffset;
+ int32_t StackOffset = 0;
// RegNum is the allocated register, or NoRegister if it isn't
// register-allocated.
- int32_t RegNum;
+ int32_t RegNum = NoRegister;
// RegNumTmp is the tentative assignment during register allocation.
- int32_t RegNumTmp;
- RegWeight Weight; // Register allocation priority
+ int32_t RegNumTmp = NoRegister;
+ RegWeight Weight = RegWeight(1); // Register allocation priority
LiveRange Live;
// LoVar and HiVar are needed for lowering from 64 to 32 bits. When
// lowering from I64 to I32 on a 32-bit architecture, we split the
@@ -546,8 +542,8 @@
// portion. TODO: It's wasteful to penalize all variables on all
// targets this way; use a sparser representation. It's also
// wasteful for a 64-bit target.
- Variable *LoVar;
- Variable *HiVar;
+ Variable *LoVar = nullptr;
+ Variable *HiVar = nullptr;
// VarsReal (and Operand::Vars) are set up such that Vars[0] ==
// this.
Variable *VarsReal[1];
@@ -574,9 +570,7 @@
MDS_MultiDefMultiBlock
};
enum MultiBlockState { MBS_Unknown, MBS_SingleBlock, MBS_MultiBlock };
- VariableTracking()
- : MultiDef(MDS_Unknown), MultiBlock(MBS_Unknown), SingleUseNode(nullptr),
- SingleDefNode(nullptr), FirstOrSingleDefinition(nullptr) {}
+ VariableTracking() = default;
VariableTracking(const VariableTracking &) = default;
MultiDefState getMultiDef() const { return MultiDef; }
MultiBlockState getMultiBlock() const { return MultiBlock; }
@@ -590,14 +584,15 @@
const CfgNode *Node);
private:
- MultiDefState MultiDef;
- MultiBlockState MultiBlock;
- const CfgNode *SingleUseNode;
- const CfgNode *SingleDefNode;
+ MultiDefState MultiDef = MDS_Unknown;
+ MultiBlockState MultiBlock = MBS_Unknown;
+ const CfgNode *SingleUseNode = nullptr;
+ const CfgNode *SingleDefNode = nullptr;
// All definitions of the variable are collected here, in increasing
// order of instruction number.
- InstDefList Definitions; // Only used if Kind==VMK_All
- const Inst *FirstOrSingleDefinition; // == Definitions[0] if Kind==VMK_All
+ InstDefList Definitions; // Only used if Kind==VMK_All
+ const Inst *FirstOrSingleDefinition =
+ nullptr; // Is a copy of Definitions[0] if Kind==VMK_All
};
// VariablesMetadata analyzes and summarizes the metadata for the
diff --git a/src/IceRegAlloc.h b/src/IceRegAlloc.h
index b53a6c9..1658a7d 100644
--- a/src/IceRegAlloc.h
+++ b/src/IceRegAlloc.h
@@ -27,8 +27,7 @@
LinearScan &operator=(const LinearScan &) = delete;
public:
- explicit LinearScan(Cfg *Func)
- : Func(Func), FindPreference(false), FindOverlap(false) {}
+ explicit LinearScan(Cfg *Func) : Func(Func) {}
void init(RegAllocKind Kind);
void scan(const llvm::SmallBitVector &RegMask, bool Randomized);
void dump(Cfg *Func) const;
@@ -58,8 +57,8 @@
OrderedRanges UnhandledPrecolored;
UnorderedRanges Active, Inactive, Handled;
std::vector<InstNumberT> Kills;
- bool FindPreference;
- bool FindOverlap;
+ bool FindPreference = false;
+ bool FindOverlap = false;
// TODO(stichnot): We're not really using FindOverlap yet, but we
// may want a flavor of register allocation where FindPreference is
// useful but we didn't want to initialize VMetadata with VMK_All
diff --git a/src/IceTargetLowering.cpp b/src/IceTargetLowering.cpp
index 03a5930..35ab024 100644
--- a/src/IceTargetLowering.cpp
+++ b/src/IceTargetLowering.cpp
@@ -77,9 +77,7 @@
}
TargetLowering::TargetLowering(Cfg *Func)
- : Func(Func), Ctx(Func->getContext()), HasComputedFrame(false),
- CallsReturnsTwice(false), StackAdjustment(0), NextLabelNumber(0),
- Context(), SnapshotStackAdjustment(0) {}
+ : Func(Func), Ctx(Func->getContext()), Context() {}
std::unique_ptr<Assembler> TargetLowering::createAssembler(TargetArch Target,
Cfg *Func) {
@@ -445,7 +443,7 @@
llvm::report_fatal_error("Unsupported target data lowering");
}
-TargetDataLowering::~TargetDataLowering() {}
+TargetDataLowering::~TargetDataLowering() = default;
namespace {
@@ -566,6 +564,6 @@
llvm::report_fatal_error("Unsupported target header lowering");
}
-TargetHeaderLowering::~TargetHeaderLowering() {}
+TargetHeaderLowering::~TargetHeaderLowering() = default;
} // end of namespace Ice
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
diff --git a/src/IceTargetLoweringARM32.cpp b/src/IceTargetLoweringARM32.cpp
index 571e2a3..de39aac 100644
--- a/src/IceTargetLoweringARM32.cpp
+++ b/src/IceTargetLoweringARM32.cpp
@@ -143,10 +143,7 @@
} // end of anonymous namespace
-TargetARM32::TargetARM32(Cfg *Func)
- : TargetLowering(Func), InstructionSet(ARM32InstructionSet::Begin),
- UsesFramePointer(false), NeedsStackAlignment(false), MaybeLeafFunc(true),
- SpillAreaSizeBytes(0) {
+TargetARM32::TargetARM32(Cfg *Func) : TargetLowering(Func) {
static_assert(
(ARM32InstructionSet::End - ARM32InstructionSet::Begin) ==
(TargetInstructionSet::ARM32InstructionSet_End -
diff --git a/src/IceTargetLoweringARM32.h b/src/IceTargetLoweringARM32.h
index 5eb320f..b7efac3 100644
--- a/src/IceTargetLoweringARM32.h
+++ b/src/IceTargetLoweringARM32.h
@@ -302,11 +302,11 @@
Context.insert(InstARM32Uxt::create(Func, Dest, Src0, Pred));
}
- ARM32InstructionSet InstructionSet;
- bool UsesFramePointer;
- bool NeedsStackAlignment;
- bool MaybeLeafFunc;
- size_t SpillAreaSizeBytes;
+ ARM32InstructionSet InstructionSet = ARM32InstructionSet::Begin;
+ bool UsesFramePointer = false;
+ bool NeedsStackAlignment = false;
+ bool MaybeLeafFunc = true;
+ size_t SpillAreaSizeBytes = 0;
llvm::SmallBitVector TypeToRegisterSet[IceType_NUM];
llvm::SmallBitVector ScratchRegs;
llvm::SmallBitVector RegsUsed;
diff --git a/src/IceTargetLoweringMIPS32.cpp b/src/IceTargetLoweringMIPS32.cpp
index 3655cb7..2cf5953 100644
--- a/src/IceTargetLoweringMIPS32.cpp
+++ b/src/IceTargetLoweringMIPS32.cpp
@@ -30,8 +30,7 @@
namespace Ice {
-TargetMIPS32::TargetMIPS32(Cfg *Func)
- : TargetLowering(Func), UsesFramePointer(false) {
+TargetMIPS32::TargetMIPS32(Cfg *Func) : TargetLowering(Func) {
// TODO: Don't initialize IntegerRegisters and friends every time.
// Instead, initialize in some sort of static initializer for the
// class.
diff --git a/src/IceTargetLoweringMIPS32.h b/src/IceTargetLoweringMIPS32.h
index cb89ffc..5383f38 100644
--- a/src/IceTargetLoweringMIPS32.h
+++ b/src/IceTargetLoweringMIPS32.h
@@ -115,8 +115,8 @@
static Type stackSlotType();
- bool UsesFramePointer;
- bool NeedsStackAlignment;
+ bool UsesFramePointer = false;
+ bool NeedsStackAlignment = false;
llvm::SmallBitVector TypeToRegisterSet[IceType_NUM];
llvm::SmallBitVector ScratchRegs;
llvm::SmallBitVector RegsUsed;
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index 13af9d7..6e80a8f 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -265,8 +265,7 @@
} // end of anonymous namespace
BoolFoldingEntry::BoolFoldingEntry(Inst *I)
- : Instr(I), IsComplex(BoolFolding::hasComplexLowering(I)), IsLiveOut(true),
- NumUses(0) {}
+ : Instr(I), IsComplex(BoolFolding::hasComplexLowering(I)) {}
BoolFolding::BoolFoldingProducerKind
BoolFolding::getProducerKind(const Inst *Instr) {
@@ -410,10 +409,7 @@
FoldingInfo.dump(Func);
}
-TargetX8632::TargetX8632(Cfg *Func)
- : TargetLowering(Func), InstructionSet(X86InstructionSet::Begin),
- IsEbpBasedFrame(false), NeedsStackAlignment(false), SpillAreaSizeBytes(0),
- RandomizationPoolingPaused(false) {
+TargetX8632::TargetX8632(Cfg *Func) : TargetLowering(Func) {
static_assert((X86InstructionSet::End - X86InstructionSet::Begin) ==
(TargetInstructionSet::X86InstructionSet_End -
TargetInstructionSet::X86InstructionSet_Begin),
diff --git a/src/IceTargetLoweringX8632.h b/src/IceTargetLoweringX8632.h
index dda2e4e..6fce261 100644
--- a/src/IceTargetLoweringX8632.h
+++ b/src/IceTargetLoweringX8632.h
@@ -31,24 +31,23 @@
BoolFoldingEntry(const BoolFoldingEntry &) = delete;
public:
- BoolFoldingEntry()
- : Instr(nullptr), IsComplex(false), IsLiveOut(true), NumUses(0) {}
+ BoolFoldingEntry() = default;
explicit BoolFoldingEntry(Inst *I);
BoolFoldingEntry &operator=(const BoolFoldingEntry &) = default;
// Instr is the instruction producing the i1-type variable of interest.
- Inst *Instr;
+ Inst *Instr = nullptr;
// IsComplex is the cached result of BoolFolding::hasComplexLowering(Instr).
- bool IsComplex;
+ bool IsComplex = false;
// IsLiveOut is initialized conservatively to true, and is set to false when
// we encounter an instruction that ends Var's live range. We disable the
// folding optimization when Var is live beyond this basic block. Note that
// if liveness analysis is not performed (e.g. in Om1 mode), IsLiveOut will
// always be true and the folding optimization will never be performed.
- bool IsLiveOut;
+ bool IsLiveOut = true;
// NumUses counts the number of times Var is used as a source operand in the
// basic block. If IsComplex is true and there is more than one use of Var,
// then the folding optimization is disabled for Var.
- uint32_t NumUses;
+ uint32_t NumUses = 0;
};
class BoolFolding {
@@ -72,7 +71,7 @@
BoolFolding &operator=(const BoolFolding &) = delete;
public:
- BoolFolding() {}
+ BoolFolding() = default;
static BoolFoldingProducerKind getProducerKind(const Inst *Instr);
static BoolFoldingConsumerKind getConsumerKind(const Inst *Instr);
static bool hasComplexLowering(const Inst *Instr);
@@ -586,10 +585,10 @@
bool optimizeScalarMul(Variable *Dest, Operand *Src0, int32_t Src1);
void findRMW();
- X86InstructionSet InstructionSet;
- bool IsEbpBasedFrame;
- bool NeedsStackAlignment;
- size_t SpillAreaSizeBytes;
+ X86InstructionSet InstructionSet = X86InstructionSet::Begin;
+ bool IsEbpBasedFrame = false;
+ bool NeedsStackAlignment = false;
+ size_t SpillAreaSizeBytes = 0;
llvm::SmallBitVector TypeToRegisterSet[IceType_NUM];
llvm::SmallBitVector ScratchRegs;
llvm::SmallBitVector RegsUsed;
@@ -602,7 +601,7 @@
OperandX8632Mem *
randomizeOrPoolImmediate(OperandX8632Mem *MemOperand,
int32_t RegNum = Variable::NoRegister);
- bool RandomizationPoolingPaused;
+ bool RandomizationPoolingPaused = false;
private:
~TargetX8632() override {}
diff --git a/src/IceThreading.h b/src/IceThreading.h
index 35e1bfb..12b085d 100644
--- a/src/IceThreading.h
+++ b/src/IceThreading.h
@@ -55,8 +55,7 @@
public:
BoundedProducerConsumerQueue(bool Sequential, size_t MaxSize = MaxStaticSize)
- : Back(0), Front(0), MaxSize(std::min(MaxSize, MaxStaticSize)),
- Sequential(Sequential), IsEnded(false) {}
+ : MaxSize(std::min(MaxSize, MaxStaticSize)), Sequential(Sequential) {}
void blockingPush(T *Item) {
{
std::unique_lock<GlobalLockType> L(Lock);
@@ -112,7 +111,7 @@
// be pushed. (More precisely, Back&MaxStaticSize is the index.)
// It is written by the producers, and read by all via size() and
// empty().
- size_t Back;
+ size_t Back = 0;
ICE_CACHELINE_BOUNDARY;
// Shrunk is notified (by the consumer) when something is removed
@@ -124,7 +123,7 @@
// i.e. the next to be popped. (More precisely Front&MaxStaticSize
// is the index.) It is written by the consumers, and read by all
// via size() and empty().
- size_t Front;
+ size_t Front = 0;
ICE_CACHELINE_BOUNDARY;
@@ -133,7 +132,7 @@
const bool Sequential;
// IsEnded is read by the consumers, and only written once by the
// producer.
- bool IsEnded;
+ bool IsEnded = false;
// The lock must be held when the following methods are called.
bool empty() const { return Front == Back; }
diff --git a/src/IceTimerTree.cpp b/src/IceTimerTree.cpp
index f1366d5..6c92215 100644
--- a/src/IceTimerTree.cpp
+++ b/src/IceTimerTree.cpp
@@ -20,8 +20,7 @@
namespace Ice {
TimerStack::TimerStack(const IceString &Name)
- : Name(Name), FirstTimestamp(timestamp()), LastTimestamp(FirstTimestamp),
- StateChangeCount(0), StackTop(0) {
+ : Name(Name), FirstTimestamp(timestamp()), LastTimestamp(FirstTimestamp) {
if (!ALLOW_DUMP)
return;
Nodes.resize(1); // Reserve Nodes[0] for the root node (sentinel).
diff --git a/src/IceTimerTree.h b/src/IceTimerTree.h
index c7cfd6e..17be997 100644
--- a/src/IceTimerTree.h
+++ b/src/IceTimerTree.h
@@ -44,13 +44,13 @@
TimerTreeNode &operator=(const TimerTreeNode &) = delete;
public:
- TimerTreeNode() : Parent(0), Interior(0), Time(0), UpdateCount(0) {}
+ TimerTreeNode() = default;
TimerTreeNode(const TimerTreeNode &) = default;
std::vector<TTindex> Children; // indexed by TimerIdT
- TTindex Parent;
- TimerIdT Interior;
- double Time;
- size_t UpdateCount;
+ TTindex Parent = 0;
+ TimerIdT Interior = 0;
+ double Time = 0;
+ size_t UpdateCount = 0;
};
public:
@@ -81,14 +81,14 @@
IceString Name;
double FirstTimestamp;
double LastTimestamp;
- uint64_t StateChangeCount;
+ uint64_t StateChangeCount = 0;
// IDsIndex maps a symbolic timer name to its integer ID.
std::map<IceString, TimerIdT> IDsIndex;
std::vector<IceString> IDs; // indexed by TimerIdT
std::vector<TimerTreeNode> Nodes; // indexed by TTindex
std::vector<double> LeafTimes; // indexed by TimerIdT
std::vector<size_t> LeafCounts; // indexed by TimerIdT
- TTindex StackTop;
+ TTindex StackTop = 0;
};
} // end of namespace Ice
diff --git a/src/IceTranslator.cpp b/src/IceTranslator.cpp
index aba71e5..c5919f3 100644
--- a/src/IceTranslator.cpp
+++ b/src/IceTranslator.cpp
@@ -25,7 +25,7 @@
: Ctx(Ctx), NextSequenceNumber(GlobalContext::getFirstSequenceNumber()),
ErrorStatus() {}
-Translator::~Translator() {}
+Translator::~Translator() = default;
IceString Translator::createUnnamedName(const IceString &Prefix, SizeT Index) {
if (Index == 0)
diff --git a/src/IceTypes.h b/src/IceTypes.h
index 9353d74..a881fb4 100644
--- a/src/IceTypes.h
+++ b/src/IceTypes.h
@@ -130,7 +130,7 @@
// Creates a function signature type with the given return type.
// Parameter types should be added using calls to appendArgType.
- FuncSigType() : ReturnType(IceType_void) {}
+ FuncSigType() = default;
FuncSigType(const FuncSigType &Ty) = default;
void appendArgType(Type ArgType) { ArgList.push_back(ArgType); }
@@ -147,7 +147,7 @@
private:
// The return type.
- Type ReturnType;
+ Type ReturnType = IceType_void;
// The list of parameters.
ArgListType ArgList;
};
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp
index d25e9f9..afe3ebc 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -47,10 +47,10 @@
/// Discriminator for LLVM-style RTTI.
enum TypeKind { Undefined, Simple, FuncSig };
- ExtendedType() : Kind(Undefined) {}
+ ExtendedType() = default;
ExtendedType(const ExtendedType &Ty) = default;
- virtual ~ExtendedType() {}
+ virtual ~ExtendedType() = default;
ExtendedType::TypeKind getKind() const { return Kind; }
void dump(Ice::Ostream &Stream) const;
@@ -75,7 +75,7 @@
Ice::FuncSigType Signature;
private:
- ExtendedType::TypeKind Kind;
+ ExtendedType::TypeKind Kind = Undefined;
};
Ice::Ostream &operator<<(Ice::Ostream &Stream, const ExtendedType &Ty) {
@@ -165,9 +165,8 @@
TopLevelParser(Ice::Translator &Translator, NaClBitstreamCursor &Cursor,
Ice::ErrorCode &ErrorStatus)
: NaClBitcodeParser(Cursor), Translator(Translator),
- ErrorStatus(ErrorStatus), NumErrors(0), NextDefiningFunctionID(0),
- VariableDeclarations(new Ice::VariableDeclarationList()),
- BlockParser(nullptr) {}
+ ErrorStatus(ErrorStatus),
+ VariableDeclarations(new Ice::VariableDeclarationList()) {}
~TopLevelParser() override {}
@@ -344,7 +343,7 @@
// The exit status that should be set to true if an error occurs.
Ice::ErrorCode &ErrorStatus;
// The number of errors reported.
- unsigned NumErrors;
+ unsigned NumErrors = 0;
// The types associated with each type ID.
std::vector<ExtendedType> TypeIDValues;
// The set of functions (prototype and defined).
@@ -355,7 +354,7 @@
// function definitions are encountered/parsed and
// NextDefiningFunctionID is incremented to track the next
// actually-defined function.
- size_t NextDefiningFunctionID;
+ size_t NextDefiningFunctionID = 0;
// The set of global variables.
std::unique_ptr<Ice::VariableDeclarationList> VariableDeclarations;
// Relocatable constants associated with global declarations.
@@ -364,7 +363,7 @@
Ice::FuncSigType UndefinedFuncSigType;
// The block parser currently being applied. Used for error
// reporting.
- BlockParserBaseClass *BlockParser;
+ BlockParserBaseClass *BlockParser = nullptr;
bool ParseBlock(unsigned BlockID) override;
@@ -726,8 +725,7 @@
public:
TypesParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser)
: BlockParserBaseClass(BlockID, EnclosingParser),
- Timer(Ice::TimerStack::TT_parseTypes, getTranslator().getContext()),
- NextTypeId(0) {}
+ Timer(Ice::TimerStack::TT_parseTypes, getTranslator().getContext()) {}
~TypesParser() override {}
@@ -735,7 +733,7 @@
Ice::TimerMarker Timer;
// The type ID that will be associated with the next type defining
// record in the types block.
- unsigned NextTypeId;
+ unsigned NextTypeId = 0;
void ProcessRecord() override;
@@ -906,7 +904,6 @@
GlobalsParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser)
: BlockParserBaseClass(BlockID, EnclosingParser),
Timer(Ice::TimerStack::TT_parseGlobals, getTranslator().getContext()),
- InitializersNeeded(0), NextGlobalID(0),
DummyGlobalVar(Ice::VariableDeclaration::create()),
CurGlobalVar(DummyGlobalVar) {}
@@ -918,10 +915,10 @@
Ice::TimerMarker Timer;
// Keeps track of how many initializers are expected for the global variable
// declaration being built.
- unsigned InitializersNeeded;
+ unsigned InitializersNeeded = 0;
// The index of the next global variable declaration.
- unsigned NextGlobalID;
+ unsigned NextGlobalID = 0;
// Dummy global variable declaration to guarantee CurGlobalVar is
// always defined (allowing code to not need to check if
@@ -1125,12 +1122,10 @@
FunctionParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser)
: BlockParserBaseClass(BlockID, EnclosingParser),
Timer(Ice::TimerStack::TT_parseFunctions, getTranslator().getContext()),
- Func(nullptr), CurrentBbIndex(0),
- FcnId(Context->getNextFunctionBlockValueID()),
+ Func(nullptr), FcnId(Context->getNextFunctionBlockValueID()),
FuncDecl(Context->getFunctionByID(FcnId)),
CachedNumGlobalValueIDs(Context->getNumGlobalIDs()),
- NextLocalInstIndex(Context->getNumGlobalIDs()),
- InstIsTerminating(false) {}
+ NextLocalInstIndex(Context->getNumGlobalIDs()) {}
bool convertFunction() {
const Ice::TimerStackIdT StackID = Ice::GlobalContext::TSK_Funcs;
@@ -1233,9 +1228,9 @@
// The corresponding ICE function defined by the function block.
std::unique_ptr<Ice::Cfg> Func;
// The index to the current basic block being built.
- uint32_t CurrentBbIndex;
+ uint32_t CurrentBbIndex = 0;
// The basic block being built.
- Ice::CfgNode *CurrentNode;
+ Ice::CfgNode *CurrentNode = nullptr;
// The ID for the function.
unsigned FcnId;
// The corresponding function declaration.
@@ -1250,7 +1245,7 @@
uint32_t NextLocalInstIndex;
// True if the last processed instruction was a terminating
// instruction.
- bool InstIsTerminating;
+ bool InstIsTerminating = false;
// Upper limit of alignment power allowed by LLVM
static const uint32_t AlignPowerLimit = 29;
@@ -2606,7 +2601,7 @@
ConstantsParser(unsigned BlockID, FunctionParser *FuncParser)
: BlockParserBaseClass(BlockID, FuncParser),
Timer(Ice::TimerStack::TT_parseConstants, getTranslator().getContext()),
- FuncParser(FuncParser), NextConstantType(Ice::IceType_void) {}
+ FuncParser(FuncParser) {}
~ConstantsParser() override {}
@@ -2617,7 +2612,7 @@
// The parser of the function block this constants block appears in.
FunctionParser *FuncParser;
// The type to use for succeeding constants.
- Ice::Type NextConstantType;
+ Ice::Type NextConstantType = Ice::IceType_void;
void ProcessRecord() override;
@@ -2821,8 +2816,7 @@
ModuleParser(unsigned BlockID, TopLevelParser *Context)
: BlockParserBaseClass(BlockID, Context),
Timer(Ice::TimerStack::TT_parseModule,
- Context->getTranslator().getContext()),
- GlobalDeclarationNamesAndInitializersInstalled(false) {}
+ Context->getTranslator().getContext()) {}
~ModuleParser() override {}
@@ -2832,7 +2826,7 @@
Ice::TimerMarker Timer;
// True if we have already installed names for unnamed global declarations,
// and have generated global constant initializers.
- bool GlobalDeclarationNamesAndInitializersInstalled;
+ bool GlobalDeclarationNamesAndInitializersInstalled = false;
// Generates names for unnamed global addresses (i.e. functions and
// global variables). Then lowers global variable declaration