File tree Expand file tree Collapse file tree
src/semmle/code/java/dataflow
test/library-tests/dataflow/fluent-methods Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,14 +46,14 @@ abstract class ValuePreservingMethod extends Method {
4646 * These steps will be visible for all global data-flow purposes, as well as via
4747 * `DataFlow::Node.getASuccessor` and other related functions exposing intraprocedural dataflow.
4848 */
49- abstract class FluentMethod extends ValuePreservingCallable {
49+ abstract class FluentMethod extends ValuePreservingMethod {
5050 override predicate returnsValue ( int arg ) { arg = - 1 }
5151}
5252
5353private class StandardLibraryValuePreservingMethod extends ValuePreservingMethod {
5454 int returnsArgNo ;
5555
56- StandardLibraryValuePreservingCallable ( ) {
56+ StandardLibraryValuePreservingMethod ( ) {
5757 this .getDeclaringType ( ) .hasQualifiedName ( "java.util" , "Objects" ) and
5858 (
5959 this .hasName ( [ "requireNonNull" , "requireNonNullElseGet" ] ) and returnsArgNo = 0
@@ -63,9 +63,7 @@ private class StandardLibraryValuePreservingMethod extends ValuePreservingMethod
6363 this .hasName ( "toString" ) and returnsArgNo = 1
6464 )
6565 or
66- this .getDeclaringType ( )
67- .getASourceSupertype * ( )
68- .hasQualifiedName ( "java.util" , "Stack" ) and
66+ this .getDeclaringType ( ) .getASourceSupertype * ( ) .hasQualifiedName ( "java.util" , "Stack" ) and
6967 this .hasName ( "push" ) and
7068 returnsArgNo = 0
7169 }
Original file line number Diff line number Diff line change @@ -409,15 +409,11 @@ predicate simpleLocalFlowStep(Node node1, Node node2) {
409409 or
410410 summaryStep ( node1 , node2 , "value" )
411411 or
412- exists ( MethodAccess ma , ValuePreservingCallable c , int argNo |
413- ma .getCallee ( ) .getSourceDeclaration ( ) = c and c .returnsValue ( argNo )
412+ exists ( MethodAccess ma , ValuePreservingMethod m , int argNo |
413+ ma .getCallee ( ) .getSourceDeclaration ( ) = m and m .returnsValue ( argNo )
414414 |
415415 node2 .asExpr ( ) = ma and
416- (
417- node1 .asExpr ( ) = ma .getArgument ( argNo )
418- or
419- argNo = - 1 and node1 .asExpr ( ) = ma .getQualifier ( )
420- )
416+ node1 .( ArgumentNode ) .argumentOf ( ma , argNo )
421417 )
422418}
423419
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ class Model extends FluentMethod {
1919 Model ( ) { this .getName ( ) = "modelledFluentMethod" }
2020}
2121
22- class IdentityModel extends ValuePreservingCallable {
22+ class IdentityModel extends ValuePreservingMethod {
2323 IdentityModel ( ) { this .getName ( ) = "modelledIdentity" }
2424
2525 override predicate returnsValue ( int arg ) { arg = 0 }
You can’t perform that action at this time.
0 commit comments