Commit Graph

76 Commits

Author SHA1 Message Date
Ivan Krysak ac587cbb4f Model: rename Type into TypeDefinition 2024-06-27 11:05:48 +02:00
Ivan Krysak 26c68b78ea Model: drop makeTypeWithID 2024-06-27 11:05:48 +02:00
Ivan Krysak 84c8822c37 Model: drop TypedRegister 2024-06-27 11:05:48 +02:00
Alessandro Di Federico f60c1bb4ad s/TrackGuard/DisableTracking/ 2024-06-20 10:24:51 +02:00
Lauri Vasama 3e33a300d5 Introduce RawFunctionType::Architecture 2024-05-29 15:42:15 +02:00
Alessandro Di Federico ffe93548c5 Model ::size(): do not suspend tracking 2024-03-01 14:53:07 +01:00
Alessandro Di Federico 6f4923265e Type verify: improve error reporting 2024-03-01 14:53:06 +01:00
Alessandro Di Federico 0da9d1e1a4 Model: fix handling of 0-sized arguments
We used to support having a single `void` argument. It was for some
C-compatibility ambitions, but just omitting the argument is perfectly
fine.

Also, the DWARF importer has been fixed to handle typedef'd void as
arguments.

More in general, arguments are now required to always have a size.
2024-03-01 14:53:06 +01:00
Ivan Krysak 2e78369ec9 Model: disable float register size mismatch check 2024-02-09 15:09:37 +00:00
Massimo Fioravanti c276a439b5 Add pipeline invalidation
Replace the stub implementation of invalidation with the proper
implementation. A ReadPathCache is added to each global so that it can
keep tracks of what target are associated to which read paths.
2024-01-02 11:14:56 +01:00
Giacomo Vercesi 8504a96020 RawFunctionType: use NamedTypedRegister for return
Use the `NamedTypedRegister` type for return values in
`RawFunctionType`. This allows return values to be renamed at the user's
discretion.
2023-12-11 12:03:45 +01:00
Giacomo Vercesi 37ef77933c NamedTypedRegister: change name to use 'register'
Change the prefix used by `NamedTypedRegister` when `CustomName` is not
present from `_argument_` to `_register_`.
2023-12-11 10:21:02 +01:00
Pietro Fezzardi 1285c6e7af Make RawFunctionType::StackArgumentsType a TTR
This is homogeneous with all other nullable references to types in the
model, such as the StackFrameType in model::Function, and others.
2023-12-05 16:19:38 +01:00
Ivan Krysak cfe28d8e56 Stop using std:: prefix for u?int\d+_t types 2023-11-02 17:10:03 +01:00
Alessandro Di Federico bf66ecc389 {,Dynamic}Function::Prototype: support typedefs 2023-10-05 10:19:44 +02:00
Alessandro Di Federico b5aa75f1f1 Introduce model::PrimitiveType::fromName 2023-08-23 16:14:05 +02:00
Alessandro Di Federico f51af94e8f TupleTreeReference::isValid is for assertions only 2023-08-23 16:14:05 +02:00
Alessandro Di Federico a5b380b201 Model: rework how we name things
This commit improves the formalization of how we handle names.

The main changes are:

* Now `_` is a reserved prefix and all the generated names start with
  `_`.
* The model verification routine now checks that `CustomName`s in the
  global scope do not collide with any local namespace (e.g., fields of
  a `StructType`).
* We changed the prefix `prefix_` to `unreserved_` to better convey the
  fact that the prefix has been introduce to use an non-reserved name.
2023-08-23 16:14:04 +02:00
Alessandro Di Federico 247879f7fc model::Type::ID: switch to progressive IDs
This commit switches `model::Type::ID` from being a GUID to be a
progressive number, in order to make things easier for humans.

On top of this, this commit introduces the following changes:

* TypeCopier: import all the necessary PrimitiveTypes and improve
  handling of CustomName.
* Move Kind as the last field of the key of each TupleTree type used in
  an `UpcastablePointer`.
* Update the ground truth of tests to ignore the `CustomName` in favor
  of focusing on `OriginalName`.
* Increase adoption of `model::Binary::makeType`, equivalent to
  `Binary.recordNewType(makeType<model::*Type>())`.
2023-08-23 16:14:04 +02:00
Alessandro Di Federico 56268e94b0 VerifyHelper: handle fail in type verification
Before this commit, if there was a failure during the verification of a
type (which is recursive), we'd get an assertion in ~VerifyHelper due to
a "pending" type still being verified.
2023-08-23 16:14:04 +02:00
Alessandro Di Federico b8b483d052 Minor changes 2023-08-23 16:14:04 +02:00
Ivan Krysak 485ef34a12 Model: add Comment field all across the board 2023-07-21 17:25:24 +02:00
Ivan Krysak 8a9b253314 Model: clean type constructors up 2023-07-21 17:25:24 +02:00
Ivan Krysak 9f1d9fd5d0 Use Container::contains() where appropriate 2023-07-02 15:06:11 +00:00
Ivan Krysak bc98e0079f Formatting: change PenaltyReturnTypeOnItsOwnLine
The new value is 21.
2023-07-02 13:20:49 +02:00
Ivan Krysak b19572ea67 Model: Leave a note about the alignment 2023-03-15 10:19:02 +01:00
Ivan Krysak 84229d92b1 Model & ABI: make size and alignment stricter 2023-03-15 10:19:02 +01:00
Ivan Krysak 0b1aaeaede Minor improvements 2023-03-15 10:19:01 +01:00
Massimo Fioravanti 4dc2e92782 Introduce DocumentError
`DocumentError`s are the inteded way of propagating errors from the
pipeline to the frontend when a location is required to inform the user
of the error whereabouts.
2023-02-09 13:42:50 +01:00
Djordje Todorovic 961f9e5461 Model: search debug info locally upon import
Also find prototypes in Models of dynamic libs for both PE and ELF.
2022-12-13 11:26:54 +01:00
Massimo Fioravanti 742e1a0c56 TupleTree: switch from public fields to accessors 2022-12-12 18:36:57 +01:00
Alessandro Di Federico 693b361e4a TupleTree: externalize several methods 2022-12-09 09:08:40 +01:00
Pietro Fezzardi df30792435 PrimitiveType: support for 80 and 96 bits types
This commit completes the support of various rare PrimitiveTypes, that
has been added opportunistically over time and has remained inconsistent
across the codebase:

- float80_t
- float96_t
- generic80_t
- generic96_t

The first two are necessary because on some platforms long double is
either 10 or 12 bytes wide.

The second two are necessary because the Generic PrimitiveType should
allow all non-zero byte sizes allowed by any other PrimitiveType.
2022-11-30 15:06:54 +01:00
Pietro Fezzardi 8bf90e8bfd QualifiedType::isScalar: true for model::EnumType 2022-11-30 15:06:54 +01:00
Ivan Krysak 207668070a QualifiedType: add argument-less isPrimitive() 2022-11-30 15:06:54 +01:00
Pietro Fezzardi fd0914b460 QualifiedType: add isConst method 2022-11-22 10:12:31 +01:00
Alvise de Faveri 999df25246 Add revng model export type-graph tool
This tools dumps a type, a function or an entire type-system to a
dot file,representing dependencies between types as edges.
2022-09-19 08:35:06 +02:00
Djordje Todorovic a36e22729f Model: Add PDB support 2022-07-28 14:52:50 +02:00
Antonio Frighetto 4bc21328d8 Model: reserve type prefixes 2022-07-22 16:10:51 +02:00
Alvise de Faveri a3110c0b59 Add QualifiedType::is(TypeKind) 2022-04-20 11:25:46 +02:00
Massimo Fioravanti 44720eedbd Redesign TupleTreeDiff
`TupleTreeDiff` is now type-safe and owns the changes.
2022-04-15 15:14:13 +02:00
Pietro Fezzardi 6b2b2e8ada Make model::Type::edges() method const 2022-04-08 18:58:58 +02:00
Pietro Fezzardi e40ded965f QualifiedType RawFunctionType.StackArgumentsType
The `StackArgumentsType` field of `RawFunctionType` was the only
cross-reference between `model::Type`s that did not use
`model::QualifiedType` but a naked `TupleTreeReference`.

Switching it to `QualifiedType` make all cross-references across
`model::Type`s homogeneous.
2022-04-08 18:58:58 +02:00
Pietro Fezzardi 63a6676551 Make EnumType.UnderlyingType a QualifiedType
This was one of the few places left in the type system where a
`model::Type` referred to another one not using QualifiedType, but a
naked `TupleTreeReference`.

Switching it to be a `model::QualifiedType` makes cross-references
between `model::Type`s more homogenenous, requiring less corner-cases
to handle for whoever manipulates types.
2022-04-08 18:58:58 +02:00
Giacomo Vercesi 039f7db93e model::*: ensure Kind -> Class correspondence 2022-04-08 17:31:05 +02:00
Alessandro Di Federico 67706f05b6 Introduce a never-failing Type::trySize 2022-03-28 12:17:05 +02:00
Pietro Fezzardi fb54cc22a2 QualifiedType: new typedef-aware helper methods
This commit reworks the helper methods for model::QualifiedType, to
properly traverse typedefs.

These methods are used to check if a QualifiedType is:
- scalar
- primitive
- float
- void
- pointer
- array

This commit add the methods for checking pointers and arrays (that
weren't available before), reworks all the helpers so that they all
traverse typedefs, and adds comments so that it's clear that they
traverse typedefs.
2022-03-17 17:03:28 +01:00
Pietro Fezzardi 630fee4500 model::Qualifier: add static methods for filtering
This commit adds the static methods:
- model::Qualifier::isConst
- model::Qualifier::isArray
- model::Qualifier::isPointer

These methods replace the old, non-static, methods:
- model::Qualifier::isConst
- model::Qualifier::isArray
- model::Qualifier::isPointer

Having these method static is very helpful for filtering, when
iterating on sequences of qualifiers, such as:

  for (const auto &Q :
       llvm::make_filter_range(Qualifiers, Qualifier::isPointer)) {
    // do stuff with Q
  }

This will be very helpful for defining other helper functions for
model::QualifiedType.

This commit also drops the non-static version of the methods, since they
are redundant, and because they would cause ambiguity and failure of
type inference in the snippet above, making them effectively useless for
the goal they were designed for, which is filtering ranges.
2022-03-17 17:03:22 +01:00
Pietro Fezzardi 29c50fa909 Model: reserve names defined in stdint.h
This commit adds a bunch of type names and macro names to the set of
reserved keywords that cannot be used for names in the revng Model.
These are the names defined in the stdint.h standard C header, that is
included automatically by the decompiler in decompiled code.

We need to reserve these names otherwise it would be possible to add
things to the revng Model with names that clash with the names defined
in stdint.h, which would in turn break recompilation of decompiled code
because of conflicting definitions.
2022-02-08 15:54:02 +01:00
Alessandro Di Federico 863652f480 Introduce OriginalName in the type system
The goal of `OriginalName` is to keep track of the original name of a
symbol upon import.

In future, this will also be used to promote it to `CustomName`.
2022-01-27 11:51:03 +01:00