Commit Graph

291 Commits

Author SHA1 Message Date
Alastair Robertson
373dbe8f6c TypeGraph: Add option to record enumerator names 2023-08-17 15:47:23 +01:00
Jake Hillion
a2f7462a5d DrgnParser: store type of template param value 2023-08-17 15:40:34 +01:00
Thierry Treyer
ca0c71fa40
Workaround for #289 missing symbol (#290) 2023-08-17 13:53:14 +01:00
Jake Hillion
063646a1d9 codegen: split genClassTypeHandler 2023-08-16 14:40:07 +01:00
Alastair Robertson
ff31971bd3 Printer: Use NodeIds for stable IDs when printing graphs
This removes Printer's legacy behaviour of generating an ID for each
node as it gets printed. This old method meant that if new nodes were
added to or removed from a graph, every ID after the new/removed node
would change.

Now IDs are stable so it is easier to follow specific nodes through
multiple transformation passes in CodeGen.
2023-08-16 12:19:14 +01:00
Alastair Robertson
dca99fc4ad TypeGraph: Change Type::name() to return a reference instead of a copy
Names which were generated on-demand are now stored in member variables,
which are set during the ctor and can be regenerated when required (by
NameGen).
2023-08-15 15:33:21 +01:00
Alastair Robertson
57d2f3d380 DrgnParser: Don't error out for certain bad DWARF
Match the behaviour of CodeGen v1 and just log warnings when certain
debug info has issues.
2023-08-14 16:22:57 +01:00
Alastair Robertson
97ba03620a TypeGraph: Convert unit tests relying on Printer to use TypeGraphParser 2023-08-14 15:01:09 +01:00
Alastair Robertson
e5a83a3a37 TopoSorterTest: Add test for value template params 2023-08-11 10:50:33 +01:00
Jake Hillion
3a2cef0372 features: centralise requirement logic
This has room for conflicting features in future which will be used with
the OIL implementation. For now it makes it much easier to add
requirements.
2023-08-09 15:23:12 +01:00
dependabot[bot]
2d32a30bb9 Bump word-wrap from 1.2.3 to 1.2.5 in /website
Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.5.
- [Release notes](https://github.com/jonschlinkert/word-wrap/releases)
- [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.5)

---
updated-dependencies:
- dependency-name: word-wrap
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-03 18:00:16 +01:00
dependabot[bot]
ecff9f025f Bump semver from 5.7.1 to 5.7.2 in /website
Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-03 17:42:04 +01:00
Alastair Robertson
8f3d11955c OIRP: Add copyright header 2023-08-03 15:17:16 +01:00
Alastair Robertson
d45c7f4931 Flattener: Handle incomplete parent types 2023-08-02 14:29:19 +01:00
Alastair Robertson
0612159121 AlignmentCalc: Mark as packed if members are not aligned
We previously only marked as packed if there was no tail padding, which
was not a sufficient condition.

The new AlignmentCalcTest.PackedMembers test case is an example which
would previously not have been marked as packed.
2023-08-02 12:07:52 +01:00
Alastair Robertson
ececbe0a99 TopoSorter: Sort contained types after unique_ptr and shared_ptr
This is the same handling as regular pointers have. I came across a
type-cycle with unique_ptrs where this was necessary.
2023-08-01 17:53:39 +01:00
Alastair Robertson
e9975286b2 NameGen: Fix naming of const pointers 2023-08-01 17:53:39 +01:00
Alastair Robertson
ed2c6f357d CodeGen: Apply "alignas" to all stubbed types
Stubbing types listed in OICodeGen's "typesToStub" leaves them in the
same state as stubbed unions, so they need the same handling.
2023-08-01 17:53:39 +01:00
Alastair Robertson
6d30015764 TypeGraph: Set alignment for Thrift isset container to 1 2023-08-01 17:48:44 +01:00
Alastair Robertson
79d1d55b03 CI: Set installs to noninteractive so they don't hang waiting for user input 2023-08-01 17:30:38 +01:00
Alastair Robertson
6fbb60826f
EnforceCompatibility: Stub out void pointers
CodeGen v1 does not record anything for pointers to incomplete types.
Not even the address, as is done for other pointers.

Introduce a new Primitive type "Incomplete". This behaves identically to
"Void", but allows us to tell whether a type was defined as void or if
it ended up like that because of incomplete DWARF information.
2023-07-31 14:28:05 +01:00
Alastair Robertson
7bb6791af9 AddPadding: Insert padding at the beginning of structs if necessary
This is sometimes needed now that we're removing members before adding
padding.
2023-07-27 16:01:35 +01:00
Jake Hillion
d7cfcca30d move all internal logic to oi::detail namespace 2023-07-26 18:01:38 +01:00
Alastair Robertson
e19641efad EnforceCompatibility: Follow OICodeGen's typesToStub list 2023-07-26 17:31:35 +01:00
Alastair Robertson
8b7bfbe4c0 TypeGraph: Add EnforceCompatibility pass
This extracts the compatibility logic from AddPadding, which allows for it to be
simplified and will make it easier to extend and eventually remove in the
future. No functional changes.
2023-07-26 17:12:36 +01:00
Alastair Robertson
45c3697f6b TypeGraph: Add Prune pass
This lets us remove fields from types when they are no longer needed,
speeding up later passes.

A secondary benefit of pruning unused types means that we sometimes
remove types for which we can't generate correct C++ code. This can
allow us to CodeGen for complex types which reference these broken types
without actually requiring them (e.g. as template parameters).

Add a new feature flag "prune-type-graph" to control this pass. It makes
sense to prune most of the time, but for testing CodeGen functionality
on a wider range of types, it will be useful to have the option to not
prune.
2023-07-26 16:56:34 +01:00
Alastair Robertson
bc895dc9cc DrgnParser: Always stub function pointers
This makes CodeGen v2 behave the same as CodeGen v1, and there doesn't
seem much point in following function pointers either.
2023-07-26 11:30:01 +01:00
Alastair Robertson
884b9a6e95 CodeGen: Don't measure the sizes of union members
In general, we can't tell which member is active in a union so it is not
safe to try and measure any of them.

Explicitly set the alignment of unions (and structs/classes) in CodeGen
if it is available, as the C++ compiler can no longer infer it from the
members.
2023-07-26 11:16:30 +01:00
Alastair Robertson
2d1cc92bb4 Rename RemoveIgnored -> RemoveMembers
Also reshuffle CodeGen's passes to fix an alignment bug with removed
members.

Change RemoveMembers to actually remove members instead of replacing
them with padding. AddPadding must be run afterwards to fill in the
gaps.
2023-07-26 10:53:04 +01:00
Alastair Robertson
99462b2132 Types: Fix folly::small_vector and folly::sorted_vector_map
folly::sorted_vector_map's results are not completely accurate, but at
least CodeGen v2 matches CodeGen v1 for it now.
2023-07-26 10:07:30 +01:00
Alastair Robertson
e1496354de TopoSorter: Sort Typedefs before pointers
Also rename visitAfter() to acceptAfter() to match the previous renaming
of visit() to accept().
2023-07-25 15:31:35 +01:00
Alastair Robertson
df5ae4e34c AlignmentCalc: Array alignment should be based on elementType's alignment 2023-07-25 14:23:01 +01:00
Alastair Robertson
dfc0c62749 AlignmentCalc: Tests for bitfields
Extend TypeGraphParser to understand bitfields
2023-07-25 14:23:01 +01:00
Alastair Robertson
14d193df64 AlignmentCalc: Recurse into params,parents,members,children of Classes 2023-07-25 14:23:01 +01:00
Jake Hillion
623f896e9e increase verbosity of size static asserts 2023-07-24 18:48:59 +01:00
Alastair Robertson
04ce7446b2 AddPadding: Always pad bitfields with "int8_t"s
The underlying type of bitfield is important to the size of a struct:

  struct Foo { int64_t bitfield : 1; };
  struct Bar { int8_t bitfield : 1; };

  sizeof(Foo) = 8;
  sizeof(Bar) = 1;
2023-07-24 16:55:26 +01:00
Jake Hillion
325837c61b test: cycles: add test where oid sees the initial raw pointer
OID hides the initial raw pointer in the `cycles.raw_ptr` test. Add a
second test which wraps this pointer so OID sees the entirety of the
cycle.
2023-07-24 15:32:38 +01:00
Alastair Robertson
6ca846232c RemoveIgnored: Recurse into params,parents,members,children of Classes
Previously this code would not have removed all members which it was
supposed to.

Also remove some now-redundant code from TypeIdentifier. RemoveIgnored
will take over the responsibility of removing members from classes.
2023-07-24 15:02:20 +01:00
Jake Hillion
323daed329 googletest: change to FetchContent 2023-07-21 17:18:06 +01:00
Jon Haslam
b834c92029
provide common interfaces for continue and detach requests (#253) 2023-07-21 15:57:04 +01:00
Alastair Robertson
fd54d0ea83 Integration tests: Add tests for alignment of unions 2023-07-19 16:29:05 +01:00
Aditya Sarwade
1334e08d05 Specify namespace for IOBuf in IOBufQueue function
Things can fail if there are only IOBufQueue objects but no IOBuf
object. Just specify the namespace too.
2023-07-19 11:13:39 +01:00
Alastair Robertson
ec9f98f0e1 AddPadding: Pad unions when necessary 2023-07-18 17:45:46 +01:00
Alastair Robertson
a0acaaea65 AddPadding: Pad classes with zero members 2023-07-18 17:45:46 +01:00
Alastair Robertson
3aa52deb71 AddPaddingTest: Tests for unions and memberless classes 2023-07-18 17:33:25 +01:00
Alastair Robertson
1e1b319a69 TypeIdentifier: Create custom visitor for Class types
This is just laying some foundations - it doesn't do anything useful
yet.
2023-07-18 17:33:25 +01:00
Alastair Robertson
3b6b739d55 CodeGen: Add comments explaining the order of passes 2023-07-18 17:20:59 +01:00
Alastair Robertson
b4b3e86c47 TypeGraphParser: Fix lifetimes of ContainerInfo objects
Containers store references to ContainerInfos, so the ContainerInfos
must live beyond the stack they were created on. Use static variables
for simplicity.
2023-07-18 17:18:28 +01:00
Alastair Robertson
4d96848bdb TypeGraphParser: Throw custom error types
We can catch these exceptions and print clearer failure messages.

Before:
  unknown file: Failure
  C++ exception with description "Invalid type for child" thrown in the test body.

After:
  ../test/type_graph_utils.cpp:44: Failure
  Failed
  Error parsing input graph: Invalid type for child
2023-07-18 17:18:28 +01:00
Jake Hillion
31f46831c2 typing: handle padding only structs 2023-07-18 17:17:32 +01:00