Skip to content

Commit 4aa6275

Browse files
authored
Merge pull request #11803 from jketema/gvn-deprecation
C++: Mark a number of private predicates in the GVN library as deprecated
2 parents ed73875 + 5f4326f commit 4aa6275

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

cpp/ql/lib/semmle/code/cpp/valuenumbering/GlobalValueNumberingImpl.qll

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ private newtype GvnBase =
183183
// global variable will only get the same value number if they are
184184
// guaranteed to have the same value.
185185
GVN_OtherVariable(Variable x, ControlFlowNode dominator) { mk_OtherVariable(x, dominator, _) } or
186-
GVN_FieldAccess(GVN s, Field f) {
186+
deprecated GVN_FieldAccess(GVN s, Field f) {
187187
mk_DotFieldAccess(s, f, _) or
188188
mk_PointerFieldAccess_with_deref(s, f, _) or
189189
mk_ImplicitThisFieldAccess_with_deref(s, f, _)
@@ -192,7 +192,7 @@ private newtype GvnBase =
192192
// time the pointer was dereferenced, so we need to include a definition
193193
// location. As a crude (but safe) approximation, we use
194194
// `mostRecentSideEffect` to compute a definition location.
195-
GVN_Deref(GVN p, ControlFlowNode dominator) {
195+
deprecated GVN_Deref(GVN p, ControlFlowNode dominator) {
196196
mk_Deref(p, dominator, _) or
197197
mk_PointerFieldAccess(p, _, dominator, _) or
198198
mk_ImplicitThisFieldAccess_with_qualifier(p, _, dominator, _)
@@ -201,10 +201,12 @@ private newtype GvnBase =
201201
mk_ThisExpr(fcn, _) or
202202
mk_ImplicitThisFieldAccess(fcn, _, _, _)
203203
} or
204-
GVN_Conversion(Type t, GVN child) { mk_Conversion(t, child, _) } or
205-
GVN_BinaryOp(GVN lhs, GVN rhs, string opname) { mk_BinaryOp(lhs, rhs, opname, _) } or
206-
GVN_UnaryOp(GVN child, string opname) { mk_UnaryOp(child, opname, _) } or
207-
GVN_ArrayAccess(GVN x, GVN i, ControlFlowNode dominator) { mk_ArrayAccess(x, i, dominator, _) } or
204+
deprecated GVN_Conversion(Type t, GVN child) { mk_Conversion(t, child, _) } or
205+
deprecated GVN_BinaryOp(GVN lhs, GVN rhs, string opname) { mk_BinaryOp(lhs, rhs, opname, _) } or
206+
deprecated GVN_UnaryOp(GVN child, string opname) { mk_UnaryOp(child, opname, _) } or
207+
deprecated GVN_ArrayAccess(GVN x, GVN i, ControlFlowNode dominator) {
208+
mk_ArrayAccess(x, i, dominator, _)
209+
} or
208210
// Any expression that is not handled by the cases above is
209211
// given a unique number based on the expression itself.
210212
GVN_Unanalyzable(Expr e) { not analyzableExpr(e) }
@@ -340,7 +342,7 @@ private predicate analyzableDotFieldAccess(DotFieldAccess access) {
340342
not analyzableConst(access)
341343
}
342344

343-
private predicate mk_DotFieldAccess(GVN qualifier, Field target, DotFieldAccess access) {
345+
deprecated private predicate mk_DotFieldAccess(GVN qualifier, Field target, DotFieldAccess access) {
344346
analyzableDotFieldAccess(access) and
345347
target = access.getTarget() and
346348
qualifier = globalValueNumber(access.getQualifier().getFullyConverted())
@@ -353,7 +355,7 @@ private predicate analyzablePointerFieldAccess(PointerFieldAccess access) {
353355
not analyzableConst(access)
354356
}
355357

356-
private predicate mk_PointerFieldAccess(
358+
deprecated private predicate mk_PointerFieldAccess(
357359
GVN qualifier, Field target, ControlFlowNode dominator, PointerFieldAccess access
358360
) {
359361
analyzablePointerFieldAccess(access) and
@@ -366,7 +368,7 @@ private predicate mk_PointerFieldAccess(
366368
* `obj->field` is equivalent to `(*obj).field`, so we need to wrap an
367369
* extra `GVN_Deref` around the qualifier.
368370
*/
369-
private predicate mk_PointerFieldAccess_with_deref(
371+
deprecated private predicate mk_PointerFieldAccess_with_deref(
370372
GVN new_qualifier, Field target, PointerFieldAccess access
371373
) {
372374
exists(GVN qualifier, ControlFlowNode dominator |
@@ -391,7 +393,7 @@ private predicate mk_ImplicitThisFieldAccess(
391393
fcn = access.getEnclosingFunction()
392394
}
393395

394-
private predicate mk_ImplicitThisFieldAccess_with_qualifier(
396+
deprecated private predicate mk_ImplicitThisFieldAccess_with_qualifier(
395397
GVN qualifier, Field target, ControlFlowNode dominator, ImplicitThisFieldAccess access
396398
) {
397399
exists(Function fcn |
@@ -400,7 +402,7 @@ private predicate mk_ImplicitThisFieldAccess_with_qualifier(
400402
)
401403
}
402404

403-
private predicate mk_ImplicitThisFieldAccess_with_deref(
405+
deprecated private predicate mk_ImplicitThisFieldAccess_with_deref(
404406
GVN new_qualifier, Field target, ImplicitThisFieldAccess access
405407
) {
406408
exists(GVN qualifier, ControlFlowNode dominator |
@@ -434,7 +436,7 @@ private predicate analyzableConversion(Conversion conv) {
434436
not analyzableConst(conv)
435437
}
436438

437-
private predicate mk_Conversion(Type t, GVN child, Conversion conv) {
439+
deprecated private predicate mk_Conversion(Type t, GVN child, Conversion conv) {
438440
analyzableConversion(conv) and
439441
t = conv.getUnspecifiedType() and
440442
child = globalValueNumber(conv.getExpr())
@@ -448,7 +450,7 @@ private predicate analyzableBinaryOp(BinaryOperation op) {
448450
not analyzableConst(op)
449451
}
450452

451-
private predicate mk_BinaryOp(GVN lhs, GVN rhs, string opname, BinaryOperation op) {
453+
deprecated private predicate mk_BinaryOp(GVN lhs, GVN rhs, string opname, BinaryOperation op) {
452454
analyzableBinaryOp(op) and
453455
lhs = globalValueNumber(op.getLeftOperand().getFullyConverted()) and
454456
rhs = globalValueNumber(op.getRightOperand().getFullyConverted()) and
@@ -463,7 +465,7 @@ private predicate analyzableUnaryOp(UnaryOperation op) {
463465
not analyzableConst(op)
464466
}
465467

466-
private predicate mk_UnaryOp(GVN child, string opname, UnaryOperation op) {
468+
deprecated private predicate mk_UnaryOp(GVN child, string opname, UnaryOperation op) {
467469
analyzableUnaryOp(op) and
468470
child = globalValueNumber(op.getOperand().getFullyConverted()) and
469471
opname = op.getOperator()
@@ -486,7 +488,9 @@ private predicate analyzableArrayAccess(ArrayExpr ae) {
486488
not analyzableConst(ae)
487489
}
488490

489-
private predicate mk_ArrayAccess(GVN base, GVN offset, ControlFlowNode dominator, ArrayExpr ae) {
491+
deprecated private predicate mk_ArrayAccess(
492+
GVN base, GVN offset, ControlFlowNode dominator, ArrayExpr ae
493+
) {
490494
analyzableArrayAccess(ae) and
491495
base = globalValueNumber(ae.getArrayBase().getFullyConverted()) and
492496
offset = globalValueNumber(ae.getArrayOffset().getFullyConverted()) and
@@ -499,7 +503,7 @@ private predicate analyzablePointerDereferenceExpr(PointerDereferenceExpr deref)
499503
not analyzableConst(deref)
500504
}
501505

502-
private predicate mk_Deref(GVN p, ControlFlowNode dominator, PointerDereferenceExpr deref) {
506+
deprecated private predicate mk_Deref(GVN p, ControlFlowNode dominator, PointerDereferenceExpr deref) {
503507
analyzablePointerDereferenceExpr(deref) and
504508
p = globalValueNumber(deref.getOperand().getFullyConverted()) and
505509
dominator = mostRecentSideEffect(deref)

0 commit comments

Comments
 (0)