@@ -44,20 +44,22 @@ Expr clearlyNotNullExpr(Expr reason) {
44
44
or
45
45
result instanceof ArrayCreationExpr and reason = result
46
46
or
47
+ result instanceof FunctionalExpr and reason = result
48
+ or
47
49
result instanceof TypeLiteral and reason = result
48
50
or
49
51
result instanceof ThisAccess and reason = result
50
52
or
51
53
result instanceof StringLiteral and reason = result
52
54
or
55
+ // Add and AssignAdd performing String concatenation never have null result
53
56
result instanceof AddExpr and result .getType ( ) instanceof TypeString and reason = result
54
57
or
55
- exists ( Field f |
56
- result = f .getAnAccess ( ) and
57
- ( f .hasName ( "TRUE" ) or f .hasName ( "FALSE" ) ) and
58
- f .getDeclaringType ( ) .hasQualifiedName ( "java.lang" , "Boolean" ) and
59
- reason = result
60
- )
58
+ result instanceof AssignAddExpr and result .getType ( ) instanceof TypeString and reason = result
59
+ or
60
+ result .getType ( ) instanceof PrimitiveType and reason = result
61
+ or
62
+ result instanceof CompileTimeConstantExpr and reason = result
61
63
or
62
64
result .( CastExpr ) .getExpr ( ) = clearlyNotNullExpr ( reason )
63
65
or
@@ -70,6 +72,11 @@ Expr clearlyNotNullExpr(Expr reason) {
70
72
( reason = r1 or reason = r2 )
71
73
)
72
74
or
75
+ exists ( SwitchExpr s |
76
+ s = result and
77
+ forall ( Expr resultExpr | resultExpr = s .getAResult ( ) | resultExpr = clearlyNotNullExpr ( reason ) )
78
+ )
79
+ or
73
80
exists ( SsaVariable v , boolean branch , RValue rval , Guard guard |
74
81
guard = directNullGuard ( v , branch , false ) and
75
82
guard .controls ( rval .getBasicBlock ( ) , branch ) and
0 commit comments