diff options
author | Tim King <taking@google.com> | 2016-01-05 11:36:30 -0800 |
---|---|---|
committer | Tim King <taking@google.com> | 2016-01-05 11:36:30 -0800 |
commit | b717513e2a1d956c4456d13e0625957fc84c2449 (patch) | |
tree | 50b8a1fbd720fd5094004bde02de0ca61780df30 /src/base/exception.h | |
parent | 541c88a37f0880d7ea42a1aaa3a8688fc86ac811 (diff) |
Adding a new class LastExceptionBuffer for the purpose of owning the memory for the last exception C string. This replaces s_debugLastException.
Diffstat (limited to 'src/base/exception.h')
-rw-r--r-- | src/base/exception.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/base/exception.h b/src/base/exception.h index 84872b9b1..02384b6cb 100644 --- a/src/base/exception.h +++ b/src/base/exception.h @@ -27,6 +27,8 @@ #include <stdexcept> #include <string> +#include "base/tls.h" + namespace CVC4 { class CVC4_PUBLIC Exception : public std::exception { @@ -136,6 +138,30 @@ template <class T> inline void CheckArgument(bool cond, const T& arg) { } \ } +class CVC4_PUBLIC LastExceptionBuffer { +public: + LastExceptionBuffer(); + ~LastExceptionBuffer(); + + void setContents(const char* string); + const char* getContents() const { return d_contents; } + + static LastExceptionBuffer* getCurrent() { return s_currentBuffer; } + static void setCurrent(LastExceptionBuffer* buffer) { s_currentBuffer = buffer; } + + static const char* currentContents() { + return (getCurrent() == NULL) ? NULL : getCurrent()->getContents(); + } + +private: + /* Disallow copies */ + LastExceptionBuffer(const LastExceptionBuffer&) CVC4_UNUSED; + LastExceptionBuffer& operator=(const LastExceptionBuffer&) CVC4_UNUSED; + + char* d_contents; + + static CVC4_THREADLOCAL(LastExceptionBuffer*) s_currentBuffer; +}; /* class LastExceptionBuffer */ }/* CVC4 namespace */ |