object-introspection/oi/type_graph
Jake Hillion a931d2f52f oilgen: migrate to source parsing (#421)
Summary:
oilgen: migrate to source parsing

Using debug information generated from partial source (that is, not the final
binary) has been insufficient to generally generate OIL code.

A particular example is pointers to templates:
```cpp
#include <oi/oi.h>
template <typename T>
struct Foo {
  T t;
};
template <typename T>
struct Bar {
  Foo<T>& f;
};
void foo(const Bar<int>& b) {
  oi::introspect(b);
}
```

The pointer/reference to `Foo<int>` appears in DWARF with
`DW_AT_declaration(true)` because it could be specialised before its usage.
However, with OIL, we are creating an implicit usage site in the
`oi::introspect` call that the compiler is unable to see.

This change reworks OILGen to work from a Clang command line rather than debug
information. We setup and run a compiler on the source, giving us access to an
AST and Semantic Analyser. We then:
- Find the `oi::introspect` template.
- Iterate through each of its callsites for their type.
- Run `ClangTypeParser::parse` on each type.
- Run codegen.
- Compile into an object file.

Having access to the semantic analyser allows us to forcefully complete a type,
as it would be if it was used in the initial code.


Test Plan:
hope

`buck2 run fbcode//mode/opt fbcode//object-introspection/oil/examples/compile-time:compile-time`

Reviewed By: tyroguru

Differential Revision: D51854477

Pulled By: JakeHillion
2023-12-19 11:57:44 -08:00
..
AddChildren.cpp Update to clang/llvm 15 (#342) 2023-09-14 06:02:32 -07:00
AddChildren.h move all internal logic to oi::detail namespace 2023-07-26 18:01:38 +01:00
AddPadding.cpp clang-format: disable bin packing 2023-11-13 18:19:53 +00:00
AddPadding.h move all internal logic to oi::detail namespace 2023-07-26 18:01:38 +01:00
AlignmentCalc.cpp TypeGraph: Fix handling for classes which inherit from containers 2023-12-14 18:02:45 +00:00
AlignmentCalc.h TypeGraph: Fix handling for classes which inherit from containers 2023-12-14 18:02:45 +00:00
ClangTypeParser.cpp oilgen: migrate to source parsing (#421) 2023-12-19 11:57:44 -08:00
ClangTypeParser.h oilgen: migrate to source parsing (#421) 2023-12-19 11:57:44 -08:00
CMakeLists.txt oilgen: migrate to source parsing (#421) 2023-12-19 11:57:44 -08:00
DrgnExporter.cpp oilgen: migrate to source parsing (#421) 2023-12-19 11:57:44 -08:00
DrgnExporter.h oilgen: migrate to source parsing (#421) 2023-12-19 11:57:44 -08:00
DrgnParser.cpp clang-format: disable bin packing 2023-11-13 18:19:53 +00:00
DrgnParser.h TypeGraph: Fix handling for classes which inherit from containers 2023-12-14 18:02:45 +00:00
EnforceCompatibility.cpp CodeGen v2: Enable independent running without CodeGen v1 2023-12-15 14:57:24 +00:00
EnforceCompatibility.h move all internal logic to oi::detail namespace 2023-07-26 18:01:38 +01:00
Flattener.cpp TypeGraph: Fix handling for classes which inherit from containers 2023-12-14 18:02:45 +00:00
Flattener.h TypeGraph: Fix handling for classes which inherit from containers 2023-12-14 18:02:45 +00:00
IdentifyContainers.cpp TypeGraph: Fix handling for classes which inherit from containers 2023-12-14 18:02:45 +00:00
IdentifyContainers.h TypeGraph: Fix handling for classes which inherit from containers 2023-12-14 18:02:45 +00:00
KeyCapture.cpp add range-v3 library 2023-11-13 18:42:04 +00:00
KeyCapture.h TypeGraph: Add KeyCapture pass 2023-09-28 19:42:49 -07:00
NameGen.cpp oilgen: migrate to source parsing (#421) 2023-12-19 11:57:44 -08:00
NameGen.h oilgen: migrate to source parsing (#421) 2023-12-19 11:57:44 -08:00
NodeTracker.h Type Graph: Replace MutationTracker with the more general ResultTracker 2023-12-14 13:43:19 +00:00
PassManager.cpp TypeGraph: Remove NodeTracker from the TypeGraph class 2023-08-24 15:01:45 +01:00
PassManager.h TypeGraph: Remove NodeTracker from the TypeGraph class 2023-08-24 15:01:45 +01:00
Printer.cpp oilgen: migrate to source parsing (#421) 2023-12-19 11:57:44 -08:00
Printer.h oilgen: migrate to source parsing (#421) 2023-12-19 11:57:44 -08:00
Prune.cpp TypeGraph: Fix handling for classes which inherit from containers 2023-12-14 18:02:45 +00:00
Prune.h TypeGraph: Fix handling for classes which inherit from containers 2023-12-14 18:02:45 +00:00
RemoveMembers.cpp CodeGen: Remove Incomplete members from Classes 2023-12-12 18:50:15 +00:00
RemoveMembers.h move all internal logic to oi::detail namespace 2023-07-26 18:01:38 +01:00
RemoveTopLevelPointer.cpp oilgen: migrate to source parsing (#421) 2023-12-19 11:57:44 -08:00
RemoveTopLevelPointer.h oilgen: migrate to source parsing (#421) 2023-12-19 11:57:44 -08:00
TopoSorter.cpp TopoSorter: Only allow certain params to be incomplete 2023-10-25 17:01:44 +01:00
TopoSorter.h TypeGraph: Add CaptureKeys node 2023-09-28 19:42:49 -07:00
TypeGraph.cpp Remove Primitive::Kind::Incomplete 2023-10-04 11:23:28 -06:00
TypeGraph.h TypeGraph: Remove NodeTracker from the TypeGraph class 2023-08-24 15:01:45 +01:00
TypeIdentifier.cpp TypeGraph: Fix handling for classes which inherit from containers 2023-12-14 18:02:45 +00:00
TypeIdentifier.h name contained types properly in treebuilder v2 2023-08-25 16:25:14 +01:00
Types.cpp CodeGen v2: Enable independent running without CodeGen v1 2023-12-15 14:57:24 +00:00
Types.h oilgen: migrate to source parsing (#421) 2023-12-19 11:57:44 -08:00
Visitor.h oilgen: migrate to source parsing (#421) 2023-12-19 11:57:44 -08:00