From ec68dd49bfa3a0e7e68e272e4331d27340b1f639 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Fri, 23 Dec 2016 02:20:02 +0000 Subject: MetadataLoader: Refactor "IsImporting" into the Pimpl for the MetadataLoader (NFC) Keeping all the state together will make it easier to handle. llvm-svn: 290406 --- llvm/lib/Bitcode/Reader/MetadataLoader.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'llvm/lib/Bitcode/Reader/MetadataLoader.cpp') diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp index 862a02c..695b2b0 100644 --- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp @@ -391,6 +391,9 @@ class MetadataLoader::MetadataLoaderImpl { bool StripTBAA = false; bool HasSeenOldLoopTags = false; + /// True if metadata is being parsed for a module being ThinLTO imported. + bool IsImporting = false; + Error parseMetadataStrings(ArrayRef Record, StringRef Blob, unsigned &NextMetadataNo); Error parseGlobalObjectAttachment(GlobalObject &GO, @@ -400,12 +403,13 @@ class MetadataLoader::MetadataLoaderImpl { public: MetadataLoaderImpl(BitstreamCursor &Stream, Module &TheModule, BitcodeReaderValueList &ValueList, - std::function getTypeByID) + std::function getTypeByID, + bool IsImporting) : MetadataList(TheModule.getContext()), ValueList(ValueList), Stream(Stream), Context(TheModule.getContext()), TheModule(TheModule), - getTypeByID(getTypeByID) {} + getTypeByID(getTypeByID), IsImporting(IsImporting) {} - Error parseMetadata(bool ModuleLevel, bool IsImporting); + Error parseMetadata(bool ModuleLevel); bool hasFwdRefs() const { return MetadataList.hasFwdRefs(); } Metadata *getMetadataFwdRef(unsigned Idx) { @@ -441,8 +445,7 @@ Error error(const Twine &Message) { /// Parse a METADATA_BLOCK. If ModuleLevel is true then we are parsing /// module level metadata. -Error MetadataLoader::MetadataLoaderImpl::parseMetadata(bool ModuleLevel, - bool IsImporting) { +Error MetadataLoader::MetadataLoaderImpl::parseMetadata(bool ModuleLevel) { if (!ModuleLevel && MetadataList.hasFwdRefs()) return error("Invalid metadata: fwd refs into function blocks"); @@ -1333,7 +1336,7 @@ MetadataLoader &MetadataLoader::operator=(MetadataLoader &&RHS) { return *this; } MetadataLoader::MetadataLoader(MetadataLoader &&RHS) - : Pimpl(std::move(RHS.Pimpl)), IsImporting(RHS.IsImporting) {} + : Pimpl(std::move(RHS.Pimpl)) {} MetadataLoader::~MetadataLoader() = default; MetadataLoader::MetadataLoader(BitstreamCursor &Stream, Module &TheModule, @@ -1341,11 +1344,10 @@ MetadataLoader::MetadataLoader(BitstreamCursor &Stream, Module &TheModule, bool IsImporting, std::function getTypeByID) : Pimpl(llvm::make_unique(Stream, TheModule, ValueList, - getTypeByID)), - IsImporting(IsImporting) {} + getTypeByID, IsImporting)) {} Error MetadataLoader::parseMetadata(bool ModuleLevel) { - return Pimpl->parseMetadata(ModuleLevel, IsImporting); + return Pimpl->parseMetadata(ModuleLevel); } bool MetadataLoader::hasFwdRefs() const { return Pimpl->hasFwdRefs(); } -- cgit v1.1