File tree Expand file tree Collapse file tree
csharp/ql/src/semmle/code/csharp/dataflow/internal/rangeanalysis
java/ql/src/semmle/code/java/dataflow/internal/rangeanalysis Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -245,6 +245,13 @@ private Sign ssaDefSign(SsaVariable v) {
245245 )
246246}
247247
248+ /** Returns the sign of implicit SSA definition `v`. */
249+ private Sign implicitSsaDefSign ( SsaVariable v ) {
250+ result = fieldSign ( getImplicitSsaDeclaration ( v ) )
251+ or
252+ anySign ( result ) and nonFieldImplicitSsaDefinition ( v )
253+ }
254+
248255/** Gets a possible sign for `e`. */
249256cached
250257Sign exprSign ( Expr e ) {
Original file line number Diff line number Diff line change @@ -122,11 +122,14 @@ private module Impl {
122122 )
123123 }
124124
125- /** Returns the sign of implicit SSA definition `v`. */
126- Sign implicitSsaDefSign ( Ssa:: ImplicitDefinition v ) {
127- result = fieldSign ( v .getSourceVariable ( ) .getAssignable ( ) )
128- or
129- anySign ( result ) and not v .getSourceVariable ( ) .getAssignable ( ) instanceof Field
125+ /** Gets the variable underlying the implicit SSA variable `v`. */
126+ Declaration getImplicitSsaDeclaration ( Ssa:: ImplicitDefinition v ) {
127+ result = v .getSourceVariable ( ) .getAssignable ( )
128+ }
129+
130+ /** Holds if the variable underlying the implicit SSA variable `v` is not a field. */
131+ predicate nonFieldImplicitSsaDefinition ( Ssa:: ImplicitDefinition v ) {
132+ not getImplicitSsaDeclaration ( v ) instanceof Field
130133 }
131134
132135 /** Gets a possible sign for `f`. */
Original file line number Diff line number Diff line change @@ -245,6 +245,13 @@ private Sign ssaDefSign(SsaVariable v) {
245245 )
246246}
247247
248+ /** Returns the sign of implicit SSA definition `v`. */
249+ private Sign implicitSsaDefSign ( SsaVariable v ) {
250+ result = fieldSign ( getImplicitSsaDeclaration ( v ) )
251+ or
252+ anySign ( result ) and nonFieldImplicitSsaDefinition ( v )
253+ }
254+
248255/** Gets a possible sign for `e`. */
249256cached
250257Sign exprSign ( Expr e ) {
Original file line number Diff line number Diff line change @@ -115,13 +115,15 @@ private module Impl {
115115 )
116116 }
117117
118- /** Returns the sign of implicit SSA definition `v`. */
119- Sign implicitSsaDefSign ( SsaVariable v ) {
120- result = fieldSign ( v .( SsaImplicitUpdate ) .getSourceVariable ( ) .getVariable ( ) )
121- or
122- result = fieldSign ( v .( SsaImplicitInit ) .getSourceVariable ( ) .getVariable ( ) )
123- or
124- anySign ( result ) and exists ( Parameter p | v .( SsaImplicitInit ) .isParameterDefinition ( p ) )
118+ /** Gets the variable underlying the implicit SSA variable `v`. */
119+ Variable getImplicitSsaDeclaration ( SsaVariable v ) {
120+ result = v .( SsaImplicitUpdate ) .getSourceVariable ( ) .getVariable ( ) or
121+ result = v .( SsaImplicitInit ) .getSourceVariable ( ) .getVariable ( )
122+ }
123+
124+ /** Holds if the variable underlying the implicit SSA variable `v` is not a field. */
125+ predicate nonFieldImplicitSsaDefinition ( SsaImplicitInit v ) {
126+ exists ( Parameter p | v .isParameterDefinition ( p ) )
125127 }
126128
127129 /** Gets a possible sign for `f`. */
You can’t perform that action at this time.
0 commit comments