Skip to content

Commit 2868150

Browse files
committed
C++: Fix bug and accept test changes.
1 parent 27a437a commit 2868150

File tree

3 files changed

+12
-5
lines changed
  • cpp/ql
    • lib/semmle/code/cpp/ir/dataflow/internal
    • test/library-tests/dataflow/ir-barrier-guards
  • shared/controlflow/codeql/controlflow

3 files changed

+12
-5
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImpl.qll

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,8 +1064,15 @@ module BarrierGuardWithIntParam<guardChecksNodeSig/4 guardChecksNode> {
10641064
DataFlowIntegrationInput::Guard g, SsaImpl::Definition def, IRGuards::GuardValue val,
10651065
int indirectionIndex
10661066
) {
1067-
IRGuards::Guards_v1::ParameterizedValidationWrapper<int, guardChecksInstr/4>::guardChecksDef(g,
1068-
def, val, indirectionIndex)
1067+
exists(Instruction e |
1068+
IRGuards::Guards_v1::ParameterizedValidationWrapper<int, guardChecksInstr/4>::guardChecks(g,
1069+
e, val, indirectionIndex)
1070+
|
1071+
indirectionIndex = 0 and
1072+
def.(Definition).getAUse().getDef() = e
1073+
or
1074+
def.(Definition).getAnIndirectUse(indirectionIndex).getDef() = e
1075+
)
10691076
}
10701077

10711078
Node getABarrierNode(int indirectionIndex) {

cpp/ql/test/library-tests/dataflow/ir-barrier-guards/test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ void sink(int);
44

55
void testCheckArgument(int* p) {
66
if (checkArgument(p)) {
7-
sink(*p); // $ barrier=int indirect_barrier=int barrier=int* indirect_barrier=int*
7+
sink(*p); // $ indirect_barrier=int barrier=int*
88
}
99
}
1010

1111
void testCheckArgument(int p) {
1212
if (checkArgument(&p)) {
13-
sink(p); // $ barrier=glval<int> indirect_barrier=glval<int> indirect_barrier=int
13+
sink(p); // $ barrier=glval<int> indirect_barrier=int
1414
}
1515
}

shared/controlflow/codeql/controlflow/Guards.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ module Make<
13641364
/**
13651365
* Holds if the guard `g` validates the expression `e` upon evaluating to `val`.
13661366
*/
1367-
private predicate guardChecks(Guard g, Expr e, GuardValue val, P par) {
1367+
predicate guardChecks(Guard g, Expr e, GuardValue val, P par) {
13681368
guardChecks0(g, e, val, par)
13691369
or
13701370
exists(NonOverridableMethodCall call, ParameterPosition ppos, ArgumentPosition apos |

0 commit comments

Comments
 (0)