If functionSemantic() fails, compilation will eventually halt anyway.
This prevents displaying a fatal follow-up error, and e.g. makes
fail_compilation/fail18938.d produce the expected error messages.
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.
Making it obvious which of the two operations is performed, reducing
call args and making sure a global isn't defined multiple times via
`defineGlobal()`.
The only [intended] functional change is in gen/trycatchfinally.cpp,
where I inserted a check for an existing __cpp_type_info_ptr global when
emitting a catch for C++ exceptions.
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).
The part needing most attention was ddmd.root.ctfloat, ddmd.target (incl.
gen/target.cpp) and ddmd.builtin. The front-end is now prepared for
elaborate compile-time floating-point types to allow for proper cross-
compilation.
This version still uses the host's `real` type for compile-time reals,
except for MSVC hosts, which still use 64-bit doubles (when compiled with
DMD host compiler too).
Some other changes:
* semantic*() of Statements extracted from statement.d to statementsem.d
* mangle() -> mangleToBuffer()
* Identifier::string -> toChars()
* Token::float80value => floatvalue
* Dsymbol::isAggregateMember() => isMember()
* BoolExp is no more
* ddmd.root.ctfloat: LDC-specific CTFE builtins
I noticed that the C++ thunks would adjust the `this` pointer and then
jump directly to the actual target function.
The D thunks (on Linux, verified by disassembling) on the other hand
performed a regular call + return. Requesting tail-calls here leads to
direct jumps for D thunks as well, improving performance when calling
virtual functions via interfaces.
E.g., for `extern(C++) int Derived::MethodCpp()`:
`Th16_ZN7Derived9MethodCPPEv` => `_ZThn16_N7Derived9MethodCPPEv`
This makes sure `runnable/cppa.d` and `runnable/extra-files/cppb.cpp` work
when linking the 2 object files in any order on Linux, just as for DMD.
Previously, it only worked if the C++ object was specified first. Then the
C++ implementations of `Derived::MethodD()` and `Derived::Method()` were
picked and the D ones discarded.
If the C++ ones were discarded by specifying the D object first, the (C++)
thunks in the (C++) interface vtable (i.e., used for `Derived` instances
created on the C++ side) apparently got corrupted, jumping to null (as the
thunk target, the real C++ function, got discarded in favor of the D one).
By fixing the D thunk names, `extern(C++)` thunks are now overrideable as
well. If the C++ object is specified first when linking, the C++ thunks
(and methods) will be picked, otherwise the D thunks (and methods).
So the interface vtables produced by C++ and D should now always point to
the same set of thunks and thus resolve this nasty issue.
Previously, the transitory state only needed and valid during
generation of the LLVM IR for the function body was conflated
with the general codegen metadata for the function declaration
in IrFunction.
There is further potential for cleanup regarding the use of
gIR->func() and so on all over the code base, but this is out
of scope of this commit, which is only concerned with those
IrFunction members moved to FuncGenState.
GitHub: Fixes#1661.
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