Commit Graph

19 Commits

Author SHA1 Message Date
Alastair Robertson
aa87c3f2d1 NameGen: Override inputName for anonymous members 2023-12-14 17:42:48 +00:00
Alastair Robertson
0ae08addc9 TypeGraph: Add CaptureKeys node 2023-09-28 19:42:49 -07:00
Jake Hillion
d009f02ecb name contained types properly in treebuilder v2
Types within containers were previously named TODO. This sorts it out so
they're named as their most resolved type. The current implementation
skips Typedef names.
2023-08-25 16:25:14 +01:00
Jake Hillion
5071519e45 oil v2 2023-08-23 15:59:53 +01:00
Jake Hillion
c62fbe371d type_graph: provide inputName for all types
Type Graph deduplicates and modifies names to better fit the generated
code, for example `int32_t[4]` becomes `OIArray<int32_t, 4>` and `struct
MyStruct` might become `struct MyStruct_0`.

Add an `inputName` which better represents the original input code which
can be used when building the tree.
2023-08-18 16:58:21 +01:00
Jake Hillion
a2f7462a5d DrgnParser: store type of template param value 2023-08-17 15:40:34 +01:00
Alastair Robertson
e9975286b2 NameGen: Fix naming of const pointers 2023-08-01 17:53:39 +01:00
Alastair Robertson
9f9d1eb568 TypeGraph: Better handling for anonymous types
- Assign names to anonymous types
- Deduplicate all enums (anonymous or not)
- Add tests
2023-07-12 17:44:38 +01:00
Alastair Robertson
df68002bd6 NameGen: Remove invalid characters from member names
GCC includes dots in vptr member names, e.g. "_vptr.MyClass". These
aren't valid in C++, so we must replace them.
2023-07-11 13:51:54 +01:00
Alastair Robertson
e1b16a3d7e TypeGraph: Switch from pointers to references
References must always have a value, so are semantically clearer than
pointers for variables which must always be set.

No functional changes.
2023-07-06 17:24:33 +01:00
Alastair Robertson
23efc8d2d6 TypeGraph: Add Node IDs to non-leaf types
These aren't used for anything yet, but should be useful for stable IDs
when printing nodes before and after passes and for faster cycle
detection than the current map of pointers.
2023-07-06 14:54:30 +01:00
Alastair Robertson
00b46377a1 Unit tests: Remove unnecessary make_unique calls
This was a purely mechanical change made with some find-and-replace
macros.
2023-07-04 17:18:43 +01:00
Alastair Robertson
4bfa932b9b DrgnParser: Handle enum values in template params
We want to use the fully qualified name for scoped enums to keep the C++
compiler happy. When a parameter expects an enum value, we must supply
an enum value and not its underlying integer value.

Before:
  isset_bitset<1, 0>

After:
  isset_bitset<1, apache::thrift::detail::IssetBitsetOption::Unpacked>
2023-06-26 15:13:21 +01:00
Alastair Robertson
b0ef913b19 NameGen: Handle containers with zero template params
Previously we always deleted the last two characters and appended a `>`.

Old:
  MyContaine>

New:
  MyContainer
2023-06-26 11:27:38 +01:00
Alastair Robertson
784b900218 TypeGraph: Replace allocators with DummyAllocator
When we were previously removing allocators, we were only able to work
with containers whose allocators appeared as their last template
parameter.

Now we can replace allocators in the middle of a parameter list.

This fixes tests for folly::sorted_vector_set.
2023-05-31 15:49:37 +01:00
Alastair Robertson
e1bc5c7b5e Tests: Split common code out into type_graph_utils 2023-05-31 15:49:37 +01:00
Alastair Robertson
3a7a647a73 TypeGraph: Apply qualifiers to template params
This is necessary when replacing the allocator of a map type, for
example.

`std::map<int, int>` will need an allocator which allocates elements of
type `std::pair<const int, int>>`
2023-05-31 15:49:37 +01:00
Alastair Robertson
cfc3cc0221 TypeGraph: Handle alias templates
This fixes the test failure for std::conditional_t
2023-05-30 17:59:42 +01:00
Alastair Robertson
bd919ae4e4 TypeGraph: Add core code
This code mostly works, but is obviously not complete. This commit just
adds the code and tests, but does not enable it in OID or OIL.
2023-05-30 13:27:23 +01:00