Because of a sub-par heuristic designed to avoid emitting
*unnecessary* debug information tags, some of the *necessary*
tags were lost as well, leading to debug information mismatch
between the backend and the UI.
Note that this is not a fix, this commit simply removes
the heuristic in question, leading to ~2x increase in
output c file size.
This commit fixes DecompileFunction.cpp to ensure that it can properly
handle calls to helpers that return struct types on LLVM IR.
In the past, these were properly handled but in the current tests this
kind of helpers never reach the C backend anymore.
This is a preliminary change necessary for updating libtcg, where this
kind of helpers will start to appear again.
Instead of failing on decompilation for loops with an empty `Body` which
are not `DoWhile`s (the only admitted type), we emit a warning on the
`c-backend` logger.
Type inlining was a feature that allowed type definitions of
structs/unions/enums to be printed in C directly inside the definition
of another parent struct/union, if the inner type was only used once in
the parent type.
This kind of reasoning is inherently global: a type definition of the
subtype can be inlined in the parent type one only if *globally* the
subtype it isn't referred anywhere else.
This caused issues with type inlining inside definitions of stack types
in the body of functions. Indeed, for a given function, due to type
inlining, it was necessary to do global reasoning about what other types
could be inlined in the definition of the function's stack frame type.
This, in turn, had heavy consequences on invalidation, because any
change to any type (even if it wasn't referred in a given function's
body) was causing invalidation of all functions' bodies.
For this reason it was decided to drop the type inlining feature.
These methods had a misleading name, because they always returned a
ScopeTag, and never indented anything.
As a result they were misused or used in a confusing way in most of
their uses.
They have now both been replaced by two different overloaded methods
with the name getScopeTag.
This commit also fixes all their broken uses.
Because of how name builders used to lazy gather namespaces on the first
requested name, the objects were self mutating. As such only non-const
references could be used to pass them around.
Since that is no longer the case, this restores most of lost const
qualifiers.
This reworks NameBuilder to ease the transition to the system where
the model will be guaranteed to never contain any name collisions, both
between user-specified names and the automatic ones.
This commit relaxes the assumption of the
CCodeGenerator::getModelGEPToken method, that previously crashed if the
BaseType and CurType were different.
Now this condition is only checked after skipping all typedefs, that
are transparent to ModelGEPs.
This commit ensures that, when the LLVM-based C code generation emits a
bitcast that would not compile in C if printed as a regular cast, it
uses __builtin_bit_cast instead.
This is necessary because the LLVM-based C backend is deprecated in
favor of the clift-based decompilation pipeline, so we're not actively
fixing bugs anymore, and it currently cannot guarantee that such invalid
casts are never emitted.
Before this commit, char literals were always printed with html
escaping, even if the associated PTML builder was set to Tagless.
This commit fixes the problem.