Skip to content

Commit 6f5cfca

Browse files
committed
C++: Sync identical files.
1 parent cc261bf commit 6f5cfca

File tree

2 files changed

+46
-46
lines changed

2 files changed

+46
-46
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/constant/ConstantAnalysis.qll

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ int getConstantValue(Instruction instr) {
1212
or
1313
result = getConstantValue(instr.(CopyInstruction).getSourceValue())
1414
or
15+
getConstantValue(instr.(LogicalNotInstruction).getUnary()) != 0 and
16+
result = 0
17+
or
1518
exists(PhiInstruction phi |
1619
phi = instr and
1720
result = unique(Operand op | op = phi.getAnInputOperand() | getConstantValue(op.getDef()))
@@ -26,28 +29,25 @@ private predicate binaryInstructionOperands(BinaryInstruction instr, int left, i
2629

2730
pragma[noinline]
2831
private int getBinaryInstructionValue(BinaryInstruction instr) {
29-
exists(int left, int right |
30-
binaryInstructionOperands(instr, left, right) and
31-
(
32-
instr instanceof AddInstruction and result = add(left, right)
33-
or
34-
instr instanceof SubInstruction and result = sub(left, right)
35-
or
36-
instr instanceof MulInstruction and result = mul(left, right)
37-
or
38-
instr instanceof DivInstruction and result = div(left, right)
39-
or
40-
instr instanceof CompareEQInstruction and result = compareEQ(left, right)
41-
or
42-
instr instanceof CompareNEInstruction and result = compareNE(left, right)
43-
or
44-
instr instanceof CompareLTInstruction and result = compareLT(left, right)
45-
or
46-
instr instanceof CompareGTInstruction and result = compareGT(left, right)
47-
or
48-
instr instanceof CompareLEInstruction and result = compareLE(left, right)
49-
or
50-
instr instanceof CompareGEInstruction and result = compareGE(left, right)
51-
)
32+
exists(int left, int right | binaryInstructionOperands(instr, left, right) |
33+
instr instanceof AddInstruction and result = add(left, right)
34+
or
35+
instr instanceof SubInstruction and result = sub(left, right)
36+
or
37+
instr instanceof MulInstruction and result = mul(left, right)
38+
or
39+
instr instanceof DivInstruction and result = div(left, right)
40+
or
41+
instr instanceof CompareEQInstruction and result = compareEQ(left, right)
42+
or
43+
instr instanceof CompareNEInstruction and result = compareNE(left, right)
44+
or
45+
instr instanceof CompareLTInstruction and result = compareLT(left, right)
46+
or
47+
instr instanceof CompareGTInstruction and result = compareGT(left, right)
48+
or
49+
instr instanceof CompareLEInstruction and result = compareLE(left, right)
50+
or
51+
instr instanceof CompareGEInstruction and result = compareGE(left, right)
5252
)
5353
}

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/constant/ConstantAnalysis.qll

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ int getConstantValue(Instruction instr) {
1212
or
1313
result = getConstantValue(instr.(CopyInstruction).getSourceValue())
1414
or
15+
getConstantValue(instr.(LogicalNotInstruction).getUnary()) != 0 and
16+
result = 0
17+
or
1518
exists(PhiInstruction phi |
1619
phi = instr and
1720
result = unique(Operand op | op = phi.getAnInputOperand() | getConstantValue(op.getDef()))
@@ -26,28 +29,25 @@ private predicate binaryInstructionOperands(BinaryInstruction instr, int left, i
2629

2730
pragma[noinline]
2831
private int getBinaryInstructionValue(BinaryInstruction instr) {
29-
exists(int left, int right |
30-
binaryInstructionOperands(instr, left, right) and
31-
(
32-
instr instanceof AddInstruction and result = add(left, right)
33-
or
34-
instr instanceof SubInstruction and result = sub(left, right)
35-
or
36-
instr instanceof MulInstruction and result = mul(left, right)
37-
or
38-
instr instanceof DivInstruction and result = div(left, right)
39-
or
40-
instr instanceof CompareEQInstruction and result = compareEQ(left, right)
41-
or
42-
instr instanceof CompareNEInstruction and result = compareNE(left, right)
43-
or
44-
instr instanceof CompareLTInstruction and result = compareLT(left, right)
45-
or
46-
instr instanceof CompareGTInstruction and result = compareGT(left, right)
47-
or
48-
instr instanceof CompareLEInstruction and result = compareLE(left, right)
49-
or
50-
instr instanceof CompareGEInstruction and result = compareGE(left, right)
51-
)
32+
exists(int left, int right | binaryInstructionOperands(instr, left, right) |
33+
instr instanceof AddInstruction and result = add(left, right)
34+
or
35+
instr instanceof SubInstruction and result = sub(left, right)
36+
or
37+
instr instanceof MulInstruction and result = mul(left, right)
38+
or
39+
instr instanceof DivInstruction and result = div(left, right)
40+
or
41+
instr instanceof CompareEQInstruction and result = compareEQ(left, right)
42+
or
43+
instr instanceof CompareNEInstruction and result = compareNE(left, right)
44+
or
45+
instr instanceof CompareLTInstruction and result = compareLT(left, right)
46+
or
47+
instr instanceof CompareGTInstruction and result = compareGT(left, right)
48+
or
49+
instr instanceof CompareLEInstruction and result = compareLE(left, right)
50+
or
51+
instr instanceof CompareGEInstruction and result = compareGE(left, right)
5252
)
5353
}

0 commit comments

Comments
 (0)