mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
C++: suppress destructors on conditional temporaries
This commit is contained in:
committed by
Mathias Vorreiter Pedersen
parent
894d934de8
commit
17e8c95e7f
@@ -127,6 +127,11 @@ private predicate ignoreExprAndDescendants(Expr expr) {
|
||||
exists(BuiltInVarArgsStart vaStartExpr |
|
||||
vaStartExpr.getLastNamedParameter().getFullyConverted() = expr
|
||||
)
|
||||
or
|
||||
// Do not translate implicit destructor calls for unnamed temporary variables that are
|
||||
// conditionally constructed (until we have a mechanism for calling these only when the
|
||||
// temporary's constructor was run)
|
||||
isConditionalTemporaryDestructorCall(expr)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,6 +257,20 @@ private predicate usedAsCondition(Expr expr) {
|
||||
)
|
||||
}
|
||||
|
||||
private predicate isInConditionalEvaluation(Expr e) {
|
||||
exists(ConditionalExpr cond |
|
||||
e = cond.getThen() and not cond.isTwoOperand()
|
||||
or
|
||||
e = cond.getElse()
|
||||
)
|
||||
or
|
||||
isInConditionalEvaluation(getRealParent(e))
|
||||
}
|
||||
|
||||
private predicate isConditionalTemporaryDestructorCall(DestructorCall dc) {
|
||||
isInConditionalEvaluation(dc.getQualifier().(ReuseExpr).getReusedExpr())
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `conv` is an `InheritanceConversion` that requires a `TranslatedLoad`, despite not being
|
||||
* marked as having an lvalue-to-rvalue conversion.
|
||||
|
||||
Reference in New Issue
Block a user