Skip to content

Commit cad4bac

Browse files
committed
C++: Concretize ConstantAnalysis NegateInstruction
This is just to make the QL shorter. It generates the same DIL.
1 parent be35c67 commit cad4bac

File tree

3 files changed

+3
-21
lines changed

3 files changed

+3
-21
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@ language[monotonicAggregates]
66
int getConstantValue(Instruction instr) {
77
result = instr.(IntegerConstantInstruction).getValue().toInt() or
88
result = getBinaryInstructionValue(instr) or
9-
exists(UnaryInstruction unaryInstr, int src |
10-
unaryInstr = instr and
11-
src = getConstantValue(unaryInstr.getOperand()) and
12-
(
13-
unaryInstr instanceof NegateInstruction and result = neg(src)
14-
)
15-
) or
9+
result = neg(getConstantValue(instr.(NegateInstruction).getOperand())) or
1610
result = getConstantValue(instr.(CopyInstruction).getSourceValue()) or
1711
exists(PhiInstruction phi |
1812
phi = instr and

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/constant/ConstantAnalysis.qll

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@ language[monotonicAggregates]
66
int getConstantValue(Instruction instr) {
77
result = instr.(IntegerConstantInstruction).getValue().toInt() or
88
result = getBinaryInstructionValue(instr) or
9-
exists(UnaryInstruction unaryInstr, int src |
10-
unaryInstr = instr and
11-
src = getConstantValue(unaryInstr.getOperand()) and
12-
(
13-
unaryInstr instanceof NegateInstruction and result = neg(src)
14-
)
15-
) or
9+
result = neg(getConstantValue(instr.(NegateInstruction).getOperand())) or
1610
result = getConstantValue(instr.(CopyInstruction).getSourceValue()) or
1711
exists(PhiInstruction phi |
1812
phi = instr and

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@ language[monotonicAggregates]
66
int getConstantValue(Instruction instr) {
77
result = instr.(IntegerConstantInstruction).getValue().toInt() or
88
result = getBinaryInstructionValue(instr) or
9-
exists(UnaryInstruction unaryInstr, int src |
10-
unaryInstr = instr and
11-
src = getConstantValue(unaryInstr.getOperand()) and
12-
(
13-
unaryInstr instanceof NegateInstruction and result = neg(src)
14-
)
15-
) or
9+
result = neg(getConstantValue(instr.(NegateInstruction).getOperand())) or
1610
result = getConstantValue(instr.(CopyInstruction).getSourceValue()) or
1711
exists(PhiInstruction phi |
1812
phi = instr and

0 commit comments

Comments
 (0)