- Notifications
You must be signed in to change notification settings - Fork1.9k
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
codeql/go/ql/lib/semmle/go/AST.qll Lines 77 to 85 in6fa6093
In rust and cpp, /** Gets the parent node of this AST node, but without crossing block boundaries. */privateAstNodeparentInSameBlock(){result=this.getParent()andnotthisinstanceofBlockStmt}/** Gets the innermost block statement to which this AST node belongs, if any. */pragma[nomagic]BlockStmtgetEnclosingBlock(){result=this.getParent().parentInSameBlock*()} |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 2 comments 4 replies
-
Can I ask what you want to use it for? The two examples you give are very much about syntactic blocks. Both of those languages have a funcf() {g()h()} At a syntactic level it clearly has one block. But from the point of the view of control flow it has two basic blocks, because |
BetaWas this translation helpful?Give feedback.
All reactions
-
Usage Scenario: decide whether the declaration of varobjSgofunc() {access(obj) }() If they are not in same varobjSfor {gofunc() {access(obj) }()}
go-all package(4.2.5 version) in codeql v2.21.3 codeql qlpacks have
Thanks for your explanation! In the second example above, using AST level I will try to connect |
BetaWas this translation helpful?Give feedback.
All reactions
-
You're right, I missed Thank you for explaining your use case. I have made a PR to add this as a member predicate:#21254 . In the meantime, you can write the code that you want in a top-level predicate rather than a member predicate: I should also mention the |
BetaWas this translation helpful?Give feedback.
All reactions
-
To be more specific, if you look at the results of |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Thanks for your explanation about Then I turn to find the enclosing |
BetaWas this translation helpful?Give feedback.
All reactions
-
#21254 has been merged, so this should be in release v2.24.2, which should be out in about two weeks. |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 1🚀 1