Cleanup the constructor of BitcodeReader. NFC.

Use the same argument names as the members.
Use default member initializes.

Extracted from a patch by Karl Schimpf.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239749 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2015-06-15 20:08:17 +00:00
parent 0f73200fd2
commit 1456b12847

View File

@ -132,13 +132,13 @@ public:
class BitcodeReader : public GVMaterializer { class BitcodeReader : public GVMaterializer {
LLVMContext &Context; LLVMContext &Context;
DiagnosticHandlerFunction DiagnosticHandler; DiagnosticHandlerFunction DiagnosticHandler;
Module *TheModule; Module *TheModule = nullptr;
std::unique_ptr<MemoryBuffer> Buffer; std::unique_ptr<MemoryBuffer> Buffer;
std::unique_ptr<BitstreamReader> StreamFile; std::unique_ptr<BitstreamReader> StreamFile;
BitstreamCursor Stream; BitstreamCursor Stream;
DataStreamer *LazyStreamer; DataStreamer *Streamer;
uint64_t NextUnreadBit; uint64_t NextUnreadBit = 0;
bool SeenValueSymbolTable; bool SeenValueSymbolTable = false;
std::vector<Type*> TypeList; std::vector<Type*> TypeList;
BitcodeReaderValueList ValueList; BitcodeReaderValueList ValueList;
@ -180,7 +180,7 @@ class BitcodeReader : public GVMaterializer {
// Several operations happen after the module header has been read, but // Several operations happen after the module header has been read, but
// before function bodies are processed. This keeps track of whether // before function bodies are processed. This keeps track of whether
// we've done this yet. // we've done this yet.
bool SeenFirstFunctionBody; bool SeenFirstFunctionBody = false;
/// DeferredFunctionInfo - When function bodies are initially scanned, this /// DeferredFunctionInfo - When function bodies are initially scanned, this
/// map contains info about where to find deferred function body in the /// map contains info about where to find deferred function body in the
@ -205,17 +205,17 @@ class BitcodeReader : public GVMaterializer {
/// relative to the instruction ID: basic block numbers, and types. /// relative to the instruction ID: basic block numbers, and types.
/// Once the old style function blocks have been phased out, we would /// Once the old style function blocks have been phased out, we would
/// not need this flag. /// not need this flag.
bool UseRelativeIDs; bool UseRelativeIDs = false;
/// True if all functions will be materialized, negating the need to process /// True if all functions will be materialized, negating the need to process
/// (e.g.) blockaddress forward references. /// (e.g.) blockaddress forward references.
bool WillMaterializeAllForwardRefs; bool WillMaterializeAllForwardRefs = false;
/// Functions that have block addresses taken. This is usually empty. /// Functions that have block addresses taken. This is usually empty.
SmallPtrSet<const Function *, 4> BlockAddressesTaken; SmallPtrSet<const Function *, 4> BlockAddressesTaken;
/// True if any Metadata block has been materialized. /// True if any Metadata block has been materialized.
bool IsMetadataMaterialized; bool IsMetadataMaterialized = false;
bool StripDebugInfo = false; bool StripDebugInfo = false;
@ -224,10 +224,10 @@ public:
std::error_code Error(BitcodeError E); std::error_code Error(BitcodeError E);
std::error_code Error(const Twine &Message); std::error_code Error(const Twine &Message);
explicit BitcodeReader(MemoryBuffer *buffer, LLVMContext &C, BitcodeReader(MemoryBuffer *Buffer, LLVMContext &Context,
DiagnosticHandlerFunction DiagnosticHandler); DiagnosticHandlerFunction DiagnosticHandler);
explicit BitcodeReader(DataStreamer *streamer, LLVMContext &C, BitcodeReader(DataStreamer *Streamer, LLVMContext &Context,
DiagnosticHandlerFunction DiagnosticHandler); DiagnosticHandlerFunction DiagnosticHandler);
~BitcodeReader() override { FreeState(); } ~BitcodeReader() override { FreeState(); }
std::error_code materializeForwardReferencedFunctions(); std::error_code materializeForwardReferencedFunctions();
@ -425,21 +425,19 @@ static DiagnosticHandlerFunction getDiagHandler(DiagnosticHandlerFunction F,
return [&C](const DiagnosticInfo &DI) { C.diagnose(DI); }; return [&C](const DiagnosticInfo &DI) { C.diagnose(DI); };
} }
BitcodeReader::BitcodeReader(MemoryBuffer *buffer, LLVMContext &C, BitcodeReader::BitcodeReader(MemoryBuffer *Buffer, LLVMContext &Context,
DiagnosticHandlerFunction DiagnosticHandler) DiagnosticHandlerFunction DiagnosticHandler)
: Context(C), DiagnosticHandler(getDiagHandler(DiagnosticHandler, C)), : Context(Context),
TheModule(nullptr), Buffer(buffer), LazyStreamer(nullptr), DiagnosticHandler(getDiagHandler(DiagnosticHandler, Context)),
NextUnreadBit(0), SeenValueSymbolTable(false), ValueList(C), Buffer(Buffer), Streamer(nullptr), ValueList(Context),
MDValueList(C), SeenFirstFunctionBody(false), UseRelativeIDs(false), MDValueList(Context) {}
WillMaterializeAllForwardRefs(false), IsMetadataMaterialized(false) {}
BitcodeReader::BitcodeReader(DataStreamer *streamer, LLVMContext &C, BitcodeReader::BitcodeReader(DataStreamer *Streamer, LLVMContext &Context,
DiagnosticHandlerFunction DiagnosticHandler) DiagnosticHandlerFunction DiagnosticHandler)
: Context(C), DiagnosticHandler(getDiagHandler(DiagnosticHandler, C)), : Context(Context),
TheModule(nullptr), Buffer(nullptr), LazyStreamer(streamer), DiagnosticHandler(getDiagHandler(DiagnosticHandler, Context)),
NextUnreadBit(0), SeenValueSymbolTable(false), ValueList(C), Buffer(nullptr), Streamer(Streamer), ValueList(Context),
MDValueList(C), SeenFirstFunctionBody(false), UseRelativeIDs(false), MDValueList(Context) {}
WillMaterializeAllForwardRefs(false), IsMetadataMaterialized(false) {}
std::error_code BitcodeReader::materializeForwardReferencedFunctions() { std::error_code BitcodeReader::materializeForwardReferencedFunctions() {
if (WillMaterializeAllForwardRefs) if (WillMaterializeAllForwardRefs)
@ -2789,7 +2787,7 @@ std::error_code BitcodeReader::ParseModule(bool Resume,
// the bitcode. If the bitcode file is old, the symbol table will be // the bitcode. If the bitcode file is old, the symbol table will be
// at the end instead and will not have been seen yet. In this case, // at the end instead and will not have been seen yet. In this case,
// just finish the parse now. // just finish the parse now.
if (LazyStreamer && SeenValueSymbolTable) { if (Streamer && SeenValueSymbolTable) {
NextUnreadBit = Stream.GetCurrentBitNo(); NextUnreadBit = Stream.GetCurrentBitNo();
return std::error_code(); return std::error_code();
} }
@ -3040,7 +3038,7 @@ std::error_code BitcodeReader::ParseModule(bool Resume,
if (!isProto) { if (!isProto) {
Func->setIsMaterializable(true); Func->setIsMaterializable(true);
FunctionsWithBodies.push_back(Func); FunctionsWithBodies.push_back(Func);
if (LazyStreamer) if (Streamer)
DeferredFunctionInfo[Func] = 0; DeferredFunctionInfo[Func] = 0;
} }
break; break;
@ -3136,7 +3134,7 @@ std::error_code BitcodeReader::ParseBitcodeInto(Module *M,
TheModule = M; TheModule = M;
if (std::error_code EC = ParseModule(false, ShouldLazyLoadMetadata)) if (std::error_code EC = ParseModule(false, ShouldLazyLoadMetadata))
return EC; return EC;
if (LazyStreamer) if (Streamer)
return std::error_code(); return std::error_code();
break; break;
default: default:
@ -4446,7 +4444,7 @@ std::error_code BitcodeReader::materialize(GlobalValue *GV) {
assert(DFII != DeferredFunctionInfo.end() && "Deferred function not found!"); assert(DFII != DeferredFunctionInfo.end() && "Deferred function not found!");
// If its position is recorded as 0, its body is somewhere in the stream // If its position is recorded as 0, its body is somewhere in the stream
// but we haven't seen it yet. // but we haven't seen it yet.
if (DFII->second == 0 && LazyStreamer) if (DFII->second == 0 && Streamer)
if (std::error_code EC = FindFunctionInStream(F, DFII)) if (std::error_code EC = FindFunctionInStream(F, DFII))
return EC; return EC;
@ -4562,7 +4560,7 @@ std::vector<StructType *> BitcodeReader::getIdentifiedStructTypes() const {
} }
std::error_code BitcodeReader::InitStream() { std::error_code BitcodeReader::InitStream() {
if (LazyStreamer) if (Streamer)
return InitLazyStream(); return InitLazyStream();
return InitStreamFromBuffer(); return InitStreamFromBuffer();
} }
@ -4589,7 +4587,7 @@ std::error_code BitcodeReader::InitStreamFromBuffer() {
std::error_code BitcodeReader::InitLazyStream() { std::error_code BitcodeReader::InitLazyStream() {
// Check and strip off the bitcode wrapper; BitstreamReader expects never to // Check and strip off the bitcode wrapper; BitstreamReader expects never to
// see it. // see it.
auto OwnedBytes = llvm::make_unique<StreamingMemoryObject>(LazyStreamer); auto OwnedBytes = llvm::make_unique<StreamingMemoryObject>(Streamer);
StreamingMemoryObject &Bytes = *OwnedBytes; StreamingMemoryObject &Bytes = *OwnedBytes;
StreamFile = llvm::make_unique<BitstreamReader>(std::move(OwnedBytes)); StreamFile = llvm::make_unique<BitstreamReader>(std::move(OwnedBytes));
Stream.init(&*StreamFile); Stream.init(&*StreamFile);