Skip to content
  • Alessandro Di Federico's avatar
    a0f4e0bb
    Introduce new assertion framework · a0f4e0bb
    Alessandro Di Federico authored
    A set of assertion-related functions has been introduced:
    
    * `revng_abort(message)`: aborts, in release builds too.
    * `revng_check(what, message)`: asserts `what`, in release builds
      too. Also emits a `__builtin_assume`, that can lead to additional
      optimizations in clang.
    * `revng_unreahcable(message)`: identical to `revng_abort`, but in
      release builds emits `__built_unreachable`.
    * `revng_assert(what, message)`: asserts in debug builds, otherwise
      emits `sizeof(what)` (to suppress unused variable warnings) and
      `__builtin_assume`.
    
    The adoption of these function has the following benefits:
    
    * Nice stack traces.
    * The developer can choose to enforce an `assert` (or an `unreachable`)
      at release-time too by using `check`/`abort`.
    * Most warnings about unused variables in release mode should be gone.
    * When using clang, the `assert`s become `assume`s, which might enable
      additional optimizations (with no run-time costs).
    * The `assert(Condition && "Reason")` trick is no longer needed, we now
      have a proper argument.
    a0f4e0bb
    Introduce new assertion framework
    Alessandro Di Federico authored
    A set of assertion-related functions has been introduced:
    
    * `revng_abort(message)`: aborts, in release builds too.
    * `revng_check(what, message)`: asserts `what`, in release builds
      too. Also emits a `__builtin_assume`, that can lead to additional
      optimizations in clang.
    * `revng_unreahcable(message)`: identical to `revng_abort`, but in
      release builds emits `__built_unreachable`.
    * `revng_assert(what, message)`: asserts in debug builds, otherwise
      emits `sizeof(what)` (to suppress unused variable warnings) and
      `__builtin_assume`.
    
    The adoption of these function has the following benefits:
    
    * Nice stack traces.
    * The developer can choose to enforce an `assert` (or an `unreachable`)
      at release-time too by using `check`/`abort`.
    * Most warnings about unused variables in release mode should be gone.
    * When using clang, the `assert`s become `assume`s, which might enable
      additional optimizations (with no run-time costs).
    * The `assert(Condition && "Reason")` trick is no longer needed, we now
      have a proper argument.
Loading