Skip to content

Commit 4339e18

Browse files
committed
C++: Update IR generation for changes in frontend
1 parent 3145c53 commit 4339e18

File tree

1 file changed

+5
-43
lines changed

1 file changed

+5
-43
lines changed

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

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -648,19 +648,7 @@ abstract class TranslatedCrementOperation extends TranslatedNonConstantExpr {
648648
class TranslatedPrefixCrementOperation extends TranslatedCrementOperation {
649649
override PrefixCrementOperation expr;
650650

651-
override Instruction getResult() {
652-
if expr.isPRValueCategory()
653-
then
654-
// If this is C, then the result of a prefix crement is a prvalue for the
655-
// new value assigned to the operand. If this is C++, then the result is
656-
// an lvalue, but that lvalue is being loaded as part of this expression.
657-
// EDG doesn't mark this as a load.
658-
result = this.getInstruction(CrementOpTag())
659-
else
660-
// This is C++, where the result is an lvalue for the operand, and that
661-
// lvalue is not being loaded as part of this expression.
662-
result = this.getUnloadedOperand().getResult()
663-
}
651+
override Instruction getResult() { result = this.getUnloadedOperand().getResult() }
664652
}
665653

666654
class TranslatedPostfixCrementOperation extends TranslatedCrementOperation {
@@ -1503,19 +1491,7 @@ class TranslatedAssignExpr extends TranslatedNonConstantExpr {
15031491
result = this.getRightOperand().getFirstInstruction()
15041492
}
15051493

1506-
final override Instruction getResult() {
1507-
if expr.isPRValueCategory()
1508-
then
1509-
// If this is C, then the result of an assignment is a prvalue for the new
1510-
// value assigned to the left operand. If this is C++, then the result is
1511-
// an lvalue, but that lvalue is being loaded as part of this expression.
1512-
// EDG doesn't mark this as a load.
1513-
result = this.getRightOperand().getResult()
1514-
else
1515-
// This is C++, where the result is an lvalue for the left operand,
1516-
// and that lvalue is not being loaded as part of this expression.
1517-
result = this.getLeftOperand().getResult()
1518-
}
1494+
final override Instruction getResult() { result = this.getLeftOperand().getResult() }
15191495

15201496
final TranslatedExpr getLeftOperand() {
15211497
result = getTranslatedExpr(expr.getLValue().getFullyConverted())
@@ -1641,19 +1617,7 @@ class TranslatedAssignOperation extends TranslatedNonConstantExpr {
16411617
result = this.getRightOperand().getFirstInstruction()
16421618
}
16431619

1644-
final override Instruction getResult() {
1645-
if expr.isPRValueCategory()
1646-
then
1647-
// If this is C, then the result of an assignment is a prvalue for the new
1648-
// value assigned to the left operand. If this is C++, then the result is
1649-
// an lvalue, but that lvalue is being loaded as part of this expression.
1650-
// EDG doesn't mark this as a load.
1651-
result = this.getStoredValue()
1652-
else
1653-
// This is C++, where the result is an lvalue for the left operand,
1654-
// and that lvalue is not being loaded as part of this expression.
1655-
result = this.getUnloadedLeftOperand().getResult()
1656-
}
1620+
final override Instruction getResult() { result = this.getUnloadedLeftOperand().getResult() }
16571621

16581622
final TranslatedExpr getUnloadedLeftOperand() {
16591623
result = this.getLoadedLeftOperand().getOperand()
@@ -3237,11 +3201,9 @@ predicate exprNeedsCopyIfNotLoaded(Expr expr) {
32373201
(
32383202
expr instanceof AssignExpr
32393203
or
3240-
expr instanceof AssignOperation and
3241-
not expr.isPRValueCategory() // is C++
3204+
expr instanceof AssignOperation
32423205
or
3243-
expr instanceof PrefixCrementOperation and
3244-
not expr.isPRValueCategory() // is C++
3206+
expr instanceof PrefixCrementOperation
32453207
or
32463208
// Because the load is on the `e` in `e++`.
32473209
expr instanceof PostfixCrementOperation

0 commit comments

Comments
 (0)