llvm / llvm/llvm-project

Missing clarity/example on how to reference `std::type_info` / RTTI symbols for `__cxa_throw`

Open
#204,433 1 comment 0 reactions 0 assignees View on GitHub
c++ documentation question
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

In the documentation [https://llvm.org/docs/ExceptionHandling.html](url) it is said to use `__cxa_throw` to throw an exeption.

> Languages that support exception handling typically provide a throw operation to initiate the exception process. Internally, a throw operation breaks down into two steps.
A request is made to allocate exception space for an exception structure. This structure needs to survive beyond the current activation. This structure will contain the type and value of the object being thrown.
A call is made to the runtime to raise the exception, passing the exception structure as an argument.
In C++, the allocation of the exception structure is done by the __cxa_allocate_exception runtime function. The exception raising is handled by __cxa_throw. The type of the exception is represented using a C++ RTTI structure.

However, it is unclear how to emit or reference std::type_info structures without hardcoding target-specific layouts inside the `.ll`.

Contributor guide

Open the contributing guide

Research direction

Start with the ExceptionHandling documentation page and its discussion of __cxa_throw and C++ RTTI. Clarify how LLVM IR should emit or reference std::type_info without target-specific layouts, including a concrete example; done means a reader can follow the documented approach.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.