Skip to content

Commit 2647630

Browse files
committed
Autoformat, address review.
1 parent bab893d commit 2647630

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

cpp/ql/src/experimental/semmle/code/cpp/rangeanalysis/ArrayLengthAnalysis.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private int getBaseSizeForPointerType(PointerType type) { result = type.getBaseT
124124
* steps to `array` that points to `offset + offsetDelta` in one step.
125125
* This predicate does not contain any recursive steps.
126126
*/
127-
bindingset[prevOffset,prevOffsetDelta]
127+
bindingset[prevOffset, prevOffsetDelta]
128128
predicate simpleArrayLengthStep(
129129
Instruction array, Offset offset, int offsetDelta, Instruction prev, Offset prevOffset,
130130
int prevOffsetDelta

cpp/ql/src/semmle/code/cpp/rangeanalysis/RangeUtils.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,28 @@ private predicate safeCast(IntegralType fromtyp, IntegralType totyp) {
104104
)
105105
}
106106

107+
/**
108+
* A `ConvertInstruction` which casts from one pointer type to another.
109+
*/
107110
class PtrToPtrCastInstruction extends ConvertInstruction {
108111
PtrToPtrCastInstruction() {
109112
getResultType() instanceof PointerType and
110113
getUnary().getResultType() instanceof PointerType
111114
}
112115
}
113116

117+
/**
118+
* A `ConvertInstruction` which casts from one integer type to another in a way
119+
* that cannot overflow or underflow.
120+
*/
114121
class SafeIntCastInstruction extends ConvertInstruction {
115122
SafeIntCastInstruction() { safeCast(getUnary().getResultType(), getResultType()) }
116123
}
117124

125+
/**
126+
* A `ConvertInstruction` which does not invalidate bounds determined by
127+
* range analysis.
128+
*/
118129
class SafeCastInstruction extends ConvertInstruction {
119130
SafeCastInstruction() {
120131
this instanceof PtrToPtrCastInstruction or

0 commit comments

Comments
 (0)