mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
6a4ce00ce9
This commit adds a post-processing step to initModelTypes, to enable it
to better discover types of void * variables, by looking at their uses.
This is useful in scenarios like e.g.:
```c
struct s {
int32_t x;
int32_t y;
};
struct s* init() {
void *result = calloc(SIZE, 1);
*((int32_t *)(result)) = SOME_INIT_VALUE;
*((int32_t *)( (uin64_t)(result) + 4) = OTHER_INIT_VALUE;
return result;
```
This patch enables initModelTypes to look at uses of `result`, and to
enable other transformations that depend on initModelTypes (such as
MakeModelGEP, SwitchToStatements) to turn the above code into:
```c
struct s {
int32_t x;
int32_t y;
};
struct s* init() {
struct s *result = calloc(SIZE, 1);
result->x = SOME_INIT_VALUE;
result->y = OTHER_INIT_VALUE;
return result;
```