diff options
author | Chris Lattner <sabre@nondot.org> | 2007-04-29 07:54:31 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-04-29 07:54:31 +0000 |
commit | c453f76e2b4d7fd1e042b5b6d4c20556779186df (patch) | |
tree | a24882c0c4c773a77d7e16562335fe8364ffc47d /lib/Bitcode/Reader/BitcodeReader.h | |
parent | 333ffd4abfcc3be32a945dc73c81adeafde1ba6b (diff) |
Switch the bitcode reader interface to take a MemoryBuffer instead of knowing
anything about disk I/O itself. This greatly simplifies its interface -
eliminating the need for the ReaderWrappers.cpp file.
This adds a new option to llvm-dis (-bitcode) which instructs it to read
the input file as bitcode. Until/unless the bytecode reader is taught to
read from MemoryBuffer, there is no way to handle stdin reading without it.
I don't plan to switch the bytecode reader over, I'd rather delete it :),
so the option will stay around temporarily.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36554 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Reader/BitcodeReader.h')
-rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.h b/lib/Bitcode/Reader/BitcodeReader.h index 8e21134602..0935c06f93 100644 --- a/lib/Bitcode/Reader/BitcodeReader.h +++ b/lib/Bitcode/Reader/BitcodeReader.h @@ -22,6 +22,7 @@ namespace llvm { class BitstreamReader; + class MemoryBuffer; class BitcodeReaderValueList : public User { std::vector<Use> Uses; @@ -57,6 +58,7 @@ public: class BitcodeReader : public ModuleProvider { + MemoryBuffer *Buffer; const char *ErrorString; std::vector<PATypeHolder> TypeList; @@ -64,10 +66,16 @@ class BitcodeReader : public ModuleProvider { std::vector<std::pair<GlobalVariable*, unsigned> > GlobalInits; std::vector<std::pair<GlobalAlias*, unsigned> > AliasInits; public: - BitcodeReader() : ErrorString(0) {} - virtual ~BitcodeReader() {} + BitcodeReader(MemoryBuffer *buffer) : Buffer(buffer), ErrorString(0) {} + ~BitcodeReader(); - virtual void FreeState() {} + + /// releaseMemoryBuffer - This causes the reader to completely forget about + /// the memory buffer it contains, which prevents the buffer from being + /// destroyed when it is deleted. + void releaseMemoryBuffer() { + Buffer = 0; + } virtual bool materializeFunction(Function *F, std::string *ErrInfo = 0) { // FIXME: TODO @@ -89,8 +97,7 @@ public: /// @brief Main interface to parsing a bitcode buffer. /// @returns true if an error occurred. - bool ParseBitcode(unsigned char *Buf, unsigned Length, - const std::string &ModuleID); + bool ParseBitcode(); private: const Type *getTypeByID(unsigned ID, bool isTypeTable = false); |