This fixes an issue where any instantiation of TypeInfo in the final
output would lead to a cryptic error with no file or line information.
This change brings ldc in line with dmd's reporting of the same error,
which at least gives file and line information to discover the problem.
As *the* way to access the IrType associated with a Type via its `ctype`
field. Most importantly, it makes sure all access is redirected to the
*unqualified* type's `ctype`, which allows to get rid of the 'multiple
types' workaround for aggregates in DtoType(). Those were e.g. hit for
`shared struct SpinLock`, where the struct's type includes the `shared`
modifier...
And be more forgiving wrt. accepted types - don't require either a LL
integer or LL struct anymore, just make sure the type is a power-of-2
and no larger than 16 bytes, thereby allowing floating-point values,
vectors etc. too.
Contracts are special nested functions, previously receiving the
aggregate `this` pointer as context ptr, as nothing except for `this`
can actually be captured from the original function (parameters are
passed explicitly).
If a contract features a nested function and that function accesses
`this`, it is captured from the original function, and the nested
function expects a regular context of depth 2.
By passing a pointer to the `this` pointer as context for contracts, it
can naturally be used directly as parent context in the contract.
This fixes newly extended runnable/testcontracts.d.
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).
This fixes issue #2450 for primitive data types, i.e., performs the
rvalue load from lvalues (passed by value) right after evaluating the
argument expression. Previously, all expressions were evaluated in a
dedicated prior pass, so side effects in later argument expressions were
incorrectly visible.
Arguments rewritten by the TargetABI are rewritten immediately too now,
so I guess most of them are fine.
Lvalues passed with the byval attribute still need to be fixed
(dedicated alloca+memcpy).
Tie the state to an LLVM module/object file instead of having a global
one. And finalize it once per LLVM module instead of once per D module
(previously, as part of ModuleInfo generation).
Fixes issue #2388.
* Remove default label in switch which covers all enumeration values.
This fixes the warning "default label in switch which covers all enumeration values". We will already get a warning when _not_ all enumeration values are covered.
This is the last warning left on OSX/Clang, so with this change, we can build with -Werror.
* Fix warning: enumeral and non-enumeral type in conditional expression
* Fix warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 5
* "fallthrough" is recognized by the compiler warning system
Invoke nothrow callees only in try-blocks with at least 1 catch-block,
otherwise call them directly.
Errors thrown by nothrow callees can thus still be caught inside a
try-catch-statement (and this is apparently required for release builds
too).
Most calls will be direct calls though, and this small change will lead
to substantially less IR as we then skip the clean-ups after an Error.
Proper clean-up when unwinding after an Error seems not to be guaranteed
anyway. There are apparent RAII front-end optimizations for structs with
nothrow dtor - see PR #1656.
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.