|
| 1 | +import cpp |
| 2 | + |
| 3 | +query predicate bodies(RangeBasedForStmt rbf, Stmt body) { body = rbf.getStmt() } |
| 4 | + |
| 5 | +query predicate variables(RangeBasedForStmt rbf, LocalVariable v, Type t) { |
| 6 | + v = rbf.getVariable() and |
| 7 | + t = v.getType() |
| 8 | +} |
| 9 | + |
| 10 | +query predicate ranges(RangeBasedForStmt rbf, Expr range, Type t) { |
| 11 | + range = rbf.getRange() and |
| 12 | + t = range.getType() |
| 13 | +} |
| 14 | + |
| 15 | +query predicate rangeVariables(RangeBasedForStmt rbf, LocalVariable rangeVar, Type t) { |
| 16 | + rangeVar = rbf.getRangeVariable() and |
| 17 | + t = rangeVar.getType() |
| 18 | +} |
| 19 | + |
| 20 | +query predicate conditions(RangeBasedForStmt rbf, Expr condition, Expr left, Expr right) { |
| 21 | + condition = rbf.getCondition() and |
| 22 | + ( |
| 23 | + condition instanceof BinaryOperation and |
| 24 | + left = condition.(BinaryOperation).getLeftOperand() and |
| 25 | + right = condition.(BinaryOperation).getRightOperand() |
| 26 | + or |
| 27 | + condition instanceof FunctionCall and |
| 28 | + left = condition.(FunctionCall).getQualifier() and |
| 29 | + right = condition.(FunctionCall).getArgument(0) |
| 30 | + ) |
| 31 | +} |
| 32 | + |
| 33 | +query predicate beginVariables(RangeBasedForStmt rbf, LocalVariable beginVar, Type t) { |
| 34 | + beginVar = rbf.getBeginVariable() and |
| 35 | + t = beginVar.getType() |
| 36 | +} |
| 37 | + |
| 38 | +query predicate endVariables(RangeBasedForStmt rbf, LocalVariable endVar, Type t) { |
| 39 | + endVar = rbf.getEndVariable() and |
| 40 | + t = endVar.getType() |
| 41 | +} |
| 42 | + |
| 43 | +query predicate updates(RangeBasedForStmt rbf, Expr update, Expr operand) { |
| 44 | + update = rbf.getUpdate() and |
| 45 | + ( |
| 46 | + update instanceof UnaryOperation and |
| 47 | + operand = update.(UnaryOperation).getOperand() |
| 48 | + or |
| 49 | + update instanceof FunctionCall and |
| 50 | + operand = update.(FunctionCall).getQualifier() |
| 51 | + ) |
| 52 | +} |
0 commit comments