Commit Graph

225 Commits

Author SHA1 Message Date
Ivan Krysak c6e38cd485 Return to using constant name builders
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.
2025-04-17 11:19:17 +03:00
Ivan Krysak dc7d08555e Decompile: verify helper names are consistent 2025-04-17 11:19:17 +03:00
Ivan Krysak b72bcd7dd2 Introduce a basic problem name reporting system 2025-04-17 11:19:17 +03:00
Ivan Krysak cdd9004feb StringLiteral: do not escape HTML in non-HTML mode 2025-04-17 11:19:17 +03:00
Ivan Krysak 57b5eb7f98 NameBuilder: allow different name checkers 2025-04-17 11:19:17 +03: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 f070f1f1e1 Model: sunset double name system 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
Pietro Fezzardi 405001d628 CCodeGenerator::getModelGEPToken: relax assumption
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.
2025-03-05 15:25:59 +01:00
Pietro Fezzardi e87a229b1c DecompileFunction: use __builtin_bit_cast
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.
2025-03-05 15:25:59 +01:00
Alessandro Di Federico 61eb102906 DecompileFunction: fix noreturn calls comment
Unfortunately, the assumption that `noreturn` functions always return
`void` does not hold in the real world.
2025-03-05 09:57:51 +01:00
Ivan Krysak 99a8e28e3b PTMLCTypeBuilder: adopt CommentLineWidth 2025-02-13 13:09:50 +02:00
Ivan Krysak fb95595b10 Backend: add comment emission support 2025-02-13 13:09:50 +02:00
Ivan Krysak 255bd256fe Backend: expose isStatement helper 2025-02-13 13:09:50 +02:00
Ivan Krysak 8841bc7144 Don't include model::NameBuilder from the binary 2025-02-13 13:09:50 +02:00
Ivan Krysak 288448f009 Never include model::VerifyHelper from headers 2025-02-13 13:09:50 +02:00
Ivan Krysak 929cb4b35b Minor improvements 2025-02-13 13:09:50 +02:00
Pietro Fezzardi a18c32dd95 Decompile Function: fix escaping of char literals
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.
2025-02-03 17:24:12 +01:00
Pietro Fezzardi c33b7c9c4a DecompileFunction: drop unused Model arguments 2025-02-03 17:07:36 +01:00
Alessandro Di Federico 36edf810ef Introduce support for function pointers 2025-01-28 15:20:45 +01:00
Alessandro Di Federico 143c315196 Merge revng-c into revng 2024-11-21 10:50:55 +01:00
Alessandro Di Federico bbd527ae51 DecompileToDirectory: do not emit PTML 2024-11-12 14:28:21 +01:00
Ivan Krysak 64446d0453 Adopt name builder across the model users 2024-11-06 19:18:53 +02:00
Alessandro Di Federico 8cd4ee3b59 Move Kinds.h to revng 2024-11-04 15:09:56 +01:00
Alessandro Di Federico 98903f6b07 Move Ranks.h to revng 2024-11-04 15:09:56 +01:00
Alessandro Di Federico 4e670ac8e6 Either link revngcSupport or revngSupport 2024-11-04 15:09:56 +01:00
Alessandro Di Federico 2e4f4d09b9 Remaining FunctionTags have been moved to revng 2024-11-04 15:09:56 +01:00
Alessandro Di Federico 800340d6e8 IRHelpers.cpp has been moved to revng 2024-11-04 15:09:56 +01:00
Alessandro Di Federico 36e2faad3d Introduce -Wunreachable-code-break 2024-10-31 17:19:55 +01:00
Ivan Krysak 94d860e2b2 Clean up builder configuration
This also re-enables stack inlining by default.
2024-10-15 10:45:13 +03:00
Ivan Krysak 1a35cbcb77 Introduce PTMLCTypeBuilder 2024-10-15 10:45:13 +03:00
Ivan Krysak f523edc863 Pipeline: toString -> locationString 2024-10-15 09:13:28 +02:00
Ivan Krysak 8aa7b55e2d PTMLIndentedOstream: rename into IndentedOstream 2024-10-15 09:13:28 +02:00
Ivan Krysak 8288bd68d2 PTMLCBuilder: rename into ptml::CBuilder 2024-10-15 09:13:28 +02:00
Alessandro Di Federico 8a5ae5f9c1 s/ExecutionContext &Ctx/ExecutionContext &EC/g 2024-09-27 10:35:10 +02:00
Alessandro Di Federico 8706fd8459 Initialize pointers to nullptr 2024-09-27 10:35:10 +02:00
Alessandro Di Federico 9c99ac33ac s/serializeToLLVMString/toLLVMString/ 2024-09-27 10:35:10 +02:00
Alessandro Di Federico 4653796008 Drop Pipe::print 2024-09-27 10:35:10 +02:00
Alessandro Di Federico ca99bbbb66 Adopt toString() 2024-09-26 17:51:08 +02:00
Alessandro Di Federico e1f46264f8 Ensure every pipe commits what it should 2024-09-26 17:51:07 +02:00
Alessandro Di Federico 835a00d80c Minor changes 2024-09-25 10:00:22 +02:00
Alessandro Di Federico 0cb3eedd37 Do not use CallBase::getCalledFunction
Use our wrapper, which does not return nullptr if the `FunctionType`s do
not match.
2024-08-07 15:40:56 +02:00
Pietro Fezzardi 521baf38e8 PTML: honor GeneratePlainC 2024-06-27 17:30:56 -04:00
Pietro Fezzardi dfe3f4cb47 Rename revng C headers for decompiled code
Strip away the 'revng-' prefix from the filename.
2024-06-27 17:26:18 -04:00
Pietro Fezzardi d72139357f Add DecompileToDirectoryPipe
This pipe decompiles all the C code in a single directory, packaged up
as a .tar.gz file.
2024-06-27 17:26:18 -04:00
Pietro Fezzardi 2b9bcc0260 Backend: enable decompiling as plain C 2024-06-27 17:14:28 -04:00
Ivan Krysak 94a0ad6b93 Adopt reworked model::Type 2024-06-27 11:07:01 +02:00
Ivan Krysak 3705906074 Model: rename Type into TypeDefinition 2024-06-27 11:07:01 +02:00
Pietro Fezzardi 85340c8d84 ModelToHeader: disable type inlining by default
This is due to the fact that type inlining currently is broken in some
corner cases involving recursive types.
The bugs are caused by the fact that TypeInlineHelper uses its own
custom graph instead of using the DependencyGraph used by ModelToHeader,
causing different decisions about the order of emission of types.
As a result, the generated C types are not valid C, and they fail to
compile because a field of a struct has a type that is defined later
than its use.

After refactoring TypeInlineHelper to use DependencyGraph like
ModelToHeader, this can be reverted.
2024-06-26 12:21:58 +02:00
Alessandro Di Federico 5186a58053 s/FunctionMetadata/ControlFlowGraph/ 2024-06-18 17:56:24 +02:00