31 Commits

Author SHA1 Message Date
Alessandro Di Federico c883bed765 Drop Logger's StaticEnabled feature 2025-10-31 17:25:03 +01:00
Ivan Krysak ecb9d76c64 Model: drop obsolete default value handling 2025-10-13 18:33:10 +03:00
Ivan Krysak f03654564e Emit _STARTS_AT on fields with custom names 2025-09-05 10:15:32 +03:00
Ivan Krysak cd7f3f8ffd ModelCBuilder: rework handling of padding fields 2025-09-04 16:57:16 +03:00
Ivan Krysak 3eea4c4094 Always emit _SIZE on struct definitions 2025-09-04 16:57:12 +03:00
Ivan Krysak c6a175a1b9 Rename _START_AT -> _STARTS_AT 2025-08-29 14:00:29 +03:00
Ivan Krysak 290d2e2c57 ptml::CTypeBuilder: rename into ModelCBuilder 2025-07-23 11:38:53 +02:00
Pietro Fezzardi e50bd12519 Drop unused printInlineDefinition 2025-05-29 09:31:26 +02:00
Pietro Fezzardi a71db5d243 DependencyGraph: refactor creation of nodes/edges 2025-05-28 17:11:57 +02:00
Pietro Fezzardi ea3cbe4c1b Drop type inlining
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.
2025-05-28 17:11:56 +02:00
Pietro Fezzardi 2331f10282 DependencyGraph: add new factory method and class 2025-05-28 17:11:11 +02:00
Pietro Fezzardi 660cb89eb5 DepenencyGraph: introduce AssociatedNodes
This data structure is used to bind together a pair of pointers to
TypeDependencyNode, one referring to a declaration of a type and the
other referring to a definition of the same type.

The definition can be null if the type referred to is a type without an
explicit definition (e.g. typedefs), while it's never null for types
for which have forward declaration that is separate from the definition
(e.g. structs and unions).
2025-05-28 17:11:11 +02:00
Pietro Fezzardi 28f180dcb8 Rename CTypeBuilder::printTypeDefinition
to printDefinition.
2025-05-28 17:11:11 +02:00
Pietro Fezzardi ec0c56abcc Rename CTypeBuilder::printTypeDeclaration
to printDeclaration.
2025-05-28 17:11:11 +02:00
Pietro Fezzardi 8c7a800de1 Rename CTypeBuilder::printForwardTypeDeclaration
to printForwardDeclaration.
2025-05-28 17:11:11 +02:00
Pietro Fezzardi 62762c1e48 TypePrinters.cpp: improve logging of TypeNodes
reusing the same getNodeLabel function used by DOTGraphTraits.
2025-05-28 17:11:11 +02:00
Pietro Fezzardi 0426c773b2 CABIFunctionDefinition: drop array argument/return
This commit bans from the model array types in as argument or return
types in CABIFunctionDefinition.
CABIFunctionDefinition implies we're decompiling towards C, and C does
not support array arguments (passed by copy) nor array return types.

Banning these from the model reduces the number of situations where we
have to emit artificial array wrappers (not present in the model) around
types when printing C code, simplifying the handling of such situations
when translating to clift and in general in the decompilation pipeline.
2025-05-28 17:11:11 +02:00
Ivan Krysak 82695ae8a6 PTMLCTypeBuilder: print RFT-RV wrapper comment
Before this definition of such wrappers allowed adding comments, but
never displayed them, which is confusing.
2025-05-08 15:42:01 +02:00
Ivan Krysak 0b2461e7b3 Wrap comments into a tag that allows commenting
This wraps most of the comments into a tag that lets them be edited
as they are, without needing to find where that comment is actually
attached to.
2025-05-08 15:42:01 +02:00
Ivan Krysak f25ea78aa8 PTMLCTypeBuilder: separate RFT-RV wrapper emission
This lets us drop the ability for the `getNamedInstanceOfReturnType`
to return definitions (this was the only user).
2025-05-08 15:42:01 +02:00
Ivan Krysak 0a097c067b TypeNames: suppress selected comment newlines 2025-05-08 15:42:01 +02:00
Ivan Krysak 3808706a39 TypeNames: render return value register comment 2025-05-08 15:42:01 +02:00
Ivan Krysak 6cdf5c01ef PTML: make commentability a property of a line
Before this, commenting is only possible on specific names, with this
the entire supported line is active (unless there are more grannular
comment contexts, for example, in the function prototype).

For example (commentable parts are marked with `^`):
```
// struct whatever {
// ...

// before this
  const my_type_name *my_field_name[10];
//                    ^^^^^^^^^^^^^

// after this
  const my_type_name *my_field_name[10];
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

// ...
// };
```
It's the same for all the others, like segments, arguments, and so on.
2025-05-08 15:42:00 +02:00
Ivan Krysak eac296a99f Standardize PTML tag emission in c backend 2025-05-08 15:42:00 +02:00
Ivan Krysak dce5c1a02c NamingConfiguration: pull more prefixes inside
Unify additional values that used to be hardcoded in the old backend
under the same naming configuration root.
2025-04-17 11:19:17 +03:00
Ivan Krysak 645cf7fc2e NameBuilder: sunset deduplication
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.
2025-04-15 16:35:42 +03:00
Ivan Krysak 705e4a5955 auto [...] -> auto &&[...] 2025-02-13 13:10:51 +02:00
Alessandro Di Federico 11d8515f46 ModelToHeader: adjust blank lines 2024-11-27 17:18:12 +01:00
Alessandro Di Federico 143c315196 Merge revng-c into revng 2024-11-21 10:50:55 +01:00
Ivan Krysak 64446d0453 Adopt name builder across the model users 2024-11-06 19:18:53 +02:00
Ivan Krysak 1a35cbcb77 Introduce PTMLCTypeBuilder 2024-10-15 10:45:13 +03:00