Commit graph

14 commits

Author SHA1 Message Date
Iain Buclaw
6374bb87b7 Move dmd files into compiler/ 2022-07-09 18:53:07 +02:00
MoonlightSentinel
15ecd8c351 Fix 22954 - dtoh: Ignore member functions with C linkage
Those functions receive D mangling and hence aren't easily callable via
the header file. Note that C++ does the same for members in an
`extern "C"` aggregate (=> mangle as C++ symbol).
`
2022-03-29 11:00:58 +00:00
MoonlightSentinel
3b20c1da54 Fix 22951 - Emit non-extern (C++) destructors as private members
Destructors not marked as `extern (C++)` aren't accessible from C++
due to the D name mangling. The header generator used to skip `extern(D)`
destructors, allowing C++ code that violated RAII guarantees.

Declaring the constructors as `private` members ensures that any
instance that would need to be destroyed on the C++ side causes a
compiler error (rather than a linker error due to missmatched mangling).

Renamed the helper function `checkVirtualFunction` because it now also
handles other types of functions.
2022-03-29 07:58:23 +00:00
MoonlightSentinel
315abda741 Issue 21941 - Extend the list of reserved words for dtoh
Adds several entries regarding C(++) keywords, extensions and default
macros provided by gcc and clang. Also rejects all identifiers starting
with __ because those are reserved by C++ compilers

Doesn't "fix" the issue because the list is confined to common keywords
and not an exhaustive list of all possible extensions.
2021-07-01 16:55:00 +00:00
MoonlightSentinel
b40c9bc282 Fix 21530 - dtoh: Sanitize identifiers wrt. reserved C++ keywords
Extends the check for C++ keywords to append an underscore instead of
raising an error whenever the actual name doesn't matter for binary
compatibility.
2021-01-14 23:42:00 +01:00
MoonlightSentinel
ecce5075cb dtoh: Emit immutable as const instead of mutable
`Type.isConst` is false for immutable symbols, so we need to check
`isImmutable`as well.

Note that `inout` is currently mangled as mutable, so we can't rely on
`!Type.isMutable`.
2020-11-13 02:31:18 +01:00
MoonlightSentinel
3a426c842a
dtoh: Provide operator[] for _d_dynamicArray ...
... s.t. it can be used like a normal array (+ bounds checking)
2020-10-26 09:33:05 +01:00
MoonlightSentinel
aeb3dbd1f4
dtoh: Emit _d_dynamicArray template which represents slices
Since slices are a central building block of D, they should also be
easily accessible from C++.
2020-10-26 09:32:50 +01:00
MoonlightSentinel
64198f34d7
dtoh: Emit template aliases as templated using declaration
Instead of simply skipping the declaration
2020-10-23 10:25:26 +02:00
MoonlightSentinel
2e9015871a
Fix 21271: Emit placeholders for skipped virtual functions (dtoh)
This ensures proper vtable layout for classes which
have extern(D) functions
2020-10-18 17:09:51 +02:00
MoonlightSentinel
9bf41e9477 dtoh: Support tuple members/parameters/variables
Emit all tuple members into the header file instead of
causing an assertion failure
2020-09-28 13:29:40 +02:00
Iain Buclaw
eb8c3f5fe8 dtoh: Remove ENUM macros, always use enum class for numeric enums 2020-09-12 14:39:52 +02:00
Manu Evans
32bb6b401a Populate the header only when it's actually used. 2020-02-24 00:25:37 -08:00
MoonlightSentinel
d0d5f08960
Address wilzbach's review
- Remove leftover comment
- Guard against multiple initializations
- Add a dshell test
2020-02-21 11:44:54 +01:00