Skip to content

Commit a97891c

Browse files
committed
C++: Add QLDoc to 'getNumberOfBinaryOperands' (and rename it to 'getNumberOfNestedBinaryOperands').
1 parent f36b483 commit a97891c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@ IRTempVariable getIRTempVariable(Locatable ast, TempVariableTag tag) {
4040
result.getTag() = tag
4141
}
4242

43+
/** Gets an operand of `binOp`. */
4344
private Expr getAnOperand(BinaryOperation binOp) { result = binOp.getAnOperand() }
4445

45-
private int getNumberOfBinaryOperands(BinaryOperation binOp) {
46+
/**
47+
* Gets the number of nested operands of `binOp`. For example,
48+
* `getNumberOfNestedBinaryOperands((1 + 2) + 3))` is `3`.
49+
*/
50+
private int getNumberOfNestedBinaryOperands(BinaryOperation binOp) {
4651
result = count(getAnOperand*(binOp))
4752
}
4853

@@ -60,7 +65,7 @@ predicate isIRConstant(Expr expr) {
6065
// But to avoid creating an outrageous amount of IR from very large
6166
// constant expressions we fall back to constant folding if the operation
6267
// has more than 50 operands (i.e., 1 + 2 + 3 + 4 + ... + 50)
63-
if expr instanceof BinaryOperation then getNumberOfBinaryOperands(expr) > 50 else any()
68+
if expr instanceof BinaryOperation then getNumberOfNestedBinaryOperands(expr) > 50 else any()
6469
}
6570

6671
// Pulled out for performance. See

0 commit comments

Comments
 (0)