-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rust: Basic control flow graph setup #17415
Rust: Basic control flow graph setup #17415
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! A few (mostly minor) comments.
* A basic block, that is, a maximal straight-line sequence of control flow nodes | ||
* without branches or joins. | ||
*/ | ||
class BasicBlock extends TBasicBlockStart { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BasicBlock
is extended further down in the file so I did
final class BasicBlock = BasicBlockImpl;
private class BasicBlockImpl extends TBasicBlockStart { ... }
similar to what you suggested for SuccessorType
.
private import internal.Completion | ||
private import internal.SuccessorType | ||
private import codeql.rust.controlflow.BasicBlocks | ||
import internal.Scope |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exposes the abstract
class CfgScope
, which users could then in principle extend. So I think it would be better to do
private import internal.Scope as Scope
final class CfgScope = Scope::CfgScope;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done as suggested. But I wonder if it would make sense to do it inside Scope.qll
instead?
rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImplSpecific.qll
Outdated
Show resolved
Hide resolved
rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll
Outdated
Show resolved
Hide resolved
rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll
Outdated
Show resolved
Hide resolved
rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll
Outdated
Show resolved
Hide resolved
e1f83de
to
6d972be
Compare
1126dc4
to
857edb7
Compare
I've addressed the comments 👍 I think we have the basic foundation for the CFG now. Looking at the result of the test we are at the very least creating some nodes and edges :) My guess it that they will still require some tweaking to be entirely right though. |
This is an attempt to add the basic setup/boilerplate needed to construct a CFG.
The PR is based on looking at how the CFG library is used for Swift, Kaleidoscope, Ruby, and C#. I've mixed and matched a bit form these, but mostly taken stuff from Swift (because it also uses codegen) and Kaleidoscope (because it's the simplest setup). I've erred on the side of simplicity to avoid adding stuff that we don't need (right away at least).