[cfe-dev] C++ Language Support Library

Sebastian Redl sebastian.redl at getdesigned.at
Sun Nov 9 08:23:47 PST 2008


Hi,

Regarding the C++ language support library, there are a few issues that 
I'd like to raise. Please note that this is only about the language 
support part of the C++ standard library.

1) Which support library do we use?
There are basically two options here. We can write our own, or we can 
use libsupc++ from GCC.

Using our own:
+ No licensing issues.
+ Allows us to do what we need to do (within the limits of the common 
C++ ABI)
- We have to write it.
- We have to maintain it.
- Interoperability problems with GCC and LLVM-GCC.

Using libsupc++:
+ Perfect interoperability with GCC and LLVM-GCC.
+ No need to write our own.
- May not fit our needs.
- Is GPL-licensed.


This decision isn't very pressing, since we only need to make it when we 
seriously start implementing C++ CodeGen, and we're far from that still.


2) How do we access its types?
The types from the support library are accessed within Sema - play a 
crucial role in some situations, even. There needs to be a nice 
interface to declare and access these types. The C support types - 
ptrdiff_t, size_t, etc. - are simply present in the ASTContext, always. 
With the C++ types, this may be considered a waste.

Here's a summary of which parts of the language use which types (may be 
incomplete):

a) typeid: Uses std::type_info as the return value, may throw 
std::bad_typeid. The exception type isn't necessarily accessed within 
the Sema; type_info most definitely is.
b) dynamic_cast: May throw bad_cast. Not necessarily accessed within the 
Sema.
c) new: Uses operator new and operator delete. May throw std::bad_alloc. 
None of these is necessarily used in Sema, but they will be needed 
during CodeGen.
d) Exceptions: exceptions use std::bad_exception, std::terminate, 
std::unexpected and more. Accessed by CodeGen, if not Sema.
e) Globals: Destructors for globals and statics are registered with 
atexit() or __cxa_atexit(). CodeGen would generate these calls.

C++0x adds some more:
f) Initializer lists: use std::initializer_list, which uses the 
ObjectType concept. Required in Sema for overload resolution.
g) Null pointers: use std::nullptr_t. This special type is considered 
fundamental and even participates in implicit conversions.
h) Range loop: uses the std::Range concept.

Concepts in general are very pervasive throughout C++0x.

The question of access is pressing. My typeid implementation doesn't 
work correctly without it.

Sebastian



More information about the cfe-dev mailing list