-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Ruby: Replace CFG with shared implementation #22158
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
Open
aschackmull
wants to merge
10
commits into
github:main
Choose a base branch
from
aschackmull:ruby/cfg-swap
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b1ab236
Ruby: Replace control flow graph with shared implementation.
aschackmull 1b7dde8
Ruby: Accept qltest changes due to removed splitting.
aschackmull 54e4bb3
Ruby: Accept qltest changes due to method body inclusion in CFG.
aschackmull c42cd27
Ruby: Accept new nodes in END block.
aschackmull 9584382
Ruby: Accept location changes for SSA.
aschackmull a293c98
Ruby: Accept remaining qltests.
aschackmull 0ffc606
Ruby: Fix joinorder.
aschackmull 496f9e6
Ruby: Reintroduce lack of BeginExpr nodes.
aschackmull 879280a
Ruby: Accept qltest changes from BeginExpr test.
aschackmull 736b110
Ruby: Add change note.
aschackmull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,2 @@ | ||
| import codeql.ruby.controlflow.internal.ControlFlowGraphImpl::Consistency as Consistency | ||
| import Consistency | ||
| import codeql.ruby.AST | ||
| import codeql.ruby.CFG | ||
| import codeql.ruby.controlflow.internal.Completion | ||
| import codeql.ruby.controlflow.internal.ControlFlowGraphImpl as CfgImpl | ||
|
|
||
| /** | ||
| * All `Expr` nodes are `PostOrderTree`s | ||
| */ | ||
| query predicate nonPostOrderExpr(Expr e, string cls) { | ||
| cls = e.getPrimaryQlClasses() and | ||
| not exists(e.getDesugared()) and | ||
| not e instanceof BodyStmt and | ||
| exists(AstNode last, Completion c | | ||
| CfgImpl::last(e, last, c) and | ||
| last != e and | ||
| c instanceof NormalCompletion | ||
| ) | ||
| } | ||
|
|
||
| query predicate scopeNoFirst(CfgScope scope) { | ||
| Consistency::scopeNoFirst(scope) and | ||
| not scope = any(StmtSequence seq | not exists(seq.getAStmt())) and | ||
| not scope = | ||
| any(Callable c | | ||
| not exists(c.getAParameter()) and | ||
| not c.getBody().hasEnsure() and | ||
| not exists(c.getBody().getARescue()) | ||
| ) | ||
| } | ||
| import ControlFlow::Consistency |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| category: breaking | ||
| --- | ||
| * The Ruby control flow graph implementation has been completely replaced. This | ||
| affects a number of queries slightly. The CFG now includes additional nodes | ||
| to more accurately represent certain constructs. This also means that any | ||
| existing code that implicitly relies on very specific details about the CFG | ||
| may need to be updated. The CFG no longer uses splitting, which means that | ||
| AST nodes now have a unique CFG node representation. In particular, | ||
| `ControlFlowNode.getAstNode` has changed its meaning. The AST-to-CFG mapping | ||
| remains one-to-many, but now for a different reason. It used to be because of | ||
| splitting, but now it's because of additional "helper" CFG nodes. To get the | ||
| (now canonical) CFG node for a given AST node, use | ||
| `Stmt.getControlFlowNode()` instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think we should deprecate this predicate.