[llvm] r290406 - MetadataLoader: Refactor "IsImporting" into the Pimpl for the MetadataLoader (NFC)
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 22 18:20:02 PST 2016
Author: mehdi_amini
Date: Thu Dec 22 20:20:02 2016
New Revision: 290406
URL: http://llvm.org/viewvc/llvm-project?rev=290406&view=rev
Log:
MetadataLoader: Refactor "IsImporting" into the Pimpl for the MetadataLoader (NFC)
Keeping all the state together will make it easier to handle.
Modified:
llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/trunk/lib/Bitcode/Reader/MetadataLoader.h
Modified: llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp?rev=290406&r1=290405&r2=290406&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp Thu Dec 22 20:20:02 2016
@@ -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<uint64_t> 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<Type *(unsigned)> getTypeByID)
+ std::function<Type *(unsigned)> 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
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(Bitstream
bool IsImporting,
std::function<Type *(unsigned)> getTypeByID)
: Pimpl(llvm::make_unique<MetadataLoaderImpl>(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(); }
Modified: llvm/trunk/lib/Bitcode/Reader/MetadataLoader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/MetadataLoader.h?rev=290406&r1=290405&r2=290406&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/MetadataLoader.h (original)
+++ llvm/trunk/lib/Bitcode/Reader/MetadataLoader.h Thu Dec 22 20:20:02 2016
@@ -36,8 +36,6 @@ class Type;
class MetadataLoader {
class MetadataLoaderImpl;
std::unique_ptr<MetadataLoaderImpl> Pimpl;
- /// True if metadata is being parsed for a module being ThinLTO imported.
- bool IsImporting = false;
Error parseMetadata(bool ModuleLevel);
public:
More information about the llvm-commits
mailing list