ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
clang_cpp_exception_id.cpp File Reference
Include dependency graph for clang_cpp_exception_id.cpp:

Functions

static void class_exception_ids (const namespacet &ns, const typet &type, const std::string &suffix, std::vector< irep_idt > &ids, bool is_catch)
 A class type's own id followed by its bases', most derived first, so a handler for a base catches a derived throw.
static void append_cpp_spelling_and_fallback (const typet &type, const std::string &suffix, std::vector< irep_idt > &ids)
 The C++ spelling, when the type carries one, and a last-resort id so the list is never empty: callers such as adjust_catch dereference ids.front(), and an unusual catch parameter (a function type, as in the ill-formed catch (exception())) matches none of the cases above.
void convert_exception_id (const namespacet &ns, const typet &type, const std::string &suffix, std::vector< irep_idt > &ids, bool is_catch)
 The catchable-type ids a thrown or caught type resolves to, most derived first.
bool finalize_exception_specification (const namespacet &ns, typet &type)
 Resolve a function type's dynamic exception specification.

Function Documentation

◆ append_cpp_spelling_and_fallback()

void append_cpp_spelling_and_fallback ( const typet & type,
const std::string & suffix,
std::vector< irep_idt > & ids )
static

The C++ spelling, when the type carries one, and a last-resort id so the list is never empty: callers such as adjust_catch dereference ids.front(), and an unusual catch parameter (a function type, as in the ill-formed catch (exception())) matches none of the cases above.

A synthetic id never matches a real throw, which is the intended behaviour there.

◆ class_exception_ids()

void class_exception_ids ( const namespacet & ns,
const typet & type,
const std::string & suffix,
std::vector< irep_idt > & ids,
bool is_catch )
static

A class type's own id followed by its bases', most derived first, so a handler for a base catches a derived throw.

Only a throw expands the bases: catch (Base) names one id and matches by the list the throw carries.

◆ convert_exception_id()

void convert_exception_id ( const namespacet & ns,
const typet & type,
const std::string & suffix,
std::vector< irep_idt > & ids,
bool is_catch = false )

The catchable-type ids a thrown or caught type resolves to, most derived first.

Shared rather than a member of clang_cpp_adjust because the IREP2 C++ pass needs the same answer and the function reads nothing but the namespace (docs/roadmap/scope-clang-cpp-irep2.md §3.3).

◆ finalize_exception_specification()

bool finalize_exception_specification ( const namespacet & ns,
typet & type )

Resolve a function type's dynamic exception specification.

The converter stashes the declared types of a throw(T...) under "exception_spec_decl"; this turns them into exception ids and stores the list under exception_specificationt's types_attribute(), returning whether it did. A no-op for any other kind of specification.

Shared for the same reason convert_exception_id is: the IREP2 C++ pass has to reach the same answer, and this reads nothing but the namespace. Left unresolved, the spec permits nothing and every throw through such a function reports "exception specification violated" (docs/roadmap/scope-clang-cpp-irep2.md §7.7).