File tree Expand file tree Collapse file tree 3 files changed +7
-13
lines changed
src/semmle/code/java/dataflow
test/library-tests/dataflow/fluent-methods Expand file tree Collapse file tree 3 files changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -46,14 +46,14 @@ abstract class ValuePreservingMethod extends Method {
46
46
* These steps will be visible for all global data-flow purposes, as well as via
47
47
* `DataFlow::Node.getASuccessor` and other related functions exposing intraprocedural dataflow.
48
48
*/
49
- abstract class FluentMethod extends ValuePreservingCallable {
49
+ abstract class FluentMethod extends ValuePreservingMethod {
50
50
override predicate returnsValue ( int arg ) { arg = - 1 }
51
51
}
52
52
53
53
private class StandardLibraryValuePreservingMethod extends ValuePreservingMethod {
54
54
int returnsArgNo ;
55
55
56
- StandardLibraryValuePreservingCallable ( ) {
56
+ StandardLibraryValuePreservingMethod ( ) {
57
57
this .getDeclaringType ( ) .hasQualifiedName ( "java.util" , "Objects" ) and
58
58
(
59
59
this .hasName ( [ "requireNonNull" , "requireNonNullElseGet" ] ) and returnsArgNo = 0
@@ -63,9 +63,7 @@ private class StandardLibraryValuePreservingMethod extends ValuePreservingMethod
63
63
this .hasName ( "toString" ) and returnsArgNo = 1
64
64
)
65
65
or
66
- this .getDeclaringType ( )
67
- .getASourceSupertype * ( )
68
- .hasQualifiedName ( "java.util" , "Stack" ) and
66
+ this .getDeclaringType ( ) .getASourceSupertype * ( ) .hasQualifiedName ( "java.util" , "Stack" ) and
69
67
this .hasName ( "push" ) and
70
68
returnsArgNo = 0
71
69
}
Original file line number Diff line number Diff line change @@ -409,15 +409,11 @@ predicate simpleLocalFlowStep(Node node1, Node node2) {
409
409
or
410
410
summaryStep ( node1 , node2 , "value" )
411
411
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 )
414
414
|
415
415
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 )
421
417
)
422
418
}
423
419
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ class Model extends FluentMethod {
19
19
Model ( ) { this .getName ( ) = "modelledFluentMethod" }
20
20
}
21
21
22
- class IdentityModel extends ValuePreservingCallable {
22
+ class IdentityModel extends ValuePreservingMethod {
23
23
IdentityModel ( ) { this .getName ( ) = "modelledIdentity" }
24
24
25
25
override predicate returnsValue ( int arg ) { arg = 0 }
You can’t perform that action at this time.
0 commit comments