necessary because the CFG library doesn't support the following
two requirements simultaneously:
1. Traverse AST classes by virtual dispatch
2. Construct ControlFlowElements from non-AST classes
Because the CFG trees derive from the a base type that must be a
subtype of `ControlFlowElement`. So if we make `ControlFlowElement`
an IPA type, we cannot write:
```
class AssignTree extends PostOrderTree instanceof AssignExpr { ... }
```
because `AssignExpr` is not a subtype of PostOrderTree (since
PostOrderTree is now a subtype of the new IPA type).
To fix this, Tom suggested the following (which is implemented in
this PR):
1. Create a copy of the CFG tree classes (i.e., Pre/PostOrderTree,
LeafTree, etc.) and call them AstPreOrderTree/AstPostOrderTree,
AstLeafTree, etc.
2. For each tree AstTree from step 1, create a instance of the
internal CFG library's appropriate class.
3. In `ControlFlowGraphImpl`, proceed as normal with virtual
dispatch using `instanceof`, but extend the AstTree classes
from step 1 instead of the CFG's own tree classes.
This works because each AstTree implements one of the CFG
library's tree classes (as per step 2).
This commit performs step 1 and 2. Step 3 will be the next commit.
This transfers the current state of `StmtVisitor` in the PoC, plus some
changes required for the update to swift 5.6.
Also `getLabel` in `SwiftDispatcher` got renamed to `createLabel`, and
is now correctly outputting the label assignment to the trap file.
This transfers the current state of `DeclVisitor` from the
proof-of-concept.
TODO: make the `declarations` tests in `extractor-tests` more
comprehensive.
This allows to avoid bypassing label type correcness in the extractor,
and allows to independently resolve TBD extractions, as with this
approach TBD nodes do have the correctly typed trap label. The TBD
status is now a predicate on the QL side.
This requires:
* a default visit using the correct type, which is achieved via macro
metaprogramming in `VisitorBase.h`, following the way
`swift::ASTVisitor` is programmed
* a mapping from labels to corresponding binding trap entries. The
functor is defined in `TrapTagTraits.h` and instantiated in generated
`TrapEntries.h`
* Binding trap entries for TBD unknown entities must not have any other
field than the `id` (after all, we are supposed to not extract them
yet). This is why all unextracted fields in `schema.yml` have been
commented out, and will be uncommentend when visitors are added
This is solving a papercut, where the C++ build was relying on the
local dbscheme file to be up-to-date, even if all the information for
building is actually in `schema.yml`. This made a pure C++ development
cycle with changes to `schema.yml` clumsy, as it required a further
dbscheme generation step.
Now for C++ the dbscheme is generated internally in the build files, and
thus a change in `schema.yml` is reflected immediately in the C++ build.
A `swift/codegen` step for checked in generated code (including the
dbscheme) is still required, but a developer can do it just before
running QL tests or committing, instead of during each C++
recompilation.
Some directory reorganization was also carried out, moving specific
generator modules to a new `generators` python package, and only leaving
the two drivers at the top level.
This allows to avoid bypassing label type correcness in the extractor,
and allows to independently resolve TBD extractions, as with this
approach TBD nodes do have the correctly typed trap label. The TBD
status is now a predicate on the QL side.
This requires:
* a default visit using the correct type, which is achieved via macro
metaprogramming in `VisitorBase.h`, following the way
`swift::ASTVisitor` is programmed
* a mapping from labels to corresponding binding trap entries. The
functor is defined in `TrapTagTraits.h` and instantiated in generated
`TrapEntries.h`
* Binding trap entries for TBD unknown entities must not have any other
field than the `id` (after all, we are supposed to not extract them
yet). This is why all unextracted fields in `schema.yml` have been
commented out, and will be uncommentend when visitors are added
This turned out easier than expected previously. `llvm::PointerUnion`
was also considered, which would have less memory footprint, but it
would require more effort as it is lacking the same implicit conversions
and operators that `std::variant` provides.
Also renamed `ToTag<E>` to `TrapTagOf<E>` and introduced a derived
convenience functor `TrapLabelOf<E>`.