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

Skip to content

Commit 689002a

Browse files
C++: Fix handling of Chi instructions in sign analysis
1 parent f4ce7b9 commit 689002a

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@ private Sign castSign(Sign s, boolean fromSigned, boolean toSigned, CastKind ck)
193193

194194
/** Holds if the sign of `e` is too complicated to determine. */
195195
private predicate unknownSign(Instruction i) {
196+
// REVIEW: This should probably be a list of the instructions that we _do_ understand, rather than
197+
// the ones we don't understand. Currently, if we try to compute the sign of an instruction that
198+
// we don't understand, and it isn't on this list, we incorrectly compute the sign as "none"
199+
// instead of "+,0,-".
200+
// Even better, we could track the state of each instruction as a power set of {non-negative,
201+
// non-positive, non-zero}, which would mean that the representation of the sign of an unknown
202+
// value would be the empty set.
196203
(
197204
i instanceof UnmodeledDefinitionInstruction
198205
or
@@ -203,6 +210,8 @@ private predicate unknownSign(Instruction i) {
203210
i instanceof BuiltInInstruction
204211
or
205212
i instanceof CallInstruction
213+
or
214+
i instanceof ChiInstruction
206215
)
207216
}
208217

0 commit comments

Comments
 (0)