10ecad19103c21a5b3d8cad2e26ac0be7fce5272
1 /********************* */
4 ** Top contributors (to current version):
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS
8 ** in the top-level source directory) and their institutional affiliations.
9 ** All rights reserved. See the file COPYING in the top-level source
10 ** directory for licensing information.\endverbatim
12 ** \brief Assertion utility classes, functions and macros.
14 ** Implementation of assertion utility classes, functions and macros.
17 #include "base/check.h"
24 FatalStream::FatalStream(const char* function
, const char* file
, int line
)
26 stream() << "Fatal failure within " << function
<< " at " << file
<< ":"
30 FatalStream::~FatalStream()
36 std::ostream
& FatalStream::stream() { return std::cerr
; }
38 void FatalStream::Flush()
40 stream() << std::endl
;
44 void AssertArgumentException::construct(const char* header
,
52 // try building the exception msg with a smallish buffer first,
53 // then with a larger one if sprintf tells us to.
63 size
= snprintf(buf
, n
, "%s\n%s\n%s:%d\n", header
, function
, file
, line
);
69 "%s\n%s\n%s:%d:\n\n %s\n",
80 va_copy(args_copy
, args
);
81 size
+= vsnprintf(buf
+ size
, n
- size
, fmt
, args_copy
);
92 // try again with a buffer that's large enough
99 setMessage(std::string(buf
));
102 LastExceptionBuffer
* buffer
= LastExceptionBuffer::getCurrent();
105 if (buffer
->getContents() == NULL
)
107 buffer
->setContents(buf
);
110 #endif /* CVC4_DEBUG */
114 void AssertArgumentException::construct(const char* header
,
116 const char* function
,
120 // try building the exception msg with a smallish buffer first,
121 // then with a larger one if sprintf tells us to.
132 size
= snprintf(buf
, n
, "%s.\n%s\n%s:%d\n", header
, function
, file
, line
);
138 "%s.\n%s\n%s:%d:\n\n %s\n",
152 // try again with a buffer that's large enough
158 setMessage(std::string(buf
));
161 LastExceptionBuffer
* buffer
= LastExceptionBuffer::getCurrent();
164 if (buffer
->getContents() == NULL
)
166 buffer
->setContents(buf
);
169 #endif /* CVC4_DEBUG */
173 AssertArgumentException::AssertArgumentException(const char* condStr
,
175 const char* function
,
184 construct("Illegal argument detected",
185 (std::string("`") + argDesc
+ "' is a bad argument; expected "
186 + condStr
+ " to hold")
196 AssertArgumentException::AssertArgumentException(const char* condStr
,
198 const char* function
,
203 construct("Illegal argument detected",
204 (std::string("`") + argDesc
+ "' is a bad argument; expected "
205 + condStr
+ " to hold")