Files
revng-revng/lib/Support/Assert.cpp
T
Alessandro Di Federico 076aeac7f3 Move and rename all files
This commit moves around most files. The new directory structure is as
follows:

* `lib/$LIBRARY/`: contains a library, i.e., a set of `.cpp` files used
  by multiple libraries/tools.
* `include/revng/$LIBRARY/`: contains the public headers associated to
  the library in `lib/$LIBRARY/`.
* `tools/$TOOL/`: directory where all the `.cpp` files (and private
  headers) for a tool reside. Currently we have two tools: `revamb` and
  `revamb-dump`.

On top of this, all file names are now in camel case.
2018-10-03 23:11:12 +02:00

53 lines
1.3 KiB
C++

/// \file revng-assert.cpp
/// \brief Implementation of the various functions to assert and abort.
// Standard includes
#include <cassert>
#include <iostream>
// LLVM includes
#include "llvm/Support/Signals.h"
#include "llvm/Support/raw_os_ostream.h"
// Local libraries includes
#include "revng/Support/Assert.h"
static void print_stack_trace() {
llvm::raw_os_ostream Output(std::cout);
std::cout << "\n";
llvm::sys::PrintStackTrace(Output);
}
[[noreturn]] static void terminate(void) {
print_stack_trace();
abort();
}
static void
report(const char *Type, const char *File, unsigned Line, const char *What) {
fprintf(stderr, "%s at %s:%d: %s\n", Type, File, Line, What);
}
void revng_assert_fail(const char *AssertionBody,
const char *Message,
const char *File,
unsigned Line) {
report("Assertion failed", File, Line, Message);
fprintf(stderr, "%s\n", AssertionBody);
terminate();
}
void revng_check_fail(const char *CheckBody,
const char *Message,
const char *File,
unsigned Line) {
report("Check failed", File, Line, Message);
fprintf(stderr, "%s\n", CheckBody);
terminate();
}
void revng_do_abort(const char *Message, const char *File, unsigned Line) {
report("Abort", File, Line, Message);
terminate();
}