mirror of
https://github.com/github/codeql.git
synced 2025-12-22 11:46:32 +01:00
C++: Two fixes to ensure we don't use getUniqueId in the new range analysis library. (1) don't use it to rank basic blocks, and (2) don't use it in 'toString' on bounds.
This commit is contained in:
@@ -73,7 +73,7 @@ class ValueNumberBound extends Bound, TBoundValueNumber {
|
|||||||
this = TBoundValueNumber(valueNumber(result)) and delta = 0
|
this = TBoundValueNumber(valueNumber(result)) and delta = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
override string toString() { result = vn.getExampleInstruction().toString() }
|
override string toString() { result = "ValueNumberBound" }
|
||||||
|
|
||||||
override Location getLocation() { result = vn.getLocation() }
|
override Location getLocation() { result = vn.getLocation() }
|
||||||
|
|
||||||
|
|||||||
@@ -112,12 +112,11 @@ module SemanticExprConfig {
|
|||||||
|
|
||||||
predicate hasDominanceInformation(BasicBlock block) { any() }
|
predicate hasDominanceInformation(BasicBlock block) { any() }
|
||||||
|
|
||||||
int getBasicBlockUniqueId(BasicBlock block) {
|
private predicate id(Cpp::Locatable x, Cpp::Locatable y) { x = y }
|
||||||
// REVIEW: `getDisplayIndex()` is not intended for use in real queries, but for now it's the
|
|
||||||
// best we can do because `equivalentRelation` won't accept a predicate whose parameters are IPA
|
private predicate idOf(Cpp::Locatable x, int y) = equivalenceRelation(id/2)(x, y)
|
||||||
// types.
|
|
||||||
result = block.getDisplayIndex()
|
int getBasicBlockUniqueId(BasicBlock block) { idOf(block.getFirstInstruction().getAst(), result) }
|
||||||
}
|
|
||||||
|
|
||||||
newtype TSsaVariable =
|
newtype TSsaVariable =
|
||||||
TSsaInstruction(IR::Instruction instr) { instr.hasMemoryResult() } or
|
TSsaInstruction(IR::Instruction instr) { instr.hasMemoryResult() } or
|
||||||
@@ -267,17 +266,7 @@ module SemanticExprConfig {
|
|||||||
|
|
||||||
ValueNumberBound() { bound = this }
|
ValueNumberBound() { bound = this }
|
||||||
|
|
||||||
override string toString() {
|
override string toString() { result = bound.toString() }
|
||||||
result =
|
|
||||||
min(SsaVariable v |
|
|
||||||
v.asInstruction() = bound.getValueNumber().getAnInstruction()
|
|
||||||
|
|
|
||||||
v
|
|
||||||
order by
|
|
||||||
v.asInstruction().getBlock().getDisplayIndex(),
|
|
||||||
v.asInstruction().getDisplayIndexInBlock()
|
|
||||||
).toString()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
predicate zeroBound(Bound bound) { bound instanceof IRBound::ZeroBound }
|
predicate zeroBound(Bound bound) { bound instanceof IRBound::ZeroBound }
|
||||||
|
|||||||
Reference in New Issue
Block a user