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 | 6694f60bec9fba4e20df1fdc8b7b9fdae7234033 (patch) | |
tree | fc5a4d0206953f078a77bd8c6be34efff8e99c53 /llvm/lib/Bitcode/Reader/BitcodeReader.h | |
parent | ee2d1f1ed2a8bfde444fa0963ed22d2a14cd9655 (diff) | |
download | bcm5719-llvm-6694f60bec9fba4e20df1fdc8b7b9fdae7234033.tar.gz bcm5719-llvm-6694f60bec9fba4e20df1fdc8b7b9fdae7234033.zip |
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.
llvm-svn: 36554
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.h')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.h b/llvm/lib/Bitcode/Reader/BitcodeReader.h index 8e211346026..0935c06f93c 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.h +++ b/llvm/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); |