Skip to content

Commit 86fd21d

Browse files
committed
Swift: respond to PR comments on constructor flow
1 parent 686f7cc commit 86fd21d

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

swift/ql/lib/codeql/swift/dataflow/internal/DataFlowPrivate.qll

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -399,26 +399,13 @@ private module ReturnNodes {
399399
override ReturnKind getKind() { result instanceof NormalReturnKind }
400400
}
401401

402-
class SelfReturnNode extends ReturnNode, TInoutReturnNode, NodeImpl {
403-
SelfParamDecl param;
404-
ControlFlowNode exit;
405-
SelfReturnNode() {
406-
this = TInoutReturnNode(param) and
407-
exit instanceof ExitNode and
408-
exit.getScope() = param.getDeclaringFunction() and
409-
param.getDeclaringFunction() instanceof ConstructorDecl
410-
}
411-
override ControlFlowNode getCfgNode() { result = exit }
412-
413-
override DataFlowCallable getEnclosingCallable() {
414-
result = TDataFlowFunc(param.getDeclaringFunction())
415-
}
416-
417-
ParamDecl getParameter() { result = param }
418-
419-
override Location getLocationImpl() { result = exit.getLocation() }
402+
/**
403+
* A data-flow node that represents the `self` value in a constructor being
404+
* implicitly returned as the newly-constructed object
405+
* */
406+
class SelfReturnNode extends InoutReturnNodeImpl {
407+
SelfReturnNode() { exit.getScope() instanceof ConstructorDecl }
420408

421-
override string toStringImpl() { result = param.toString() + "[constructor return]" }
422409
override ReturnKind getKind() { result instanceof NormalReturnKind }
423410
}
424411

0 commit comments

Comments
 (0)