ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
exception_specificationt Class Reference

Canonical, function-boundary C++ exception specification. More...

#include <exception_specification.h>

Public Types

enum class  kindt { potentially_throwing , non_throwing , dynamic }

Public Member Functions

 exception_specificationt ()
bool is_restrictive () const
 A restrictive spec can be violated at the function boundary.

Static Public Member Functions

static exception_specificationt from_type (const typet &type)
 Decode the specification stored on a function typet.
static const char * kind_attribute ()
 Names of the named-sub attributes used on the typet.
static const char * types_attribute ()

Public Attributes

kindt kind
std::vector< irep_idt > allowed_types

Detailed Description

Canonical, function-boundary C++ exception specification.

A C++ exception specification is a property of a function's boundary, not of any region of its body. It is violated only when exception handler search exits the function body with an exception the specification does not permit. This replaces the old executable THROW_DECL/THROW_DECL_END GOTO instructions, whose enforcement incorrectly depended on the nearest active try/catch region rather than the function frame.

The canonical representation lives on the function symbol's (legacy) typet as named-sub attributes so it survives GOTO-binary serialization and is available for declarations without bodies. goto_functiont caches a decoded copy for convenient executable access during symbolic execution.

Member Enumeration Documentation

◆ kindt

Enumerator
potentially_throwing 

No specification (or an explicitly throwing one): may throw anything.

non_throwing 

C++11 noexcept (or noexcept(true)): violation calls std::terminate.

dynamic 

Legacy dynamic spec throw(T...) (incl.

empty throw()): violation calls std::unexpected. allowed_types lists the permitted exception type ids (matching the ids produced by clang_cpp_adjust's convert_exception_id); empty means nothing may escape.

Constructor & Destructor Documentation

◆ exception_specificationt()

exception_specificationt::exception_specificationt ( )
inline

Member Function Documentation

◆ from_type()

exception_specificationt exception_specificationt::from_type ( const typet & type)
static

Decode the specification stored on a function typet.

Returns a default (potentially_throwing) spec when no metadata is present.

◆ is_restrictive()

bool exception_specificationt::is_restrictive ( ) const
inline

A restrictive spec can be violated at the function boundary.

Plain potentially-throwing functions never violate their spec.

◆ kind_attribute()

const char * exception_specificationt::kind_attribute ( )
inlinestatic

Names of the named-sub attributes used on the typet.

◆ types_attribute()

const char * exception_specificationt::types_attribute ( )
inlinestatic

Member Data Documentation

◆ allowed_types

std::vector<irep_idt> exception_specificationt::allowed_types

◆ kind

kindt exception_specificationt::kind

The documentation for this class was generated from the following files: