mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
Many classes have been declared with `extends @cfgnode` because they
should be implemented internally as a control-flow node but should not
expose the member predicates of `ControlFlowNode` to their users. After
the transition in a1e44041e it became mandatory to convert explicitly
between the `Element`-derived `ControlFlowNode` and the raw dbtype
`@cfgnode`, and that commit inserted numerous such conversions as a
result of having all those classes that did not derive from `Element` in
the standard library.
It was also confusing and error-prone that the libraries implementing
`ControlFlowNode` referred to `ControlFlowNode`. This seemingly cyclic
reference worked out because the libraries did not call the predicates
on `ControlFlowNode` whose implementation they were part of.
Both these problems are now solved by adding a new class
`ControlFlowNodeBase extends Element` that should be used in preference
to `@cfgnode` everywhere. This class is for exactly those use cases
where `@cfgnode` should be seen as an `Element` without having too many
member predicates on it.
The classes that move from extending `@cfgnode` to extending
`ControlFlowNodeBase` are: `BasicBlock`, `AdditionalControlFlowEdge`,
`DefOrUse`, `SsaDefinition`, `SubBasicBlock` and `RangeSsaDefinition`.
These previously had to define their own `toString` rootdef, which
typically had some dummy string as result (like `"BasicBlock"`), but now
their `toString` is part of the `Element` rootdef and should not be
overridden otherwise `Element.toString` will sometimes have multiple
results. Removing these dummy `toString` predicates had some effects on
the tests that are included in this commit.
The `getLocation` family of predicates is affected like `toString`, but
the situation is slightly different. Some of these classes had genuinely
useful alternative definitions of locations. Fortunately, they all used
`hasLocationInfo`, which is preferred over `getLocation` by the QL
engine. Because `Element` does not define `getLocationInfo`, each class
can create its own rootdef of this predicate like before.
23 lines
1.3 KiB
Plaintext
23 lines
1.3 KiB
Plaintext
| pass_by_ref.cpp:9:19:28:1 | { ... } | pass_by_ref.cpp:9:16:9:16 | n |
|
|
| pass_by_ref.cpp:30:18:34:1 | { ... } | pass_by_ref.cpp:30:15:30:15 | n |
|
|
| pass_by_ref.cpp:36:19:43:1 | { ... } | pass_by_ref.cpp:36:16:36:16 | n |
|
|
| pass_by_ref.cpp:45:20:55:1 | { ... } | pass_by_ref.cpp:45:17:45:17 | n |
|
|
| test.c:2:31:72:1 | { ... } | test.c:2:14:2:14 | x |
|
|
| test.c:2:31:72:1 | { ... } | test.c:2:21:2:21 | w |
|
|
| test.c:2:31:72:1 | { ... } | test.c:2:28:2:28 | z |
|
|
| test.c:74:19:89:1 | { ... } | test.c:74:16:74:16 | a |
|
|
| test.c:91:33:97:1 | { ... } | test.c:91:27:91:30 | cond |
|
|
| test.cpp:2:19:17:1 | { ... } | test.cpp:2:16:2:16 | p |
|
|
| test.cpp:19:27:21:1 | { ... } | test.cpp:19:24:19:24 | x |
|
|
| test.cpp:23:27:25:1 | { ... } | test.cpp:23:24:23:24 | x |
|
|
| test.cpp:93:3:93:4 | { ... } | test.cpp:72:12:72:16 | nextp |
|
|
| test.cpp:93:3:93:4 | { ... } | test.cpp:73:12:73:16 | nextr |
|
|
| test.cpp:93:3:93:4 | { ... } | test.cpp:74:18:74:23 | nextcp |
|
|
| test.cpp:93:3:93:4 | { ... } | test.cpp:75:18:75:23 | nextcr |
|
|
| test.cpp:93:3:93:4 | { ... } | test.cpp:76:9:76:9 | i |
|
|
| test.cpp:93:3:93:4 | { ... } | test.cpp:77:10:77:11 | ip |
|
|
| test.cpp:93:3:93:4 | { ... } | test.cpp:78:10:78:11 | ir |
|
|
| test.cpp:93:3:93:4 | { ... } | test.cpp:79:15:79:16 | ci |
|
|
| test.cpp:93:3:93:4 | { ... } | test.cpp:80:16:80:18 | cip |
|
|
| test.cpp:93:3:93:4 | { ... } | test.cpp:81:16:81:18 | cir |
|