File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
rust/ql/lib/codeql/rust/elements/internal Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,17 @@ module Impl {
5959 )
6060 }
6161
62+ /** Gets the block that encloses this node, if any. */
63+ cached
64+ BlockExpr getEnclosingBlock ( ) {
65+ exists ( AstNode p | p = this .getParentNode ( ) |
66+ result = p
67+ or
68+ not p instanceof BlockExpr and
69+ result = p .getEnclosingBlock ( )
70+ )
71+ }
72+
6273 /** Holds if this node is inside a macro expansion. */
6374 predicate isInMacroExpansion ( ) { MacroCallImpl:: isInMacroExpansion ( _, this ) }
6475
Original file line number Diff line number Diff line change @@ -127,6 +127,10 @@ module Impl {
127127 */
128128 Name getName ( ) { variableDecl ( definingNode , result , text ) }
129129
130+ /** Gets the block that encloses this variable, if any. */
131+ cached
132+ BlockExpr getEnclosingBlock ( ) { result = definingNode .getEnclosingBlock ( ) }
133+
130134 /** Gets the `self` parameter that declares this variable, if any. */
131135 SelfParam getSelfParam ( ) { result .getName ( ) = this .getName ( ) }
132136
You can’t perform that action at this time.
0 commit comments