Skip to content

Commit f9db6a9

Browse files
committed
C++: Don't do range analysis on malformed IR.
1 parent d57276c commit f9db6a9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ module SemanticExprConfig {
188188
none()
189189
}
190190

191+
/** Holds if no range analysis should be performed on the phi edges in `f`. */
192+
private predicate excludeFunction(Cpp::Function f) { count(f.getEntryPoint()) > 1 }
193+
191194
SemType getUnknownExprType(Expr expr) { result = getSemanticType(expr.getResultIRType()) }
192195

193196
class BasicBlock = IR::IRBlock;
@@ -270,7 +273,13 @@ module SemanticExprConfig {
270273
getSemanticExpr(v.asInstruction()) = sourceExpr
271274
}
272275

273-
predicate phi(SsaVariable v) { v.asInstruction() instanceof IR::PhiInstruction }
276+
predicate phi(SsaVariable v) {
277+
exists(IR::PhiInstruction phi, Cpp::Function f |
278+
phi = v.asInstruction() and
279+
f = phi.getEnclosingFunction() and
280+
not excludeFunction(f)
281+
)
282+
}
274283

275284
SsaVariable getAPhiInput(SsaVariable v) {
276285
exists(IR::PhiInstruction instr | v.asInstruction() = instr |

0 commit comments

Comments
 (0)