Commit graph

242 commits

Author SHA1 Message Date
Martin Kinkelin
b3b06d0cc7 Replace LDC-specific VarDeclaration.scopeClassType by .onstackWithDtor
This doesn't increase the VarDeclaration size.
2019-04-13 20:34:16 +02:00
Martin Kinkelin
5e93ed0dfd Upgrade front-end & libs to v2.085.0-beta.1 2019-03-01 18:19:00 +01:00
Martin Kinkelin
ab38d73b26 Fix alignment of scope-allocated class instances
I noticed that an `align(N) class ...` seems to be totally ignored; i.e.,
it has no effect on `Type::alignment()` and neither on
`ClassDeclaration::alignsize()`.

I checked the paddings too (and the tests cover them as well); they seem
fine already, both inbetween header and payload (and for both D and C++
classes, the latter missing the monitor field) as well as inbetween base
payload and derived payload.
2018-11-19 21:50:40 +01:00
Martin Kinkelin
4a23399236 Aim for consistent #includes (order + dir prefix)
I surely missed a few.
2018-10-20 16:19:46 +02:00
Martin Kinkelin
7776c4081b Upgrade frontend & libs to v2.083.0-beta.1 2018-10-20 16:19:46 +02:00
Martin Kinkelin
267ffbb645
Posix: Fix C++ class construction with D new (#2801) 2018-08-31 16:37:24 +02:00
Martin Kinkelin
40cf784cbe Misc. merge fixes, minor adaptions 2018-08-17 21:31:53 +02:00
Martin Kinkelin
494bc8b1e4
Add some support for classes without TypeInfos (#2765)
For -betterC and/or a minimal object.d without TypeInfo:

* Skip TypeInfo emission for classes and interfaces.
* Emit null as first vtable member.

Makes dmd-testsuite's {compilable,runnable}/minimal2.d work.
2018-07-10 17:56:05 +02:00
Martin Kinkelin
7dbd07dd1e Use new extern(D) dtor shims for struct/class TypeInfos
The TypeInfo may need an extern(D) wrapper accounting for ABI
differences wrt. extern(C++) dtor implementations.

This fixes `runnable/cppa.d` for 32-bit x86 targets.
2018-06-23 19:31:43 +02:00
Martin
e337cec78a Slightly refactor RTTIBuilder 2018-04-04 19:59:10 +02:00
Martin
9ff736bf0f Lookup runtime function before constructing the call args
To retain the LoC information in case TypeInfo declarations are missing.
2018-04-04 19:59:10 +02:00
Martin
d8f60d2f5c Redirect access to object.d type declarations through gen/runtime
Not all type declarations yet (e.g., some TypeInfo subtypes are still
accessed directly), but those already wrapped as LazyType in the
gen/runtime.cpp module (with check and proper error msg in case object.d
doesn't contain a required declaration).
2018-04-04 19:59:10 +02:00
Martin
1b860e70d7 Merge branch 'master' into merge-2.078 2018-01-26 18:52:49 +01:00
Martin Kinkelin
6367d98d3a
Don't finalize scope objects without dtors and monitor (#2516)
The dtors can be checked at compile-time; insert a runtime check for the
monitor before finalizing the stack-allocated class object via druntime
call.

See issue #2515.
2018-01-26 18:38:16 +01:00
Martin
bd1db42ca0 Fix transition from removed ClassDeclaration::cpp 2018-01-06 15:03:24 +01:00
Martin
cfad799f48 Merge 2.078.0 front-end and stdlibs 2018-01-06 01:39:18 +01:00
kinke
d1b30d627c Backport fix for issue #2357 (#2366)
Improve robustness for TypeInfos of speculative types by only eliding
their TypeInfo definition, not the declaration of the LL global
altogether.

`DtoTypeInfoOf()` expects the LL global to be created and otherwise
fails with an assertion or segfault (e.g., issue #2357). So now only
linker errors should result in case the TypeInfo definition is missing.

Also normalize the calls to `DtoTypeInfoOf()` and revise the following
pointer bitcasts, as the LL type of forward-declared TypeInfo globals
may be opaque.
2017-10-18 20:47:09 +02:00
Martin
2616261fd2 Revise all LDC-specific errors/warnings/deprecs and insert backticks
For DMD's new syntax highlighting. I grepped in all .{h,cpp} files only.
2017-08-03 22:53:49 +02:00
Martin
47f1e59798 Fix flag 'isAbstract' for ClassInfos
The (public) field ClassDeclaration::isabstract isn't a bool, it's a
tristate with 0 = forward-reference, 1 = is abstract, 2 = is not abstract.

Fixes dmd-testsuite's runnable/test34.d, as TypeInfo_Class.create() (and
so Object.Factory()) returns null for abstract classes.
2017-02-04 18:12:59 +01:00
Ivan Butygin
a26bfc1223 Refactor code to hide direct IrFunction->func usage and add convenient functions (#1911) 2017-01-17 22:40:32 +01:00
Martin
16d15e01cb Use opaque [N x i8*] for vtables
This fixes the forward-referencing issue #1741.
2016-11-21 21:54:53 +01:00
Martin
e1394fad5f Build vtable type lazily 2016-11-19 15:29:19 +01:00
Martin
a5e5bd1716 Keep _d_newclass() semantics, re-introduce _d_allocclass() instead
And use that one in DtoNewClass(), keeping 3rd party code from breaking.
2016-08-15 13:19:11 +02:00
Johan Engelen
463e53b9ac Apply DDMD PR #5885 (f5f9150ea57cce5fabb43c79ff1b187d34d37044).
This fixes incorrect overriding of class methods and gets rid of many C++ warnings.
2016-07-25 15:25:01 +02:00
Martin
de9149f1b6 Remove getLVal() from DValue and add DtoL/RVal() overloads 2016-06-13 22:30:16 +02:00
Martin
e3e2f4b2e9 DValue: Remove method getType()
Use the existing public field directly instead.

It's shorter and different than LLValue's getType() (making it easier
to discriminate DValues and LLValues for experienced LDC devs imho).
2016-06-13 22:30:13 +02:00
Martin
039560bd83 Introduce DtoRVal/DtoLVal convenience functions
No functional changes intended.
2016-06-13 22:30:13 +02:00
Johan Engelen
3426b7d9ec Merge pull request #1455 from JohanEngelen/cpp11
C++11 a few loops [NFC]
2016-05-09 19:44:23 +02:00
Johan Engelen
c77c16ef59 C++11 a few loops [NFC] 2016-04-24 14:45:06 +02:00
Rainer Schuetze
1f5d689526 fix vtbl generation for interfaces (bad caching caused wrong thunks to be used)
fix interface casting
2016-04-18 08:22:31 +02:00
Johan Engelen
29ce4012af dmd2 --> ddmd. Merge (almost all of) our changes to dmd source into the new D source of dmd 2.069.2.
Also adds the CMake infrastructure to compile and link the D source files.

The build is partially broken:
- A few files in Phobos and druntime do not build
- MSVC build is broken because of unresolved symbols involving reals
2016-01-28 19:03:58 +01:00
Johan Engelen
70a6e73188 Cleanup runtime fwd decls and use ABI functiontype rewriting 2015-11-22 01:27:26 +01:00
Martin
2dfa5e8569 Some more cosmetic fixes
Found by searching for lines > 80 chars.
2015-11-05 19:12:32 +01:00
David Nadlinger
05d45350aa clang-tidy: Add readability-else-after-return 2015-11-02 11:30:40 +02:00
David Nadlinger
9df487edff gen/ir: clang-tidy the world 2015-11-02 11:30:40 +02:00
David Nadlinger
44b0f7b615 driver/gen/ir: clang-format the world
This uses the LLVM style, which makes sense for sharing code
with other LLVM projects. The DMD code we use will soon all
be in D anyway.
2015-11-02 00:28:01 +02:00
Martin
2d959ea540 Make use of C++11 range-based for
Should be available now that support for LLVM < 3.5 has been dropped.
2015-11-01 14:49:04 +01:00
David Nadlinger
f4f55abf27 Use thunks instead of calling _d_toObject for D interfaces
This allows us avoid the problems stemming from the 64 kiB
size limit hack in _d_toObject.

GitHub: Fix #1065.
2015-09-13 20:27:00 +02:00
David Nadlinger
553cc3705c Clarify ClassInfo/ModuleInfo size mismatch error messages
GitHub: Fix #1067.
2015-09-10 10:09:49 +02:00
David Nadlinger
6215acc15a Merge pull request #1030 from klickverbot/cfg-rewrite
EH/cleanup codegen rewrite
2015-08-20 15:30:15 +02:00
David Nadlinger
4bcae9731a The big catch/finally rework, part 2
Now with *almost* working EH codegen. Does not compile Phobos yet
because we run into the "instruction does not dominate all uses"
issue when an r-value result of toElemDtor is used and we need to
run cleanups in between. Should easily be fixed by promoting those
values to allocas.

Most of the changes outside of ir/irfunction.{h, cpp} are just
because CreateCallOrInvoke moved locations. I took the
opportunity to also make use of the different arg count
overloads where possible.
2015-08-19 19:56:39 +02:00
Martin
5d71dc38df Fix issue 1024: allow classes to be cast to typeof(null)
... and always return null in that case.
2015-08-16 21:43:24 +02:00
Martin
2304b52acb First attempt to simplify and fix destruction of temporaries in toElem(). 2015-07-18 13:34:26 +02:00
Martin
2444ae0988 First attempt to fix NewExp::argprefix.
The front-end uses a single bool variable as gate for all destructors
(by replacing each dtor expression by `gate || dtor()`).
This flag is set at the end of the argprefix chain of CommaExp.
So when no exception occurs in argprefix, the dtors aren't invoked in
the inserted finally block.
Right after the finally block we have the call to NewExp's ctor, which
will take care of destructing its parameters.
2015-07-18 13:34:26 +02:00
Martin
9f1e6f1a2e Prepare for more flexible toElemDtor().
We'd like to evaluate expression NewExp::argprefix and only destruct
it if an exception interrupts its evaluation.
2015-07-18 13:34:26 +02:00
David Nadlinger
0922254dd1 Directly emit IR into same llvm::Module instead of using Linker
GitHub: Fixes #970.
2015-06-14 21:36:35 +02:00
David Nadlinger
b10f110066 Do not try to use RTTI for C++ classes
Casts are just bitcasts, and do not try to invoke
class invariants on asserts.

@yebblies mentioned he would extend the DMD test suite
accordingly.
2015-05-31 09:34:14 +02:00
Kai Nacke
70218e1fd2 Revert "Don't initialize a new class instance a 2nd time after _d_newclass()." 2015-04-26 00:53:11 +02:00
Kai Nacke
17dddf7c54 Merge pull request #917 from kinke/disabledctor
Don't set default ctor in ClassInfo if it's @disabled.
2015-04-25 23:50:06 +02:00
Martin
ff3a994e09 Don't set default ctor in ClassInfo if it's @disabled. 2015-04-25 19:59:25 +02:00