C++: Undo the hack.

This commit is contained in:
Mathias Vorreiter Pedersen
2026-01-26 19:19:13 +00:00
parent bd09aad7d5
commit e0a7889b71
3 changed files with 9 additions and 21 deletions

View File

@@ -432,23 +432,7 @@ private class DirectUseImpl extends UseImpl, TDirectUseImpl {
override string toString() { result = "Use of " + this.getSourceVariable() }
final override predicate hasIndexInBlock(IRBlock block, int index) {
// See the comment in `ssa0`'s `OperandBasedUse` for an explanation of this
// predicate's implementation.
if this.getBase().getAst() = any(Cpp::PostfixCrementOperation c).getOperand()
then
exists(Operand op, int indirection, Instruction base |
indirection = this.getIndirection() and
base = this.getBase() and
op =
min(Operand cand, int i |
isUse(_, cand, base, indirection, indirectionIndex) and
block.getInstruction(i) = cand.getUse()
|
cand order by i
) and
block.getInstruction(index) = op.getUse()
)
else operand.getUse() = block.getInstruction(index)
operand.getUse() = block.getInstruction(index)
}
private BaseSourceVariableInstruction getBase() { isUse(_, operand, result, _, indirectionIndex) }

View File

@@ -378,8 +378,11 @@ irFlow
| test.cpp:1195:10:1195:24 | *call to indirect_source | test.cpp:1224:19:1224:37 | ** ... |
| test.cpp:1195:10:1195:24 | *call to indirect_source | test.cpp:1227:10:1227:29 | * ... |
| test.cpp:1258:11:1258:16 | call to source | test.cpp:1259:8:1259:10 | ... ++ |
| test.cpp:1258:11:1258:16 | call to source | test.cpp:1260:8:1260:8 | x |
| test.cpp:1262:7:1262:12 | call to source | test.cpp:1263:8:1263:10 | ... -- |
| test.cpp:1262:7:1262:12 | call to source | test.cpp:1264:8:1264:8 | x |
| test.cpp:1284:11:1284:16 | call to source | test.cpp:1285:8:1285:20 | ... ? ... : ... |
| test.cpp:1284:11:1284:16 | call to source | test.cpp:1286:8:1286:8 | x |
| test.cpp:1288:7:1288:12 | call to source | test.cpp:1290:8:1290:8 | x |
| test.cpp:1292:7:1292:12 | call to source | test.cpp:1294:8:1294:8 | x |
| test.cpp:1296:7:1296:12 | call to source | test.cpp:1297:8:1297:18 | ... ? ... : ... |
@@ -388,6 +391,7 @@ irFlow
| test.cpp:1300:7:1300:12 | call to source | test.cpp:1302:8:1302:8 | x |
| test.cpp:1304:7:1304:12 | call to source | test.cpp:1306:8:1306:8 | x |
| test.cpp:1308:7:1308:12 | call to source | test.cpp:1309:8:1309:16 | ... ++ |
| test.cpp:1308:7:1308:12 | call to source | test.cpp:1310:8:1310:8 | x |
| test.cpp:1312:7:1312:12 | call to source | test.cpp:1313:8:1313:24 | ... ? ... : ... |
| test.cpp:1312:7:1312:12 | call to source | test.cpp:1314:8:1314:8 | x |
| true_upon_entry.cpp:9:11:9:16 | call to source | true_upon_entry.cpp:13:8:13:8 | x |

View File

@@ -1257,11 +1257,11 @@ namespace globals_without_explicit_def {
void crement_test1() {
int x = source();
sink(x++); // $ ir ast
sink(x);
sink(x); // $ SPURIOUS: ir
x = source();
sink(x--); // $ ir ast
sink(x);
sink(x); // $ SPURIOUS: ir
x = source();
sink(++x); // $ SPURIOUS: ast
@@ -1283,7 +1283,7 @@ void crement_test1() {
void crement_test2(bool b, int y) {
int x = source();
sink(b ? x++ : x--); // $ ir ast
sink(x);
sink(x); // $ SPURIOUS: ir
x = source();
sink((b ? x : y)++); // $ ast MISSING: ir
@@ -1307,7 +1307,7 @@ void crement_test2(bool b, int y) {
x = source();
sink((long)x++); // $ ir ast
sink(x);
sink(x); // $ SPURIOUS: ir
x = source();
sink(b ? (long)x++ : 0); // $ ir ast