@@ -23,16 +23,20 @@ class DeleteOrDeleteArrayExpr extends Expr {
23
23
DeallocationFunction getDeallocator ( ) {
24
24
result = [ this .( DeleteExpr ) .getDeallocator ( ) , this .( DeleteArrayExpr ) .getDeallocator ( ) ]
25
25
}
26
+
27
+ Destructor getDestructor ( ) {
28
+ result = [ this .( DeleteExpr ) .getDestructor ( ) , this .( DeleteArrayExpr ) .getDestructor ( ) ]
29
+ }
26
30
}
27
31
28
32
/** Gets the `Constructor` invoked when `newExpr` allocates memory. */
29
33
Constructor getConstructorForAllocation ( NewOrNewArrayExpr newExpr ) {
30
- result .getACallToThisFunction ( ) . getLocation ( ) = newExpr .getLocation ( )
34
+ result .getACallToThisFunction ( ) = newExpr .getInitializer ( )
31
35
}
32
36
33
37
/** Gets the `Destructor` invoked when `deleteExpr` deallocates memory. */
34
38
Destructor getDestructorForDeallocation ( DeleteOrDeleteArrayExpr deleteExpr ) {
35
- result . getACallToThisFunction ( ) . getLocation ( ) = deleteExpr .getLocation ( )
39
+ result = deleteExpr .getDestructor ( )
36
40
}
37
41
38
42
/** Holds if the evaluation of `newExpr` may throw an exception. */
@@ -63,15 +67,45 @@ predicate stmtMayThrow(Stmt stmt) {
63
67
or
64
68
convertedExprMayThrow ( stmt .( ExprStmt ) .getExpr ( ) )
65
69
or
70
+ convertedExprMayThrow ( stmt .( DeclStmt ) .getADeclaration ( ) .( Variable ) .getInitializer ( ) .getExpr ( ) )
71
+ or
66
72
exists ( IfStmt ifStmt | ifStmt = stmt |
67
73
convertedExprMayThrow ( ifStmt .getCondition ( ) ) or
68
74
stmtMayThrow ( [ ifStmt .getThen ( ) , ifStmt .getElse ( ) ] )
69
75
)
70
76
or
77
+ exists ( ConstexprIfStmt constIfStmt | constIfStmt = stmt |
78
+ stmtMayThrow ( [ constIfStmt .getThen ( ) , constIfStmt .getElse ( ) ] )
79
+ )
80
+ or
71
81
exists ( Loop loop | loop = stmt |
72
82
convertedExprMayThrow ( loop .getCondition ( ) ) or
73
83
stmtMayThrow ( loop .getStmt ( ) )
74
84
)
85
+ or
86
+ // The case for `Loop` already checked the condition and the statement.
87
+ convertedExprMayThrow ( stmt .( RangeBasedForStmt ) .getUpdate ( ) )
88
+ or
89
+ // The case for `Loop` already checked the condition and the statement.
90
+ exists ( ForStmt forStmt | forStmt = stmt |
91
+ stmtMayThrow ( forStmt .getInitialization ( ) )
92
+ or
93
+ convertedExprMayThrow ( forStmt .getUpdate ( ) )
94
+ )
95
+ or
96
+ exists ( SwitchStmt switchStmt | switchStmt = stmt |
97
+ convertedExprMayThrow ( switchStmt .getExpr ( ) ) or
98
+ stmtMayThrow ( switchStmt .getStmt ( ) )
99
+ )
100
+ or
101
+ stmtMayThrow ( stmt .( SwitchCase ) .getAStmt ( ) )
102
+ or
103
+ // NOTE: We don't include `TryStmt` as those exceptions are not "observable" outside the function.
104
+ stmtMayThrow ( stmt .( Handler ) .getBlock ( ) )
105
+ or
106
+ convertedExprMayThrow ( stmt .( CoReturnStmt ) .getExpr ( ) )
107
+ or
108
+ convertedExprMayThrow ( stmt .( ReturnStmt ) .getExpr ( ) )
75
109
}
76
110
77
111
/** Holds if the evaluation of `e` (including conversions) may throw an exception. */
0 commit comments