#include "context/context.h"
#include "context/context_mm.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
namespace CVC4 {
namespace context {
#include <ext/hash_map>
#include "context/context.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "context/cdhashmap_forward.h"
namespace CVC4 {
#include "context/context.h"
#include "context/cdhashset_forward.h"
#include "context/cdhashmap.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
namespace CVC4 {
namespace context {
#include "context/context.h"
#include "context/context_mm.h"
#include "context/cdlist_forward.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include <boost/static_assert.hpp>
#define __CVC4__CONTEXT__CDO_H
#include "context/context.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
namespace CVC4 {
namespace context {
#include "context/context.h"
#include "context/cdlist.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include <vector>
#include <vector>
#include "context/context.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
namespace CVC4 {
namespace context {
#include <typeinfo>
#include "context/context_mm.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
namespace CVC4 {
namespace context {
#include <deque>
#include <new>
#include "context/context_mm.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "util/output.h"
namespace CVC4 {
%include "util/output.i"
%include "util/result.i"
%include "util/configuration.i"
-%include "util/Assert.i"
%include "util/bitvector.i"
%include "util/subrange_bound.i"
%include "util/array.i"
#include "expr/node.h"
#include "expr/expr_manager_scope.h"
#include "expr/variable_type_map.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include <vector>
#include <iterator>
#include <iostream>
#include "expr/kind.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
namespace CVC4 {
#include "expr/kind.h"
#include "expr/metakind.h"
#include "expr/expr.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "util/configuration.h"
#include "util/output.h"
#include "util/exception.h"
#include "expr/kind.h"
#include "expr/metakind.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "expr/node_value.h"
#include "util/output.h"
#include "expr/node_manager.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "options/options.h"
#include "util/statistics_registry.h"
#include "util/tls.h"
#include <iterator>
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "expr/node.h"
namespace CVC4 {
#include "expr/node_value.h"
#include "expr/expr_manager_scope.h"
#include "expr/variable_type_map.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "expr/kind.h"
#include "expr/metakind.h"
#include "expr/node_value.h"
#include "expr/expr_manager_scope.h"
#include "expr/variable_type_map.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "expr/kind.h"
#include "expr/metakind.h"
#include "util/output.h"
#include "expr/kind.h"
#include "expr/metakind.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "util/cardinality.h"
namespace CVC4 {
#line 25 "${template}"
#include "expr/type_node.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "expr/kind.h"
#include "expr/expr.h"
#include "util/language.h"
#include "util/proof.h"
#include "proof/sat_proof.h"
#include "proof/cnf_proof.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
namespace CVC4 {
#include "theory/theory_engine.h"
#include "theory/theory.h"
#include "expr/node.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "util/output.h"
#include "expr/command.h"
#include "expr/expr.h"
#include "decision/options.h"
#include "theory/theory_engine.h"
#include "theory/theory_registrar.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "options/options.h"
#include "smt/options.h"
#include "main/options.h"
#include "smt/smt_engine.h"
#include "util/tls.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "expr/node_manager.h"
#include "util/output.h"
#include <iostream>
#include "theory/arrays/static_fact_manager.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "expr/node.h"
using namespace std;
#include <iostream>
#include "theory/arrays/union_find.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "expr/node.h"
using namespace std;
#include "theory/valuation.h"
#include "expr/kind.h"
#include "util/datatype.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "theory/datatypes/theory_datatypes_instantiator.h"
#include "theory/datatypes/datatypes_rewriter.h"
#include "theory/model.h"
#include "expr/kind.h"
#include "theory/logic_info.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
using namespace std;
using namespace CVC4::theory;
#ifndef __CVC4__THEORY__OUTPUT_CHANNEL_H
#define __CVC4__THEORY__OUTPUT_CHANNEL_H
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "theory/interrupted.h"
namespace CVC4 {
#include "theory/quantifiers/instantiation_engine.h"
#include "theory/quantifiers/model_engine.h"
#include "expr/kind.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "theory/quantifiers/theory_quantifiers_instantiator.h"
#include "theory/quantifiers/options.h"
#include "theory/quantifiers/term_database.h"
**/
#include "theory/theory.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "theory/quantifiers_engine.h"
#include "theory/quantifiers/instantiator_default.h"
#ifndef __CVC4__THEORY__THEORY_TEST_UTILS_H
#define __CVC4__THEORY__THEORY_TEST_UTILS_H
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "expr/node.h"
#include "theory/output_channel.h"
#include "theory/interrupted.h"
#include "util/exception.h"
#include "expr/node.h"
#include "expr/type_node.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
namespace CVC4 {
namespace theory {
#include "theory/type_enumerator.h"
#include "expr/kind.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
${type_enumerator_includes}
#line 28 "${template}"
+++ /dev/null
-/********************* */
-/*! \file Assert.cpp
- ** \verbatim
- ** Original author: mdeters
- ** Major contributors: none
- ** Minor contributors (to current version): acsys
- ** This file is part of the CVC4 prototype.
- ** Copyright (c) 2009, 2010, 2011 The Analysis of Computer Systems Group (ACSys)
- ** Courant Institute of Mathematical Sciences
- ** New York University
- ** See the file COPYING in the top-level source directory for licensing
- ** information.\endverbatim
- **
- ** \brief Assertion utility classes, functions, and exceptions.
- **
- ** Assertion utility classes, functions, and exceptions. Implementation.
- **/
-
-#include <new>
-#include <cstdarg>
-#include <cstdio>
-
-#include "util/Assert.h"
-
-using namespace std;
-
-namespace CVC4 {
-
-#ifdef CVC4_DEBUG
-CVC4_THREADLOCAL(const char*) s_debugLastException = NULL;
-#endif /* CVC4_DEBUG */
-
-void AssertionException::construct(const char* header, const char* extra,
- const char* function, const char* file,
- unsigned line, const char* fmt,
- va_list args) {
- // try building the exception msg with a smallish buffer first,
- // then with a larger one if sprintf tells us to.
- int n = 512;
- char* buf;
-
- for(;;) {
- buf = new char[n];
-
- int size;
- if(extra == NULL) {
- size = snprintf(buf, n, "%s\n%s\n%s:%d\n",
- header, function, file, line);
- } else {
- size = snprintf(buf, n, "%s\n%s\n%s:%d:\n\n %s\n",
- header, function, file, line, extra);
- }
-
- if(size < n) {
- va_list args_copy;
- va_copy(args_copy, args);
- size += vsnprintf(buf + size, n - size, fmt, args_copy);
- va_end(args_copy);
-
- if(size < n) {
- break;
- }
- }
-
- if(size >= n) {
- // try again with a buffer that's large enough
- n = size + 1;
- delete [] buf;
- }
- }
-
- setMessage(string(buf));
-
-#ifdef CVC4_DEBUG
- if(s_debugLastException == NULL) {
- // we leak buf[] but only in debug mode with assertions failing
- s_debugLastException = buf;
- }
-#else /* CVC4_DEBUG */
- delete [] buf;
-#endif /* CVC4_DEBUG */
-}
-
-void AssertionException::construct(const char* header, const char* extra,
- const char* function, const char* file,
- unsigned line) {
- // try building the exception msg with a smallish buffer first,
- // then with a larger one if sprintf tells us to.
- int n = 256;
- char* buf;
-
- for(;;) {
- buf = new char[n];
-
- int size;
- if(extra == NULL) {
- size = snprintf(buf, n, "%s.\n%s\n%s:%d\n",
- header, function, file, line);
- } else {
- size = snprintf(buf, n, "%s.\n%s\n%s:%d:\n\n %s\n",
- header, function, file, line, extra);
- }
-
- if(size < n) {
- break;
- } else {
- // try again with a buffer that's large enough
- n = size + 1;
- delete [] buf;
- }
- }
-
- setMessage(string(buf));
-
-#ifdef CVC4_DEBUG
- // we leak buf[] but only in debug mode with assertions failing
- if(s_debugLastException == NULL) {
- s_debugLastException = buf;
- }
-#else /* CVC4_DEBUG */
- delete [] buf;
-#endif /* CVC4_DEBUG */
-}
-
-#ifdef CVC4_DEBUG
-
-/**
- * Special assertion failure handling in debug mode; in non-debug
- * builds, the exception is thrown from the macro. We factor out this
- * additional logic so as not to bloat the code at every Assert()
- * expansion.
- *
- * Note this name is prefixed with "debug" because it is included in
- * debug builds only; in debug builds, it handles all assertion
- * failures (even those that exist in non-debug builds).
- */
-void debugAssertionFailed(const AssertionException& thisException,
- const char* propagatingException) {
- static CVC4_THREADLOCAL(bool) alreadyFired = false;
-
- if(EXPECT_TRUE( !std::uncaught_exception() ) || alreadyFired) {
- throw thisException;
- }
-
- alreadyFired = true;
-
- // propagatingException is the propagating exception, but can be
- // NULL if the propagating exception is not a CVC4::Exception.
- Warning() << "===========================================" << std::endl
- << "An assertion failed during stack unwinding:" << std::endl;
- if(propagatingException != NULL) {
- Warning() << "The propagating exception is:" << std::endl
- << propagatingException << std::endl
- << "===========================================" << std::endl;
- Warning() << "The newly-thrown exception is:" << std::endl;
- } else {
- Warning() << "The propagating exception is unknown." << std::endl;
- }
- Warning() << thisException << std::endl
- << "===========================================" << std::endl;
-
- terminate();
-}
-
-#endif /* CVC4_DEBUG */
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file Assert.h
- ** \verbatim
- ** Original author: mdeters
- ** Major contributors: none
- ** Minor contributors (to current version): acsys
- ** This file is part of the CVC4 prototype.
- ** Copyright (c) 2009, 2010, 2011 The Analysis of Computer Systems Group (ACSys)
- ** Courant Institute of Mathematical Sciences
- ** New York University
- ** See the file COPYING in the top-level source directory for licensing
- ** information.\endverbatim
- **
- ** \brief Assertion utility classes, functions, exceptions, and macros.
- **
- ** Assertion utility classes, functions, exceptions, and macros.
- **/
-
-#include "cvc4_private.h"
-
-#ifndef __CVC4__ASSERT_H
-#define __CVC4__ASSERT_H
-
-#include <string>
-#include <sstream>
-#include <cstdio>
-#include <cstdlib>
-#include <cstdarg>
-
-#include "util/exception.h"
-#include "util/tls.h"
-
-// output.h not strictly needed for this header, but it _is_ needed to
-// actually _use_ anything in this header, so let's include it.
-#include "util/output.h"
-
-namespace CVC4 {
-
-class AssertionException : public Exception {
-protected:
- void construct(const char* header, const char* extra,
- const char* function, const char* file,
- unsigned line, const char* fmt, ...) {
- va_list args;
- va_start(args, fmt);
- construct(header, extra, function, file, line, fmt, args);
- va_end(args);
- }
-
- void construct(const char* header, const char* extra,
- const char* function, const char* file,
- unsigned line, const char* fmt, va_list args);
-
- void construct(const char* header, const char* extra,
- const char* function, const char* file,
- unsigned line);
-
- AssertionException() : Exception() {}
-
-public:
- AssertionException(const char* extra, const char* function,
- const char* file, unsigned line,
- const char* fmt, ...) :
- Exception() {
- va_list args;
- va_start(args, fmt);
- construct("Assertion failure", extra, function, file, line, fmt, args);
- va_end(args);
- }
-
- AssertionException(const char* extra, const char* function,
- const char* file, unsigned line) :
- Exception() {
- construct("Assertion failure", extra, function, file, line);
- }
-};/* class AssertionException */
-
-class UnreachableCodeException : public AssertionException {
-protected:
- UnreachableCodeException() : AssertionException() {}
-
-public:
- UnreachableCodeException(const char* function, const char* file,
- unsigned line, const char* fmt, ...) :
- AssertionException() {
- va_list args;
- va_start(args, fmt);
- construct("Unreachable code reached",
- NULL, function, file, line, fmt, args);
- va_end(args);
- }
-
- UnreachableCodeException(const char* function, const char* file,
- unsigned line) :
- AssertionException() {
- construct("Unreachable code reached", NULL, function, file, line);
- }
-};/* class UnreachableCodeException */
-
-class UnhandledCaseException : public UnreachableCodeException {
-protected:
- UnhandledCaseException() : UnreachableCodeException() {}
-
-public:
- UnhandledCaseException(const char* function, const char* file,
- unsigned line, const char* fmt, ...) :
- UnreachableCodeException() {
- va_list args;
- va_start(args, fmt);
- construct("Unhandled case encountered",
- NULL, function, file, line, fmt, args);
- va_end(args);
- }
-
- template <class T>
- UnhandledCaseException(const char* function, const char* file,
- unsigned line, T theCase) :
- UnreachableCodeException() {
- std::stringstream sb;
- sb << theCase;
- construct("Unhandled case encountered",
- NULL, function, file, line, "The case was: %s", sb.str().c_str());
- }
-
- UnhandledCaseException(const char* function, const char* file,
- unsigned line) :
- UnreachableCodeException() {
- construct("Unhandled case encountered", NULL, function, file, line);
- }
-};/* class UnhandledCaseException */
-
-class UnimplementedOperationException : public AssertionException {
-protected:
- UnimplementedOperationException() : AssertionException() {}
-
-public:
- UnimplementedOperationException(const char* function, const char* file,
- unsigned line, const char* fmt, ...) :
- AssertionException() {
- va_list args;
- va_start(args, fmt);
- construct("Unimplemented code encountered",
- NULL, function, file, line, fmt, args);
- va_end(args);
- }
-
- UnimplementedOperationException(const char* function, const char* file,
- unsigned line) :
- AssertionException() {
- construct("Unimplemented code encountered", NULL, function, file, line);
- }
-};/* class UnimplementedOperationException */
-
-class AssertArgumentException : public AssertionException {
-protected:
- AssertArgumentException() : AssertionException() {}
-
-public:
- AssertArgumentException(const char* argDesc, const char* function,
- const char* file, unsigned line,
- const char* fmt, ...) :
- AssertionException() {
- va_list args;
- va_start(args, fmt);
- construct("Illegal argument detected",
- ( std::string("`") + argDesc + "' is a bad argument" ).c_str(),
- function, file, line, fmt, args);
- va_end(args);
- }
-
- AssertArgumentException(const char* argDesc, const char* function,
- const char* file, unsigned line) :
- AssertionException() {
- construct("Illegal argument detected",
- ( std::string("`") + argDesc + "' is a bad argument" ).c_str(),
- function, file, line);
- }
-
- AssertArgumentException(const char* condStr, const char* argDesc,
- const char* function, const char* file,
- unsigned line, const char* fmt, ...) :
- AssertionException() {
- va_list args;
- va_start(args, fmt);
- construct("Illegal argument detected",
- ( std::string("`") + argDesc + "' is a bad argument; expected " +
- condStr + " to hold" ).c_str(),
- function, file, line, fmt, args);
- va_end(args);
- }
-
- AssertArgumentException(const char* condStr, const char* argDesc,
- const char* function, const char* file,
- unsigned line) :
- AssertionException() {
- construct("Illegal argument detected",
- ( std::string("`") + argDesc + "' is a bad argument; expected " +
- condStr + " to hold" ).c_str(),
- function, file, line);
- }
-};/* class AssertArgumentException */
-
-class InternalErrorException : public AssertionException {
-protected:
- InternalErrorException() : AssertionException() {}
-
-public:
- InternalErrorException(const char* function, const char* file, unsigned line) :
- AssertionException() {
- construct("Internal error detected", "",
- function, file, line);
- }
-
- InternalErrorException(const char* function, const char* file, unsigned line,
- const char* fmt, ...) :
- AssertionException() {
- va_list args;
- va_start(args, fmt);
- construct("Internal error detected", "",
- function, file, line, fmt, args);
- va_end(args);
- }
-
- InternalErrorException(const char* function, const char* file, unsigned line,
- std::string fmt, ...) :
- AssertionException() {
- va_list args;
- va_start(args, fmt);
- construct("Internal error detected", "",
- function, file, line, fmt.c_str(), args);
- va_end(args);
- }
-
-};/* class InternalErrorException */
-
-#ifdef CVC4_DEBUG
-
-extern CVC4_THREADLOCAL(const char*) s_debugLastException;
-
-/**
- * Special assertion failure handling in debug mode; in non-debug
- * builds, the exception is thrown from the macro. We factor out this
- * additional logic so as not to bloat the code at every Assert()
- * expansion.
- *
- * Note this name is prefixed with "debug" because it is included in
- * debug builds only; in debug builds, it handles all assertion
- * failures (even those that exist in non-debug builds).
- */
-void debugAssertionFailed(const AssertionException& thisException, const char* lastException);
-
-// If we're currently handling an exception, print a warning instead;
-// otherwise std::terminate() is called by the runtime and we lose
-// details of the exception
-# define AlwaysAssert(cond, msg...) \
- do { \
- if(EXPECT_FALSE( ! (cond) )) { \
- /* save the last assertion failure */ \
- const char* lastException = ::CVC4::s_debugLastException; \
- ::CVC4::AssertionException exception(#cond, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg); \
- ::CVC4::debugAssertionFailed(exception, lastException); \
- } \
- } while(0)
-
-#else /* CVC4_DEBUG */
-// These simpler (but less useful) versions for non-debug builds fails
-// will terminate() if thrown during stack unwinding.
-# define AlwaysAssert(cond, msg...) \
- do { \
- if(EXPECT_FALSE( ! (cond) )) { \
- throw ::CVC4::AssertionException(#cond, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg); \
- } \
- } while(0)
-#endif /* CVC4_DEBUG */
-
-#define Unreachable(msg...) \
- throw ::CVC4::UnreachableCodeException(__PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg)
-#define Unhandled(msg...) \
- throw ::CVC4::UnhandledCaseException(__PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg)
-#define Unimplemented(msg...) \
- throw ::CVC4::UnimplementedOperationException(__PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg)
-#define InternalError(msg...) \
- throw ::CVC4::InternalErrorException(__PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg)
-#define IllegalArgument(arg, msg...) \
- throw ::CVC4::IllegalArgumentException("", #arg, __PRETTY_FUNCTION__, ## msg)
-#define CheckArgument(cond, arg, msg...) \
- do { \
- if(EXPECT_FALSE( ! (cond) )) { \
- throw ::CVC4::IllegalArgumentException(#cond, #arg, __PRETTY_FUNCTION__, ## msg); \
- } \
- } while(0)
-#define AlwaysAssertArgument(cond, arg, msg...) \
- do { \
- if(EXPECT_FALSE( ! (cond) )) { \
- throw ::CVC4::AssertArgumentException(#cond, #arg, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg); \
- } \
- } while(0)
-
-#ifdef CVC4_ASSERTIONS
-# define Assert(cond, msg...) AlwaysAssert(cond, ## msg)
-# define AssertArgument(cond, arg, msg...) AlwaysAssertArgument(cond, arg, ## msg)
-# define DebugCheckArgument(cond, arg, msg...) CheckArgument(cond, arg, ## msg)
-#else /* ! CVC4_ASSERTIONS */
-# define Assert(cond, msg...) /*EXPECT_TRUE( cond )*/
-# define AssertArgument(cond, arg, msg...) /*EXPECT_TRUE( cond )*/
-# define DebugCheckArgument(cond, arg, msg...) /*EXPECT_TRUE( cond )*/
-#endif /* CVC4_ASSERTIONS */
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__ASSERT_H */
+++ /dev/null
-%{
-#include "util/Assert.h"
-%}
-
-%rename(CVC4IllegalArgumentException) CVC4::IllegalArgumentException;
-%ignore CVC4::InternalErrorException::InternalErrorException(const char*, const char*, unsigned, const char*, ...);
-
-%include "util/Assert.h"
# configured at the time of the "make dist", which (1) may not be the
# configuration that the user wants, and (2) might cause link errors.
libutil_la_SOURCES = \
- Assert.h \
- Assert.cpp \
+ cvc4_assert.h \
+ cvc4_assert.cpp \
backtrackable.h \
Makefile.am \
Makefile.in \
#include <algorithm>
#include "expr/node.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
namespace CVC4 {
--- /dev/null
+/********************* */
+/*! \file Assert.cpp
+ ** \verbatim
+ ** Original author: mdeters
+ ** Major contributors: none
+ ** Minor contributors (to current version): acsys
+ ** This file is part of the CVC4 prototype.
+ ** Copyright (c) 2009, 2010, 2011 The Analysis of Computer Systems Group (ACSys)
+ ** Courant Institute of Mathematical Sciences
+ ** New York University
+ ** See the file COPYING in the top-level source directory for licensing
+ ** information.\endverbatim
+ **
+ ** \brief Assertion utility classes, functions, and exceptions.
+ **
+ ** Assertion utility classes, functions, and exceptions. Implementation.
+ **/
+
+#include <new>
+#include <cstdarg>
+#include <cstdio>
+
+#include "util/cvc4_assert.h"
+
+using namespace std;
+
+namespace CVC4 {
+
+#ifdef CVC4_DEBUG
+CVC4_THREADLOCAL(const char*) s_debugLastException = NULL;
+#endif /* CVC4_DEBUG */
+
+void AssertionException::construct(const char* header, const char* extra,
+ const char* function, const char* file,
+ unsigned line, const char* fmt,
+ va_list args) {
+ // try building the exception msg with a smallish buffer first,
+ // then with a larger one if sprintf tells us to.
+ int n = 512;
+ char* buf;
+
+ for(;;) {
+ buf = new char[n];
+
+ int size;
+ if(extra == NULL) {
+ size = snprintf(buf, n, "%s\n%s\n%s:%d\n",
+ header, function, file, line);
+ } else {
+ size = snprintf(buf, n, "%s\n%s\n%s:%d:\n\n %s\n",
+ header, function, file, line, extra);
+ }
+
+ if(size < n) {
+ va_list args_copy;
+ va_copy(args_copy, args);
+ size += vsnprintf(buf + size, n - size, fmt, args_copy);
+ va_end(args_copy);
+
+ if(size < n) {
+ break;
+ }
+ }
+
+ if(size >= n) {
+ // try again with a buffer that's large enough
+ n = size + 1;
+ delete [] buf;
+ }
+ }
+
+ setMessage(string(buf));
+
+#ifdef CVC4_DEBUG
+ if(s_debugLastException == NULL) {
+ // we leak buf[] but only in debug mode with assertions failing
+ s_debugLastException = buf;
+ }
+#else /* CVC4_DEBUG */
+ delete [] buf;
+#endif /* CVC4_DEBUG */
+}
+
+void AssertionException::construct(const char* header, const char* extra,
+ const char* function, const char* file,
+ unsigned line) {
+ // try building the exception msg with a smallish buffer first,
+ // then with a larger one if sprintf tells us to.
+ int n = 256;
+ char* buf;
+
+ for(;;) {
+ buf = new char[n];
+
+ int size;
+ if(extra == NULL) {
+ size = snprintf(buf, n, "%s.\n%s\n%s:%d\n",
+ header, function, file, line);
+ } else {
+ size = snprintf(buf, n, "%s.\n%s\n%s:%d:\n\n %s\n",
+ header, function, file, line, extra);
+ }
+
+ if(size < n) {
+ break;
+ } else {
+ // try again with a buffer that's large enough
+ n = size + 1;
+ delete [] buf;
+ }
+ }
+
+ setMessage(string(buf));
+
+#ifdef CVC4_DEBUG
+ // we leak buf[] but only in debug mode with assertions failing
+ if(s_debugLastException == NULL) {
+ s_debugLastException = buf;
+ }
+#else /* CVC4_DEBUG */
+ delete [] buf;
+#endif /* CVC4_DEBUG */
+}
+
+#ifdef CVC4_DEBUG
+
+/**
+ * Special assertion failure handling in debug mode; in non-debug
+ * builds, the exception is thrown from the macro. We factor out this
+ * additional logic so as not to bloat the code at every Assert()
+ * expansion.
+ *
+ * Note this name is prefixed with "debug" because it is included in
+ * debug builds only; in debug builds, it handles all assertion
+ * failures (even those that exist in non-debug builds).
+ */
+void debugAssertionFailed(const AssertionException& thisException,
+ const char* propagatingException) {
+ static CVC4_THREADLOCAL(bool) alreadyFired = false;
+
+ if(EXPECT_TRUE( !std::uncaught_exception() ) || alreadyFired) {
+ throw thisException;
+ }
+
+ alreadyFired = true;
+
+ // propagatingException is the propagating exception, but can be
+ // NULL if the propagating exception is not a CVC4::Exception.
+ Warning() << "===========================================" << std::endl
+ << "An assertion failed during stack unwinding:" << std::endl;
+ if(propagatingException != NULL) {
+ Warning() << "The propagating exception is:" << std::endl
+ << propagatingException << std::endl
+ << "===========================================" << std::endl;
+ Warning() << "The newly-thrown exception is:" << std::endl;
+ } else {
+ Warning() << "The propagating exception is unknown." << std::endl;
+ }
+ Warning() << thisException << std::endl
+ << "===========================================" << std::endl;
+
+ terminate();
+}
+
+#endif /* CVC4_DEBUG */
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file Assert.h
+ ** \verbatim
+ ** Original author: mdeters
+ ** Major contributors: none
+ ** Minor contributors (to current version): acsys
+ ** This file is part of the CVC4 prototype.
+ ** Copyright (c) 2009, 2010, 2011 The Analysis of Computer Systems Group (ACSys)
+ ** Courant Institute of Mathematical Sciences
+ ** New York University
+ ** See the file COPYING in the top-level source directory for licensing
+ ** information.\endverbatim
+ **
+ ** \brief Assertion utility classes, functions, exceptions, and macros.
+ **
+ ** Assertion utility classes, functions, exceptions, and macros.
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef __CVC4__ASSERT_H
+#define __CVC4__ASSERT_H
+
+#include <string>
+#include <sstream>
+#include <cstdio>
+#include <cstdlib>
+#include <cstdarg>
+
+#include "util/exception.h"
+#include "util/tls.h"
+
+// output.h not strictly needed for this header, but it _is_ needed to
+// actually _use_ anything in this header, so let's include it.
+#include "util/output.h"
+
+namespace CVC4 {
+
+class AssertionException : public Exception {
+protected:
+ void construct(const char* header, const char* extra,
+ const char* function, const char* file,
+ unsigned line, const char* fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ construct(header, extra, function, file, line, fmt, args);
+ va_end(args);
+ }
+
+ void construct(const char* header, const char* extra,
+ const char* function, const char* file,
+ unsigned line, const char* fmt, va_list args);
+
+ void construct(const char* header, const char* extra,
+ const char* function, const char* file,
+ unsigned line);
+
+ AssertionException() : Exception() {}
+
+public:
+ AssertionException(const char* extra, const char* function,
+ const char* file, unsigned line,
+ const char* fmt, ...) :
+ Exception() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Assertion failure", extra, function, file, line, fmt, args);
+ va_end(args);
+ }
+
+ AssertionException(const char* extra, const char* function,
+ const char* file, unsigned line) :
+ Exception() {
+ construct("Assertion failure", extra, function, file, line);
+ }
+};/* class AssertionException */
+
+class UnreachableCodeException : public AssertionException {
+protected:
+ UnreachableCodeException() : AssertionException() {}
+
+public:
+ UnreachableCodeException(const char* function, const char* file,
+ unsigned line, const char* fmt, ...) :
+ AssertionException() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Unreachable code reached",
+ NULL, function, file, line, fmt, args);
+ va_end(args);
+ }
+
+ UnreachableCodeException(const char* function, const char* file,
+ unsigned line) :
+ AssertionException() {
+ construct("Unreachable code reached", NULL, function, file, line);
+ }
+};/* class UnreachableCodeException */
+
+class UnhandledCaseException : public UnreachableCodeException {
+protected:
+ UnhandledCaseException() : UnreachableCodeException() {}
+
+public:
+ UnhandledCaseException(const char* function, const char* file,
+ unsigned line, const char* fmt, ...) :
+ UnreachableCodeException() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Unhandled case encountered",
+ NULL, function, file, line, fmt, args);
+ va_end(args);
+ }
+
+ template <class T>
+ UnhandledCaseException(const char* function, const char* file,
+ unsigned line, T theCase) :
+ UnreachableCodeException() {
+ std::stringstream sb;
+ sb << theCase;
+ construct("Unhandled case encountered",
+ NULL, function, file, line, "The case was: %s", sb.str().c_str());
+ }
+
+ UnhandledCaseException(const char* function, const char* file,
+ unsigned line) :
+ UnreachableCodeException() {
+ construct("Unhandled case encountered", NULL, function, file, line);
+ }
+};/* class UnhandledCaseException */
+
+class UnimplementedOperationException : public AssertionException {
+protected:
+ UnimplementedOperationException() : AssertionException() {}
+
+public:
+ UnimplementedOperationException(const char* function, const char* file,
+ unsigned line, const char* fmt, ...) :
+ AssertionException() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Unimplemented code encountered",
+ NULL, function, file, line, fmt, args);
+ va_end(args);
+ }
+
+ UnimplementedOperationException(const char* function, const char* file,
+ unsigned line) :
+ AssertionException() {
+ construct("Unimplemented code encountered", NULL, function, file, line);
+ }
+};/* class UnimplementedOperationException */
+
+class AssertArgumentException : public AssertionException {
+protected:
+ AssertArgumentException() : AssertionException() {}
+
+public:
+ AssertArgumentException(const char* argDesc, const char* function,
+ const char* file, unsigned line,
+ const char* fmt, ...) :
+ AssertionException() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Illegal argument detected",
+ ( std::string("`") + argDesc + "' is a bad argument" ).c_str(),
+ function, file, line, fmt, args);
+ va_end(args);
+ }
+
+ AssertArgumentException(const char* argDesc, const char* function,
+ const char* file, unsigned line) :
+ AssertionException() {
+ construct("Illegal argument detected",
+ ( std::string("`") + argDesc + "' is a bad argument" ).c_str(),
+ function, file, line);
+ }
+
+ AssertArgumentException(const char* condStr, const char* argDesc,
+ const char* function, const char* file,
+ unsigned line, const char* fmt, ...) :
+ AssertionException() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Illegal argument detected",
+ ( std::string("`") + argDesc + "' is a bad argument; expected " +
+ condStr + " to hold" ).c_str(),
+ function, file, line, fmt, args);
+ va_end(args);
+ }
+
+ AssertArgumentException(const char* condStr, const char* argDesc,
+ const char* function, const char* file,
+ unsigned line) :
+ AssertionException() {
+ construct("Illegal argument detected",
+ ( std::string("`") + argDesc + "' is a bad argument; expected " +
+ condStr + " to hold" ).c_str(),
+ function, file, line);
+ }
+};/* class AssertArgumentException */
+
+class InternalErrorException : public AssertionException {
+protected:
+ InternalErrorException() : AssertionException() {}
+
+public:
+ InternalErrorException(const char* function, const char* file, unsigned line) :
+ AssertionException() {
+ construct("Internal error detected", "",
+ function, file, line);
+ }
+
+ InternalErrorException(const char* function, const char* file, unsigned line,
+ const char* fmt, ...) :
+ AssertionException() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Internal error detected", "",
+ function, file, line, fmt, args);
+ va_end(args);
+ }
+
+ InternalErrorException(const char* function, const char* file, unsigned line,
+ std::string fmt, ...) :
+ AssertionException() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Internal error detected", "",
+ function, file, line, fmt.c_str(), args);
+ va_end(args);
+ }
+
+};/* class InternalErrorException */
+
+#ifdef CVC4_DEBUG
+
+extern CVC4_THREADLOCAL(const char*) s_debugLastException;
+
+/**
+ * Special assertion failure handling in debug mode; in non-debug
+ * builds, the exception is thrown from the macro. We factor out this
+ * additional logic so as not to bloat the code at every Assert()
+ * expansion.
+ *
+ * Note this name is prefixed with "debug" because it is included in
+ * debug builds only; in debug builds, it handles all assertion
+ * failures (even those that exist in non-debug builds).
+ */
+void debugAssertionFailed(const AssertionException& thisException, const char* lastException);
+
+// If we're currently handling an exception, print a warning instead;
+// otherwise std::terminate() is called by the runtime and we lose
+// details of the exception
+# define AlwaysAssert(cond, msg...) \
+ do { \
+ if(EXPECT_FALSE( ! (cond) )) { \
+ /* save the last assertion failure */ \
+ const char* lastException = ::CVC4::s_debugLastException; \
+ ::CVC4::AssertionException exception(#cond, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg); \
+ ::CVC4::debugAssertionFailed(exception, lastException); \
+ } \
+ } while(0)
+
+#else /* CVC4_DEBUG */
+// These simpler (but less useful) versions for non-debug builds fails
+// will terminate() if thrown during stack unwinding.
+# define AlwaysAssert(cond, msg...) \
+ do { \
+ if(EXPECT_FALSE( ! (cond) )) { \
+ throw ::CVC4::AssertionException(#cond, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg); \
+ } \
+ } while(0)
+#endif /* CVC4_DEBUG */
+
+#define Unreachable(msg...) \
+ throw ::CVC4::UnreachableCodeException(__PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg)
+#define Unhandled(msg...) \
+ throw ::CVC4::UnhandledCaseException(__PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg)
+#define Unimplemented(msg...) \
+ throw ::CVC4::UnimplementedOperationException(__PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg)
+#define InternalError(msg...) \
+ throw ::CVC4::InternalErrorException(__PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg)
+#define IllegalArgument(arg, msg...) \
+ throw ::CVC4::IllegalArgumentException("", #arg, __PRETTY_FUNCTION__, ## msg)
+#define CheckArgument(cond, arg, msg...) \
+ do { \
+ if(EXPECT_FALSE( ! (cond) )) { \
+ throw ::CVC4::IllegalArgumentException(#cond, #arg, __PRETTY_FUNCTION__, ## msg); \
+ } \
+ } while(0)
+#define AlwaysAssertArgument(cond, arg, msg...) \
+ do { \
+ if(EXPECT_FALSE( ! (cond) )) { \
+ throw ::CVC4::AssertArgumentException(#cond, #arg, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg); \
+ } \
+ } while(0)
+
+#ifdef CVC4_ASSERTIONS
+# define Assert(cond, msg...) AlwaysAssert(cond, ## msg)
+# define AssertArgument(cond, arg, msg...) AlwaysAssertArgument(cond, arg, ## msg)
+# define DebugCheckArgument(cond, arg, msg...) CheckArgument(cond, arg, ## msg)
+#else /* ! CVC4_ASSERTIONS */
+# define Assert(cond, msg...) /*EXPECT_TRUE( cond )*/
+# define AssertArgument(cond, arg, msg...) /*EXPECT_TRUE( cond )*/
+# define DebugCheckArgument(cond, arg, msg...) /*EXPECT_TRUE( cond )*/
+#endif /* CVC4_ASSERTIONS */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__ASSERT_H */
--- /dev/null
+%{
+#include "util/cvc4_assert.h"
+%}
+
+%rename(CVC4IllegalArgumentException) CVC4::IllegalArgumentException;
+%ignore CVC4::InternalErrorException::InternalErrorException(const char*, const char*, unsigned, const char*, ...);
+
+%include "util/cvc4_assert.h"
#include "expr/node.h"
#include "util/recursion_breaker.h"
#include "util/matcher.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
using namespace std;
#ifndef __CVC4__UTIL__DYNAMIC_ARRAY_H
#define __CVC4__UTIL__DYNAMIC_ARRAY_H
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
namespace CVC4 {
}/* CVC4 namespace */
#if (defined(__BUILDING_CVC4LIB) || defined(__BUILDING_CVC4LIB_UNIT_TEST)) && !defined(__BUILDING_STATISTICS_FOR_EXPORT)
-# include "util/Assert.h"
+# include "util/cvc4_assert.h"
#endif /* (__BUILDING_CVC4LIB || __BUILDING_CVC4LIB_UNIT_TEST) && !__BUILDING_STATISTICS_FOR_EXPORT */
namespace CVC4 {
#include <string>
#include <vector>
#include <map>
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "expr/node.h"
#include "expr/type_node.h"
#include "expr/expr.h"
#include "util/predicate.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
using namespace std;
#include <ext/hash_set>
#include "util/hash.h"
#include "util/tls.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
namespace CVC4 {
#include <cctype>
#include "util/result.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "printer/printer.h"
using namespace std;
#include <vector>
#include "util/sexpr.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "printer/printer.h"
#include "expr/expr.h"
#include "util/trans_closure.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
using namespace std;
#include <cxxtest/TestSuite.h>
#include "context/cdhashmap.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
using namespace std;
using namespace CVC4;
#include "context/context.h"
#include "context/cdlist.h"
#include "context/cdo.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
using namespace std;
using namespace CVC4;
#include "context/context.h"
#include "context/cdlist.h"
#include "context/cdo.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
using namespace std;
using namespace CVC4;
#include "context/context.h"
#include "context/cdo.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
using namespace std;
using namespace CVC4;
#include "theory/theory.h"
#include "theory/theory_engine.h"
#include "theory/uf/theory_uf.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
using namespace CVC4;
using namespace CVC4::kind;
#include "expr/node.h"
#include "expr/kind.h"
#include "context/context.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "util/rational.h"
using namespace CVC4;
#include "expr/node_manager.h"
#include "expr/node.h"
#include "context/context.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
using namespace CVC4;
using namespace CVC4::kind;
#include "expr/expr_manager.h"
#include "expr/expr.h"
#include "expr/type.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "util/exception.h"
using namespace CVC4;
#include <sys/time.h>
#include <sys/resource.h>
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
namespace CVC4 {
namespace test {
/* #include <gmock/gmock.h> */
/* #include <gtest/gtest.h> */
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
#include "expr/expr_manager.h"
#include "expr/node_manager.h"
#include "util/rational.h"
#include "util/integer.h"
#include "options/options.h"
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
using namespace CVC4;
using namespace CVC4::theory;
#include <string>
#include <cstring>
-#include "util/Assert.h"
+#include "util/cvc4_assert.h"
using namespace CVC4;
using namespace std;