Skip to content

Commit cad003a

Browse files
authored
Merge pull request #14732 from aschackmull/cpp/range-ssa
C++: Fix operand ssa variables for range analysis.
2 parents c060827 + abe0bb7 commit cad003a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

cpp/ql/lib/semmle/code/cpp/rangeanalysis/new/internal/semantic/SemanticExprSpecific.qll

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ module SemanticExprConfig {
130130

131131
newtype TSsaVariable =
132132
TSsaInstruction(IR::Instruction instr) { instr.hasMemoryResult() } or
133-
TSsaOperand(IR::Operand op) { op.isDefinitionInexact() }
133+
TSsaOperand(IR::PhiInputOperand op) { op.isDefinitionInexact() }
134134

135135
class SsaVariable extends TSsaVariable {
136136
string toString() { none() }
@@ -139,7 +139,7 @@ module SemanticExprConfig {
139139

140140
IR::Instruction asInstruction() { none() }
141141

142-
IR::Operand asOperand() { none() }
142+
IR::PhiInputOperand asOperand() { none() }
143143
}
144144

145145
class SsaInstructionVariable extends SsaVariable, TSsaInstruction {
@@ -155,15 +155,15 @@ module SemanticExprConfig {
155155
}
156156

157157
class SsaOperand extends SsaVariable, TSsaOperand {
158-
IR::Operand op;
158+
IR::PhiInputOperand op;
159159

160160
SsaOperand() { this = TSsaOperand(op) }
161161

162162
final override string toString() { result = op.toString() }
163163

164164
final override Location getLocation() { result = op.getLocation() }
165165

166-
final override IR::Operand asOperand() { result = op }
166+
final override IR::PhiInputOperand asOperand() { result = op }
167167
}
168168

169169
predicate explicitUpdate(SsaVariable v, Expr sourceExpr) {
@@ -190,12 +190,14 @@ module SemanticExprConfig {
190190

191191
SemType getSsaVariableType(SsaVariable v) {
192192
result = getSemanticType(v.asInstruction().getResultIRType())
193+
or
194+
result = getSemanticType(v.asOperand().getUse().getResultIRType())
193195
}
194196

195197
BasicBlock getSsaVariableBasicBlock(SsaVariable v) {
196198
result = v.asInstruction().getBlock()
197199
or
198-
result = v.asOperand().getUse().getBlock()
200+
result = v.asOperand().getAnyDef().getBlock()
199201
}
200202

201203
/** Holds if `inp` is an input to the phi node along the edge originating in `bb`. */

0 commit comments

Comments
 (0)