Skip to content

Commit 568cc63

Browse files
committed
C++: Add utility predicates.
1 parent ff527bd commit 568cc63

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,11 @@ class CallInstruction extends Instruction {
17141714
result = this.getPositionalArgumentOperand(index).getDef()
17151715
}
17161716

1717+
/**
1718+
* Gets a positional argument, if any.
1719+
*/
1720+
final Instruction getAPositionalArgument() { result = this.getPositionalArgument(_) }
1721+
17171722
/**
17181723
* Gets the argument operand at the specified index, or `this` if `index` is `-1`.
17191724
*/
@@ -1735,6 +1740,11 @@ class CallInstruction extends Instruction {
17351740
*/
17361741
final int getNumberOfArguments() { result = count(this.getAnArgumentOperand()) }
17371742

1743+
/**
1744+
* Gets the number of positional arguments of the call.
1745+
*/
1746+
final int getNumberOfPositionalArguments() { result = count(this.getAPositionalArgument()) }
1747+
17381748
/**
17391749
* Holds if the result is a side effect for the argument at the specified index, or `this` if
17401750
* `index` is `-1`.

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,11 @@ class CallInstruction extends Instruction {
17141714
result = this.getPositionalArgumentOperand(index).getDef()
17151715
}
17161716

1717+
/**
1718+
* Gets a positional argument, if any.
1719+
*/
1720+
final Instruction getAPositionalArgument() { result = this.getPositionalArgument(_) }
1721+
17171722
/**
17181723
* Gets the argument operand at the specified index, or `this` if `index` is `-1`.
17191724
*/
@@ -1735,6 +1740,11 @@ class CallInstruction extends Instruction {
17351740
*/
17361741
final int getNumberOfArguments() { result = count(this.getAnArgumentOperand()) }
17371742

1743+
/**
1744+
* Gets the number of positional arguments of the call.
1745+
*/
1746+
final int getNumberOfPositionalArguments() { result = count(this.getAPositionalArgument()) }
1747+
17381748
/**
17391749
* Holds if the result is a side effect for the argument at the specified index, or `this` if
17401750
* `index` is `-1`.

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,11 @@ class CallInstruction extends Instruction {
17141714
result = this.getPositionalArgumentOperand(index).getDef()
17151715
}
17161716

1717+
/**
1718+
* Gets a positional argument, if any.
1719+
*/
1720+
final Instruction getAPositionalArgument() { result = this.getPositionalArgument(_) }
1721+
17171722
/**
17181723
* Gets the argument operand at the specified index, or `this` if `index` is `-1`.
17191724
*/
@@ -1735,6 +1740,11 @@ class CallInstruction extends Instruction {
17351740
*/
17361741
final int getNumberOfArguments() { result = count(this.getAnArgumentOperand()) }
17371742

1743+
/**
1744+
* Gets the number of positional arguments of the call.
1745+
*/
1746+
final int getNumberOfPositionalArguments() { result = count(this.getAPositionalArgument()) }
1747+
17381748
/**
17391749
* Holds if the result is a side effect for the argument at the specified index, or `this` if
17401750
* `index` is `-1`.

0 commit comments

Comments
 (0)