Skip to content

Commit 70f81ba

Browse files
committed
C++ IR: Move ErrorExpr filter to TranslatedElement
The convention in the IR translation is to handle all ignored expressions in this central place.
1 parent 0889d5d commit 70f81ba

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@ private predicate ignoreExprOnly(Expr expr) {
8484
// Ignore the allocator call, because we always synthesize it. Don't ignore
8585
// its arguments, though, because we use them as part of the synthesis.
8686
newExpr.getAllocatorCall() = expr
87-
) or
87+
)
88+
or
89+
// The extractor deliberately emits an `ErrorExpr` as the first argument to
90+
// the allocator call, if any, of a `NewOrNewArrayExpr`. That `ErrorExpr`
91+
// should not be translated.
92+
exists(NewOrNewArrayExpr new | expr = new.getAllocatorCall().getArgument(0))
93+
or
8894
not translateFunction(expr.getEnclosingFunction())
8995
or
9096
// We do not yet translate destructors properly, so for now we ignore the

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,13 +2866,6 @@ class TranslatedStmtExpr extends TranslatedNonConstantExpr {
28662866
class TranslatedErrorExpr extends TranslatedSingleInstructionExpr {
28672867
override ErrorExpr expr;
28682868

2869-
TranslatedErrorExpr() {
2870-
// The extractor deliberately emits an `ErrorExpr` as the first argument to
2871-
// the allocator call, if any, of a `NewOrNewArrayExpr`. That `ErrorExpr`
2872-
// should not be translated.
2873-
not exists(NewOrNewArrayExpr new | expr = new.getAllocatorCall().getArgument(0))
2874-
}
2875-
28762869
override final Instruction getFirstInstruction() {
28772870
result = getInstruction(OnlyInstructionTag())
28782871
}

0 commit comments

Comments
 (0)