@@ -850,11 +850,6 @@ module Public {
850850 {
851851 ThisParameterInstructionNode ( ) { instr .getIRVariable ( ) instanceof IRThisVariable }
852852
853- override predicate isSourceParameterOf ( Function f , ParameterPosition pos ) {
854- pos .( DirectPosition ) .getArgumentIndex ( ) = - 1 and
855- instr .getEnclosingFunction ( ) = f
856- }
857-
858853 override string toStringImpl ( ) { result = "this" }
859854 }
860855
@@ -1129,7 +1124,7 @@ class IndirectArgumentOutNode extends PostUpdateNodeImpl {
11291124 /**
11301125 * Gets the `Function` that the call targets, if this is statically known.
11311126 */
1132- Function getStaticCallTarget ( ) { result = this .getCallInstruction ( ) .getStaticCallTarget ( ) }
1127+ Declaration getStaticCallTarget ( ) { result = this .getCallInstruction ( ) .getStaticCallTarget ( ) }
11331128
11341129 override string toStringImpl ( ) {
11351130 exists ( string prefix | if indirectionIndex > 0 then prefix = "" else prefix = "pointer to " |
@@ -1633,7 +1628,7 @@ abstract private class AbstractParameterNode extends Node {
16331628 * implicit `this` parameter is considered to have position `-1`, and
16341629 * pointer-indirection parameters are at further negative positions.
16351630 */
1636- predicate isSourceParameterOf ( Function f , ParameterPosition pos ) { none ( ) }
1631+ predicate isSourceParameterOf ( Declaration f , ParameterPosition pos ) { none ( ) }
16371632
16381633 /**
16391634 * Holds if this node is the parameter of `sc` at the specified position. The
@@ -1659,6 +1654,11 @@ abstract private class AbstractParameterNode extends Node {
16591654
16601655 /** Gets the `Parameter` associated with this node, if it exists. */
16611656 Parameter getParameter ( ) { none ( ) } // overridden by subclasses
1657+
1658+ /**
1659+ * Holds if this node represents an implicit `this` parameter, if it exists.
1660+ */
1661+ predicate isThis ( ) { none ( ) } // overridden by subclasses
16621662}
16631663
16641664abstract private class AbstractIndirectParameterNode extends AbstractParameterNode {
@@ -1687,7 +1687,9 @@ private class IndirectInstructionParameterNode extends AbstractIndirectParameter
16871687 InitializeParameterInstruction init ;
16881688
16891689 IndirectInstructionParameterNode ( ) {
1690- IndirectInstruction .super .hasInstructionAndIndirectionIndex ( init , _)
1690+ IndirectInstruction .super .hasInstructionAndIndirectionIndex ( init , _) and
1691+ // We don't model catch parameters as parameter nodes
1692+ not exists ( init .getParameter ( ) .getCatchBlock ( ) )
16911693 }
16921694
16931695 int getArgumentIndex ( ) { init .hasIndex ( result ) }
@@ -1701,16 +1703,17 @@ private class IndirectInstructionParameterNode extends AbstractIndirectParameter
17011703 )
17021704 }
17031705
1704- /** Gets the parameter whose indirection is initialized. */
17051706 override Parameter getParameter ( ) { result = init .getParameter ( ) }
17061707
1708+ override predicate isThis ( ) { init .hasIndex ( - 1 ) }
1709+
17071710 override DataFlowCallable getEnclosingCallable ( ) {
17081711 result .asSourceCallable ( ) = this .getFunction ( )
17091712 }
17101713
17111714 override Declaration getFunction ( ) { result = init .getEnclosingFunction ( ) }
17121715
1713- override predicate isSourceParameterOf ( Function f , ParameterPosition pos ) {
1716+ override predicate isSourceParameterOf ( Declaration f , ParameterPosition pos ) {
17141717 this .getFunction ( ) = f and
17151718 exists ( int argumentIndex , int indirectionIndex |
17161719 indirectPositionHasArgumentIndexAndIndex ( pos , argumentIndex , indirectionIndex ) and
@@ -1738,6 +1741,18 @@ abstract class InstructionDirectParameterNode extends InstructionNode, AbstractD
17381741 * Gets the `IRVariable` that this parameter references.
17391742 */
17401743 final IRVariable getIRVariable ( ) { result = instr .getIRVariable ( ) }
1744+
1745+ override predicate isThis ( ) { instr .hasIndex ( - 1 ) }
1746+
1747+ override Parameter getParameter ( ) { result = instr .getParameter ( ) }
1748+
1749+ override predicate isSourceParameterOf ( Declaration f , ParameterPosition pos ) {
1750+ this .getFunction ( ) = f and
1751+ exists ( int argumentIndex |
1752+ pos .( DirectPosition ) .getArgumentIndex ( ) = argumentIndex and
1753+ instr .hasIndex ( argumentIndex )
1754+ )
1755+ }
17411756}
17421757
17431758abstract private class AbstractExplicitParameterNode extends AbstractDirectParameterNode { }
@@ -1746,15 +1761,12 @@ abstract private class AbstractExplicitParameterNode extends AbstractDirectParam
17461761private class ExplicitParameterInstructionNode extends AbstractExplicitParameterNode ,
17471762 InstructionDirectParameterNode
17481763{
1749- ExplicitParameterInstructionNode ( ) { exists ( instr .getParameter ( ) ) }
1750-
1751- override predicate isSourceParameterOf ( Function f , ParameterPosition pos ) {
1752- f .getParameter ( pos .( DirectPosition ) .getArgumentIndex ( ) ) = instr .getParameter ( )
1764+ ExplicitParameterInstructionNode ( ) {
1765+ // We don't model catch parameters as parameter nodes.
1766+ exists ( instr .getParameter ( ) .getFunction ( ) )
17531767 }
17541768
17551769 override string toStringImpl ( ) { result = instr .getParameter ( ) .toString ( ) }
1756-
1757- override Parameter getParameter ( ) { result = instr .getParameter ( ) }
17581770}
17591771
17601772/**
@@ -1782,9 +1794,9 @@ private class DirectBodyLessParameterNode extends AbstractExplicitParameterNode,
17821794{
17831795 DirectBodyLessParameterNode ( ) { indirectionIndex = 0 }
17841796
1785- override predicate isSourceParameterOf ( Function f , ParameterPosition pos ) {
1797+ override predicate isSourceParameterOf ( Declaration f , ParameterPosition pos ) {
17861798 this .getFunction ( ) = f and
1787- f .getParameter ( pos .( DirectPosition ) .getArgumentIndex ( ) ) = p
1799+ f .( Function ) . getParameter ( pos .( DirectPosition ) .getArgumentIndex ( ) ) = p
17881800 }
17891801
17901802 override Parameter getParameter ( ) { result = p }
@@ -1795,10 +1807,10 @@ private class IndirectBodyLessParameterNode extends AbstractIndirectParameterNod
17951807{
17961808 IndirectBodyLessParameterNode ( ) { not this instanceof DirectBodyLessParameterNode }
17971809
1798- override predicate isSourceParameterOf ( Function f , ParameterPosition pos ) {
1810+ override predicate isSourceParameterOf ( Declaration f , ParameterPosition pos ) {
17991811 exists ( int argumentPosition |
18001812 this .getFunction ( ) = f and
1801- f .getParameter ( argumentPosition ) = p and
1813+ f .( Function ) . getParameter ( argumentPosition ) = p and
18021814 indirectPositionHasArgumentIndexAndIndex ( pos , argumentPosition , indirectionIndex )
18031815 )
18041816 }
0 commit comments