Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e40ce91

Browse files
author
Robert Marsh
committed
C++: document new IR class and predicates
1 parent d6cea1b commit e40ce91

3 files changed

Lines changed: 57 additions & 3 deletions

File tree

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,13 +967,31 @@ class CompareNEInstruction extends CompareInstruction {
967967
}
968968
}
969969

970+
/**
971+
* Represents an instruction that does a relative comparison of two values, such as `<` or `>=`.
972+
*/
970973
class RelationalInstruction extends CompareInstruction {
971974
RelationalInstruction() {
972975
opcode instanceof RelationalOpcode
973976
}
974-
977+
/**
978+
* Gets the operand on the "greater" (or "greater-or-equal") side
979+
* of this relational instruction, that is, the side that is larger
980+
* if the overall instruction evaluates to `true`; for example on
981+
* `x <= 20` this is the `20`, and on `y > 0` it is `y`.
982+
*/
975983
abstract Instruction getGreaterOperand();
984+
985+
/**
986+
* Gets the operand on the "lesser" (or "lesser-or-equal") side
987+
* of this relational instruction, that is, the side that is smaller
988+
* if the overall instruction evaluates to `true`; for example on
989+
* `x <= 20` this is `x`, and on `y > 0` it is the `0`.
990+
*/
976991
abstract Instruction getLesserOperand();
992+
/**
993+
* Holds if this relational instruction is strict (is not an "or-equal" instruction).
994+
*/
977995
abstract predicate isStrict();
978996
}
979997

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,13 +967,31 @@ class CompareNEInstruction extends CompareInstruction {
967967
}
968968
}
969969

970+
/**
971+
* Represents an instruction that does a relative comparison of two values, such as `<` or `>=`.
972+
*/
970973
class RelationalInstruction extends CompareInstruction {
971974
RelationalInstruction() {
972975
opcode instanceof RelationalOpcode
973976
}
974-
977+
/**
978+
* Gets the operand on the "greater" (or "greater-or-equal") side
979+
* of this relational instruction, that is, the side that is larger
980+
* if the overall instruction evaluates to `true`; for example on
981+
* `x <= 20` this is the `20`, and on `y > 0` it is `y`.
982+
*/
975983
abstract Instruction getGreaterOperand();
984+
985+
/**
986+
* Gets the operand on the "lesser" (or "lesser-or-equal") side
987+
* of this relational instruction, that is, the side that is smaller
988+
* if the overall instruction evaluates to `true`; for example on
989+
* `x <= 20` this is `x`, and on `y > 0` it is the `0`.
990+
*/
976991
abstract Instruction getLesserOperand();
992+
/**
993+
* Holds if this relational instruction is strict (is not an "or-equal" instruction).
994+
*/
977995
abstract predicate isStrict();
978996
}
979997

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,13 +967,31 @@ class CompareNEInstruction extends CompareInstruction {
967967
}
968968
}
969969

970+
/**
971+
* Represents an instruction that does a relative comparison of two values, such as `<` or `>=`.
972+
*/
970973
class RelationalInstruction extends CompareInstruction {
971974
RelationalInstruction() {
972975
opcode instanceof RelationalOpcode
973976
}
974-
977+
/**
978+
* Gets the operand on the "greater" (or "greater-or-equal") side
979+
* of this relational instruction, that is, the side that is larger
980+
* if the overall instruction evaluates to `true`; for example on
981+
* `x <= 20` this is the `20`, and on `y > 0` it is `y`.
982+
*/
975983
abstract Instruction getGreaterOperand();
984+
985+
/**
986+
* Gets the operand on the "lesser" (or "lesser-or-equal") side
987+
* of this relational instruction, that is, the side that is smaller
988+
* if the overall instruction evaluates to `true`; for example on
989+
* `x <= 20` this is `x`, and on `y > 0` it is the `0`.
990+
*/
976991
abstract Instruction getLesserOperand();
992+
/**
993+
* Holds if this relational instruction is strict (is not an "or-equal" instruction).
994+
*/
977995
abstract predicate isStrict();
978996
}
979997

0 commit comments

Comments
 (0)