aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode/Reader/Reader.h
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-08-22 16:09:19 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-08-22 16:09:19 +0000
commit233fe721c5489a32b8b5aaf4e6b43e4383d75400 (patch)
tree5368dcf6faea3d43bb5af146da971547e21611f1 /lib/Bytecode/Reader/Reader.h
parent751ca6b48cb741797c513fa0e9df369ebd7e4aa5 (diff)
For PR797:
Make the Bytecode Reader use setjmp/longjump instead of exceptions to handle errors. The alternative was even uglier than setjmp/longjump as it would impact the interface and workings of nearly every function in the reader. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29819 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Reader/Reader.h')
-rw-r--r--lib/Bytecode/Reader/Reader.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Bytecode/Reader/Reader.h b/lib/Bytecode/Reader/Reader.h
index da199519c3..37dd1d73ff 100644
--- a/lib/Bytecode/Reader/Reader.h
+++ b/lib/Bytecode/Reader/Reader.h
@@ -24,6 +24,7 @@
#include "llvm/Bytecode/Analyzer.h"
#include <utility>
#include <map>
+#include <setjmp.h>
namespace llvm {
@@ -136,11 +137,13 @@ public:
/// @name Methods
/// @{
public:
+ /// @returns true if an error occurred
/// @brief Main interface to parsing a bytecode buffer.
- void ParseBytecode(
+ bool ParseBytecode(
const unsigned char *Buf, ///< Beginning of the bytecode buffer
unsigned Length, ///< Length of the bytecode buffer
- const std::string &ModuleID ///< An identifier for the module constructed.
+ const std::string &ModuleID, ///< An identifier for the module constructed.
+ std::string* ErrMsg = 0 ///< Optional place for error message
);
/// @brief Parse all function bodies
@@ -260,6 +263,8 @@ protected:
/// @name Data
/// @{
private:
+ std::string ErrorMsg; ///< A place to hold an error message through longjmp
+ jmp_buf context; ///< Where to return to if an error occurs.
char* decompressedBlock; ///< Result of decompression
BufPtr MemStart; ///< Start of the memory buffer
BufPtr MemEnd; ///< End of the memory buffer
@@ -487,7 +492,7 @@ private:
}
}
- inline void error(std::string errmsg);
+ inline void error(const std::string& errmsg);
BytecodeReader(const BytecodeReader &); // DO NOT IMPLEMENT
void operator=(const BytecodeReader &); // DO NOT IMPLEMENT