@@ -398,6 +398,30 @@ abstract class FluentMethod extends ValuePreservingCallable {
398
398
override predicate returnsValue ( int arg ) { arg = - 1 }
399
399
}
400
400
401
+ private class StandardLibraryValuePreservingCallable extends ValuePreservingCallable {
402
+ int returnsArgNo ;
403
+
404
+ StandardLibraryValuePreservingCallable ( ) {
405
+ this .getDeclaringType ( ) .hasQualifiedName ( "java.util" , "Objects" ) and
406
+ (
407
+ this .hasName ( [ "requireNonNull" , "requireNonNullElseGet" ] ) and returnsArgNo = 0
408
+ or
409
+ this .hasName ( "requireNonNullElse" ) and returnsArgNo = [ 0 .. this .getNumberOfParameters ( ) - 1 ]
410
+ or
411
+ this .hasName ( "toString" ) and returnsArgNo = 1
412
+ )
413
+ or
414
+ this .getDeclaringType ( )
415
+ .getSourceDeclaration ( )
416
+ .getASourceSupertype * ( )
417
+ .hasQualifiedName ( "java.util" , "Stack" ) and
418
+ this .hasName ( "push" ) and
419
+ returnsArgNo = 0
420
+ }
421
+
422
+ override predicate returnsValue ( int argNo ) { argNo = returnsArgNo }
423
+ }
424
+
401
425
/**
402
426
* INTERNAL: do not use.
403
427
*
@@ -448,30 +472,6 @@ predicate simpleLocalFlowStep(Node node1, Node node2) {
448
472
argNo = - 1 and node1 .asExpr ( ) = ma .getQualifier ( )
449
473
)
450
474
)
451
- or
452
- exists ( MethodAccess ma , Method m |
453
- ma = node2 .asExpr ( ) and
454
- m = ma .getMethod ( ) and
455
- m .getDeclaringType ( ) .hasQualifiedName ( "java.util" , "Objects" ) and
456
- (
457
- m .hasName ( [ "requireNonNull" , "requireNonNullElseGet" ] ) and node1 .asExpr ( ) = ma .getArgument ( 0 )
458
- or
459
- m .hasName ( "requireNonNullElse" ) and node1 .asExpr ( ) = ma .getAnArgument ( )
460
- or
461
- m .hasName ( "toString" ) and node1 .asExpr ( ) = ma .getArgument ( 1 )
462
- )
463
- )
464
- or
465
- exists ( MethodAccess ma , Method m |
466
- ma = node2 .asExpr ( ) and
467
- m = ma .getMethod ( ) and
468
- m .getDeclaringType ( )
469
- .getSourceDeclaration ( )
470
- .getASourceSupertype * ( )
471
- .hasQualifiedName ( "java.util" , "Stack" ) and
472
- m .hasName ( "push" ) and
473
- node1 .asExpr ( ) = ma .getArgument ( 0 )
474
- )
475
475
}
476
476
477
477
/**
0 commit comments