mirror of
https://github.com/Z3Prover/z3
synced 2025-04-29 03:45:51 +00:00
fix a few warnings & simplify debug.h header
This commit is contained in:
parent
a97bc65af4
commit
d8cea7c8d5
6 changed files with 24 additions and 56 deletions
|
@ -36,13 +36,13 @@ bool assertions_enabled() {
|
|||
}
|
||||
|
||||
void notify_assertion_violation(const char * fileName, int line, const char * condition) {
|
||||
std::cerr << "ASSERTION VIOLATION\n";
|
||||
std::cerr << "File: " << fileName << "\n";
|
||||
std::cerr << "Line: " << line << "\n";
|
||||
std::cerr << condition << "\n";
|
||||
std::cerr << "ASSERTION VIOLATION\n"
|
||||
"File: " << fileName << "\n"
|
||||
"Line: " << line << '\n'
|
||||
<< condition << '\n';
|
||||
#ifndef Z3DEBUG
|
||||
std::cerr << Z3_FULL_VERSION << "\n";
|
||||
std::cerr << "Please file an issue with this message and more detail about how you encountered it at https://github.com/Z3Prover/z3/issues/new\n";
|
||||
std::cerr << Z3_FULL_VERSION "\n"
|
||||
"Please file an issue with this message and more detail about how you encountered it at https://github.com/Z3Prover/z3/issues/new\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -16,25 +16,13 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef DEBUG_H_
|
||||
#define DEBUG_H_
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void enable_assertions(bool f);
|
||||
bool assertions_enabled();
|
||||
|
||||
#if 0
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include<stdlib.h>
|
||||
#include<new>
|
||||
#include<crtdbg.h>
|
||||
#endif
|
||||
|
||||
#ifndef __has_builtin
|
||||
# define __has_builtin(x) 0
|
||||
#endif
|
||||
|
||||
#include "util/error_codes.h"
|
||||
#include "util/warning.h"
|
||||
|
||||
|
@ -75,44 +63,27 @@ bool is_debug_enabled(const char * tag);
|
|||
#define CASSERT(TAG, COND) DEBUG_CODE(if (assertions_enabled() && is_debug_enabled(TAG) && !(COND)) { notify_assertion_violation(__FILE__, __LINE__, #COND); INVOKE_DEBUGGER(); })
|
||||
#define XASSERT(COND, EXTRA_CODE) DEBUG_CODE(if (assertions_enabled() && !(COND)) { notify_assertion_violation(__FILE__, __LINE__, #COND); { EXTRA_CODE } INVOKE_DEBUGGER(); })
|
||||
|
||||
/**
|
||||
We use __builtin_unreachable where possible to suppress control flow compilation warnings, but it should
|
||||
not be called because its behavior is undefined, so we do need to exit before "calling" it.
|
||||
*/
|
||||
#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 405)) || __has_builtin(__builtin_unreachable)
|
||||
# define EXIT_WITH(ERR_CODE) { exit(ERR_CODE); __builtin_unreachable(); } ((void) 0)
|
||||
#else
|
||||
# define EXIT_WITH(ERR_CODE) { exit(ERR_CODE); } ((void) 0)
|
||||
#endif
|
||||
|
||||
#ifdef Z3DEBUG
|
||||
# define UNREACHABLE() DEBUG_CODE(notify_assertion_violation(__FILE__, __LINE__, "UNREACHABLE CODE WAS REACHED."); INVOKE_DEBUGGER();)
|
||||
#else
|
||||
# define UNREACHABLE() { notify_assertion_violation(__FILE__, __LINE__, "UNREACHABLE CODE WAS REACHED."); EXIT_WITH(ERR_UNREACHABLE); } ((void) 0)
|
||||
# define UNREACHABLE() { notify_assertion_violation(__FILE__, __LINE__, "UNREACHABLE CODE WAS REACHED."); exit(ERR_UNREACHABLE); } ((void) 0)
|
||||
#endif
|
||||
|
||||
#ifdef Z3DEBUG
|
||||
# define NOT_IMPLEMENTED_YET() DEBUG_CODE(notify_assertion_violation(__FILE__, __LINE__, "NOT IMPLEMENTED YET!"); INVOKE_DEBUGGER();)
|
||||
#else
|
||||
# define NOT_IMPLEMENTED_YET() { notify_assertion_violation(__FILE__, __LINE__, "NOT IMPLEMENTED YET!"); EXIT_WITH(ERR_NOT_IMPLEMENTED_YET); } ((void) 0)
|
||||
# define NOT_IMPLEMENTED_YET() { notify_assertion_violation(__FILE__, __LINE__, "NOT IMPLEMENTED YET!"); exit(ERR_NOT_IMPLEMENTED_YET); } ((void) 0)
|
||||
#endif
|
||||
|
||||
#define VERIFY(_x_) if (!(_x_)) { \
|
||||
std::cerr << "Failed to verify: " << #_x_ << "\n"; \
|
||||
UNREACHABLE(); \
|
||||
#define VERIFY(_x_) if (!(_x_)) { \
|
||||
notify_assertion_violation(__FILE__, __LINE__, "Failed to verify: " #_x_ "\n"); \
|
||||
exit(ERR_UNREACHABLE); \
|
||||
}
|
||||
|
||||
#define ENSURE(_x_) \
|
||||
if (!(_x_)) { \
|
||||
std::cerr << "Failed to verify: " << #_x_ << "\n"; \
|
||||
exit(-1); \
|
||||
}
|
||||
#define ENSURE(_x_) VERIFY(_x_)
|
||||
|
||||
|
||||
void finalize_debug();
|
||||
/*
|
||||
ADD_FINALIZER('finalize_debug();')
|
||||
*/
|
||||
|
||||
#endif /* DEBUG_H_ */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue