Commit Graph

38 Commits

Author SHA1 Message Date
Pietro Fezzardi 93d9cbb67b Enforce new include conventions 2020-11-12 18:00:45 +01:00
Alessandro Di Federico 37fde04594 Move licensing details to LICENSE.md 2020-11-09 10:03:33 +01:00
Pietro Fezzardi 217a18edb1 Update copyright notice 2020-11-06 15:07:45 +01:00
Pietro Fezzardi 87611643ad Fix names of struct types declarations
Before this commit, we assigned names to struct types without looking at
the function names of which they were return types.
Now we do, so that the name of the generated type for the function `f`
is `f_ret_type`.

This also fixes errors when reparsing the generated C code, where the
names of the struct types did not match.
2020-11-03 12:53:11 +01:00
Pietro Fezzardi 2bdff9bbaf MarkForSerialization: fix ExtractValueInst
With this commit `ExtractValueInst`s are handled so that they don't have
side effects.
This significantly improves the quality of the decompiled output,
preventing the forced serialization of all the extraction of struct
fields after calls to function that return structs, except for when it's
really needed.
2020-11-02 12:52:58 +01:00
Pietro Fezzardi 37f43f7e83 Use Value names for C declarations if possible
With this commit, the declarations of local variables and function
parameters now use the name of the associated `llvm::Value` if present,
instead of always using the prefix "param_" or "var_".
2020-11-02 12:32:22 +01:00
Pietro Fezzardi 99a6a18f26 createAST(): fix size of stack-allocated arrays
This commit fixes a wrong computation that caused stack-allocated arrays
to use the wrong size in bits instead of the correct size in bytes.
2020-11-02 10:43:06 +01:00
Pietro Fezzardi 27f850e433 GlobalDeclCreationAction: fix short literals
Before this commit, when GlobalDeclCreationAction needed to emit
literals for initialization of global variables, it did it using
custom code.
This was not working properly, an in some cases it emitted short
literals which are not allowed in C.
Hence the generated C code that was impossible to recompile without
syntax errors.

This commit fixes this problem, using the getLiteralFromConstant method
of StmtBuilder.
In order to do this, we need to make the StmtBuilder available inside
the GlobalDeclCreationAction, which is not a very clean design.
However, we are already planning to merge the GlobalDeclCreationAction
and the StmtBuilder class, so this issue will be taken care of in the
future.
2020-10-29 14:27:38 +01:00
Pietro Fezzardi f7e8599c5e Enforce check-conventions.sh
All commits should pass check-conventions.sh from now on.
2020-06-15 15:40:02 +02:00
Andrea Gussoni 0a630cc9ea Handle Switch in AST construction analysis 2020-06-15 15:06:22 +02:00
Pietro Fezzardi 6e2fa0c9cb Switch to llvm 10 2020-03-27 08:58:20 +01:00
Pietro Fezzardi fc2912ca32 enforce clang-format 2020-01-15 18:24:28 +01:00
Pietro Fezzardi c3a6a09f11 Upgrade to llvm-9 2020-01-15 18:24:28 +01:00
Andrea Gussoni e4df18f851 HACK: fix 128 uint and int emission 2020-01-15 18:16:24 +01:00
Andrea Gussoni de70a09c7a Fix gcc warnings related to default switch case 2019-11-20 15:16:17 +01:00
Pietro Fezzardi c6c6f19535 Enforce check-conventions 2019-11-20 15:16:17 +01:00
Pietro Fezzardi 429233f054 Fix more warnings left from -Weverything 2019-11-20 15:16:17 +01:00
Andrea Gussoni dc77551f83 HACK: fix emission of return statements
Handle returns of structs by emitting a `return void;`

This should be a very temporary fix.
2019-11-20 15:16:17 +01:00
Andrea Gussoni b214dd1921 Enforce check-conventions.sh
Replicate this commit 72f836d30079c191d1c30e185114c4c0a0f914df made by
Pietro.
2019-11-20 15:16:17 +01:00
Andrea Gussoni 560a345a2c Enforce -Weverything extensively
Replicate the changes made by this commit
f2a0df309f78e1b5d7c5f81ada5110523644559e perfomed by Pietro on the
branch containing the development fixes for `revng-c`.
2019-11-20 15:16:17 +01:00
Pietro Fezzardi 02ea1e5f94 Fix warnings emerged with -Wextra and -Weverything 2019-11-20 15:16:17 +01:00
Pietro Fezzardi 569ec5658e Add and enforce -Wall and -Werror 2019-11-20 15:16:14 +01:00
Andrea Gussoni 52faffb5eb Fix emission of literal constants
Fix the emission of literal constants in case we want to serialize the
address of a `GlobalVariable`.
2019-07-30 17:21:20 +02:00
Andrea Gussoni 637205dd0e Handle InserValue instruction with init
Handle `InsertValue` instructions which provide a `ConstantStruct` as
initialization.

A new value declaration at the top of the function is emitted and later
used as initilization for the struct which is being populated.
2019-06-13 12:14:47 +00:00
Andrea Gussoni 11298108ff Handle variadic functions in decompilation
Handle the emission of variadic functions (such as the
`indirect_handler` helper function) both in regards if declaration and
definition.

Handle also `undef` values in calls to the `indirect_handler` function.
2019-06-13 12:10:38 +00:00
Pietro Fezzardi ef3daf7a60 Refactor building AST for BasicBlocks 2019-05-10 11:53:28 +02:00
Pietro Fezzardi b058c326c6 Enforce coding style 2019-05-08 17:40:53 +02:00
Pietro Fezzardi b68f4fd89c Print all types before variable declarations 2019-05-08 17:40:53 +02:00
Pietro Fezzardi de7089cbc4 Handle breaks from loops from within switches 2019-05-06 11:19:41 +02:00
Pietro Fezzardi ed3d1b1ab8 Properly print bool variables from stdbool.h 2019-04-05 18:52:13 +02:00
Pietro Fezzardi 28a9804143 Print int types from inttypes.h 2019-04-04 17:30:48 +02:00
Pietro Fezzardi 9e4c5f0ece Add support for functions returning structs 2019-04-02 11:57:07 +02:00
Pietro Fezzardi 9dc97a360e ASTBuildAnalysis: skip over Stores of undef values 2019-03-29 11:08:13 +01:00
Pietro Fezzardi 25d9a8f3d5 Handle Set/Check nodes for loop state variables 2019-03-26 13:51:06 +01:00
Pietro Fezzardi a5175908dc Fix emission of statements after decompiler rework 2019-03-21 11:59:06 +01:00
Pietro Fezzardi dadbf54631 Rework decompiler 2019-03-20 17:47:04 +01:00
Pietro Fezzardi b4758ae02d Move PHI analysis in PHIASAPAssignmentInfo 2019-03-14 09:49:43 +01:00
Pietro Fezzardi 2640bbfeeb Use uniform naming for decompiler source files 2019-03-11 18:11:05 +01:00