File tree Expand file tree Collapse file tree
cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -257,11 +257,26 @@ private predicate usedAsCondition(Expr expr) {
257257 )
258258}
259259
260+ private predicate hasThrowingChild ( Expr e ) {
261+ e = any ( ThrowExpr throw ) .getFullyConverted ( )
262+ or
263+ exists ( Expr child |
264+ e = getRealParent ( child ) and
265+ hasThrowingChild ( child )
266+ )
267+ }
268+
260269private predicate isInConditionalEvaluation ( Expr e ) {
261270 exists ( ConditionalExpr cond |
262271 e = cond .getThen ( ) .getFullyConverted ( ) and not cond .isTwoOperand ( )
263272 or
264273 e = cond .getElse ( ) .getFullyConverted ( )
274+ or
275+ // If one of the operands throws then the temporaries constructed in either
276+ // branch will also be attached to the ternary expression. We suppress
277+ // those destructor calls as well.
278+ hasThrowingChild ( [ cond .getThen ( ) , cond .getElse ( ) ] ) and
279+ e = cond .getFullyConverted ( )
265280 )
266281 or
267282 isInConditionalEvaluation ( getRealParent ( e ) )
You can’t perform that action at this time.
0 commit comments