C++ IR: Move ErrorExpr filter to TranslatedElement

The convention in the IR translation is to handle all ignored
expressions in this central place.
This commit is contained in:
Jonas Jensen
2019-07-10 14:20:09 +02:00
parent 0889d5d27a
commit 70f81badcb
2 changed files with 7 additions and 8 deletions

View File

@@ -84,7 +84,13 @@ private predicate ignoreExprOnly(Expr expr) {
// Ignore the allocator call, because we always synthesize it. Don't ignore
// its arguments, though, because we use them as part of the synthesis.
newExpr.getAllocatorCall() = expr
) or
)
or
// The extractor deliberately emits an `ErrorExpr` as the first argument to
// the allocator call, if any, of a `NewOrNewArrayExpr`. That `ErrorExpr`
// should not be translated.
exists(NewOrNewArrayExpr new | expr = new.getAllocatorCall().getArgument(0))
or
not translateFunction(expr.getEnclosingFunction())
or
// We do not yet translate destructors properly, so for now we ignore the

View File

@@ -2866,13 +2866,6 @@ class TranslatedStmtExpr extends TranslatedNonConstantExpr {
class TranslatedErrorExpr extends TranslatedSingleInstructionExpr {
override ErrorExpr expr;
TranslatedErrorExpr() {
// The extractor deliberately emits an `ErrorExpr` as the first argument to
// the allocator call, if any, of a `NewOrNewArrayExpr`. That `ErrorExpr`
// should not be translated.
not exists(NewOrNewArrayExpr new | expr = new.getAllocatorCall().getArgument(0))
}
override final Instruction getFirstInstruction() {
result = getInstruction(OnlyInstructionTag())
}