Skip to content

Commit 106b8cf

Browse files
committed
Java/C++/C#: Fix bad magic and bad join-order.
1 parent d0842fc commit 106b8cf

File tree

19 files changed

+228
-76
lines changed

19 files changed

+228
-76
lines changed

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,22 @@ private predicate nodeCandFwd1(Node node, Configuration config) {
314314
)
315315
or
316316
// flow out of a callable
317-
exists(DataFlowCall call, ReturnNodeExt ret, ReturnKindExt kind |
318-
nodeCandFwd1(ret, config) and
319-
getReturnPosition(ret) = viableReturnPos(call, kind) and
317+
exists(DataFlowCall call, ReturnPosition pos, ReturnKindExt kind |
318+
nodeCandFwd1ReturnPosition(pos, config) and
319+
pos = viableReturnPos(call, kind) and
320320
node = kind.getAnOutNode(call)
321321
)
322322
)
323323
}
324324

325+
pragma[noinline]
326+
private predicate nodeCandFwd1ReturnPosition(ReturnPosition pos, Configuration config) {
327+
exists(ReturnNodeExt ret |
328+
nodeCandFwd1(ret, config) and
329+
getReturnPosition(ret) = pos
330+
)
331+
}
332+
325333
pragma[nomagic]
326334
private predicate nodeCandFwd1Read(Content f, Node node, Configuration config) {
327335
exists(Node mid |
@@ -1885,7 +1893,7 @@ private predicate paramFlowsThrough(
18851893
)
18861894
}
18871895

1888-
pragma[noinline]
1896+
pragma[nomagic]
18891897
private predicate pathThroughCallable0(
18901898
DataFlowCall call, PathNodeMid mid, ReturnKindExt kind, CallContext cc, AccessPathNil apnil
18911899
) {

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,22 @@ private predicate nodeCandFwd1(Node node, Configuration config) {
314314
)
315315
or
316316
// flow out of a callable
317-
exists(DataFlowCall call, ReturnNodeExt ret, ReturnKindExt kind |
318-
nodeCandFwd1(ret, config) and
319-
getReturnPosition(ret) = viableReturnPos(call, kind) and
317+
exists(DataFlowCall call, ReturnPosition pos, ReturnKindExt kind |
318+
nodeCandFwd1ReturnPosition(pos, config) and
319+
pos = viableReturnPos(call, kind) and
320320
node = kind.getAnOutNode(call)
321321
)
322322
)
323323
}
324324

325+
pragma[noinline]
326+
private predicate nodeCandFwd1ReturnPosition(ReturnPosition pos, Configuration config) {
327+
exists(ReturnNodeExt ret |
328+
nodeCandFwd1(ret, config) and
329+
getReturnPosition(ret) = pos
330+
)
331+
}
332+
325333
pragma[nomagic]
326334
private predicate nodeCandFwd1Read(Content f, Node node, Configuration config) {
327335
exists(Node mid |
@@ -1885,7 +1893,7 @@ private predicate paramFlowsThrough(
18851893
)
18861894
}
18871895

1888-
pragma[noinline]
1896+
pragma[nomagic]
18891897
private predicate pathThroughCallable0(
18901898
DataFlowCall call, PathNodeMid mid, ReturnKindExt kind, CallContext cc, AccessPathNil apnil
18911899
) {

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,22 @@ private predicate nodeCandFwd1(Node node, Configuration config) {
314314
)
315315
or
316316
// flow out of a callable
317-
exists(DataFlowCall call, ReturnNodeExt ret, ReturnKindExt kind |
318-
nodeCandFwd1(ret, config) and
319-
getReturnPosition(ret) = viableReturnPos(call, kind) and
317+
exists(DataFlowCall call, ReturnPosition pos, ReturnKindExt kind |
318+
nodeCandFwd1ReturnPosition(pos, config) and
319+
pos = viableReturnPos(call, kind) and
320320
node = kind.getAnOutNode(call)
321321
)
322322
)
323323
}
324324

325+
pragma[noinline]
326+
private predicate nodeCandFwd1ReturnPosition(ReturnPosition pos, Configuration config) {
327+
exists(ReturnNodeExt ret |
328+
nodeCandFwd1(ret, config) and
329+
getReturnPosition(ret) = pos
330+
)
331+
}
332+
325333
pragma[nomagic]
326334
private predicate nodeCandFwd1Read(Content f, Node node, Configuration config) {
327335
exists(Node mid |
@@ -1885,7 +1893,7 @@ private predicate paramFlowsThrough(
18851893
)
18861894
}
18871895

1888-
pragma[noinline]
1896+
pragma[nomagic]
18891897
private predicate pathThroughCallable0(
18901898
DataFlowCall call, PathNodeMid mid, ReturnKindExt kind, CallContext cc, AccessPathNil apnil
18911899
) {

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,22 @@ private predicate nodeCandFwd1(Node node, Configuration config) {
314314
)
315315
or
316316
// flow out of a callable
317-
exists(DataFlowCall call, ReturnNodeExt ret, ReturnKindExt kind |
318-
nodeCandFwd1(ret, config) and
319-
getReturnPosition(ret) = viableReturnPos(call, kind) and
317+
exists(DataFlowCall call, ReturnPosition pos, ReturnKindExt kind |
318+
nodeCandFwd1ReturnPosition(pos, config) and
319+
pos = viableReturnPos(call, kind) and
320320
node = kind.getAnOutNode(call)
321321
)
322322
)
323323
}
324324

325+
pragma[noinline]
326+
private predicate nodeCandFwd1ReturnPosition(ReturnPosition pos, Configuration config) {
327+
exists(ReturnNodeExt ret |
328+
nodeCandFwd1(ret, config) and
329+
getReturnPosition(ret) = pos
330+
)
331+
}
332+
325333
pragma[nomagic]
326334
private predicate nodeCandFwd1Read(Content f, Node node, Configuration config) {
327335
exists(Node mid |
@@ -1885,7 +1893,7 @@ private predicate paramFlowsThrough(
18851893
)
18861894
}
18871895

1888-
pragma[noinline]
1896+
pragma[nomagic]
18891897
private predicate pathThroughCallable0(
18901898
DataFlowCall call, PathNodeMid mid, ReturnKindExt kind, CallContext cc, AccessPathNil apnil
18911899
) {

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImplLocal.qll

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,22 @@ private predicate nodeCandFwd1(Node node, Configuration config) {
314314
)
315315
or
316316
// flow out of a callable
317-
exists(DataFlowCall call, ReturnNodeExt ret, ReturnKindExt kind |
318-
nodeCandFwd1(ret, config) and
319-
getReturnPosition(ret) = viableReturnPos(call, kind) and
317+
exists(DataFlowCall call, ReturnPosition pos, ReturnKindExt kind |
318+
nodeCandFwd1ReturnPosition(pos, config) and
319+
pos = viableReturnPos(call, kind) and
320320
node = kind.getAnOutNode(call)
321321
)
322322
)
323323
}
324324

325+
pragma[noinline]
326+
private predicate nodeCandFwd1ReturnPosition(ReturnPosition pos, Configuration config) {
327+
exists(ReturnNodeExt ret |
328+
nodeCandFwd1(ret, config) and
329+
getReturnPosition(ret) = pos
330+
)
331+
}
332+
325333
pragma[nomagic]
326334
private predicate nodeCandFwd1Read(Content f, Node node, Configuration config) {
327335
exists(Node mid |
@@ -1885,7 +1893,7 @@ private predicate paramFlowsThrough(
18851893
)
18861894
}
18871895

1888-
pragma[noinline]
1896+
pragma[nomagic]
18891897
private predicate pathThroughCallable0(
18901898
DataFlowCall call, PathNodeMid mid, ReturnKindExt kind, CallContext cc, AccessPathNil apnil
18911899
) {

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,22 @@ private predicate nodeCandFwd1(Node node, Configuration config) {
314314
)
315315
or
316316
// flow out of a callable
317-
exists(DataFlowCall call, ReturnNodeExt ret, ReturnKindExt kind |
318-
nodeCandFwd1(ret, config) and
319-
getReturnPosition(ret) = viableReturnPos(call, kind) and
317+
exists(DataFlowCall call, ReturnPosition pos, ReturnKindExt kind |
318+
nodeCandFwd1ReturnPosition(pos, config) and
319+
pos = viableReturnPos(call, kind) and
320320
node = kind.getAnOutNode(call)
321321
)
322322
)
323323
}
324324

325+
pragma[noinline]
326+
private predicate nodeCandFwd1ReturnPosition(ReturnPosition pos, Configuration config) {
327+
exists(ReturnNodeExt ret |
328+
nodeCandFwd1(ret, config) and
329+
getReturnPosition(ret) = pos
330+
)
331+
}
332+
325333
pragma[nomagic]
326334
private predicate nodeCandFwd1Read(Content f, Node node, Configuration config) {
327335
exists(Node mid |
@@ -1885,7 +1893,7 @@ private predicate paramFlowsThrough(
18851893
)
18861894
}
18871895

1888-
pragma[noinline]
1896+
pragma[nomagic]
18891897
private predicate pathThroughCallable0(
18901898
DataFlowCall call, PathNodeMid mid, ReturnKindExt kind, CallContext cc, AccessPathNil apnil
18911899
) {

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,22 @@ private predicate nodeCandFwd1(Node node, Configuration config) {
314314
)
315315
or
316316
// flow out of a callable
317-
exists(DataFlowCall call, ReturnNodeExt ret, ReturnKindExt kind |
318-
nodeCandFwd1(ret, config) and
319-
getReturnPosition(ret) = viableReturnPos(call, kind) and
317+
exists(DataFlowCall call, ReturnPosition pos, ReturnKindExt kind |
318+
nodeCandFwd1ReturnPosition(pos, config) and
319+
pos = viableReturnPos(call, kind) and
320320
node = kind.getAnOutNode(call)
321321
)
322322
)
323323
}
324324

325+
pragma[noinline]
326+
private predicate nodeCandFwd1ReturnPosition(ReturnPosition pos, Configuration config) {
327+
exists(ReturnNodeExt ret |
328+
nodeCandFwd1(ret, config) and
329+
getReturnPosition(ret) = pos
330+
)
331+
}
332+
325333
pragma[nomagic]
326334
private predicate nodeCandFwd1Read(Content f, Node node, Configuration config) {
327335
exists(Node mid |
@@ -1885,7 +1893,7 @@ private predicate paramFlowsThrough(
18851893
)
18861894
}
18871895

1888-
pragma[noinline]
1896+
pragma[nomagic]
18891897
private predicate pathThroughCallable0(
18901898
DataFlowCall call, PathNodeMid mid, ReturnKindExt kind, CallContext cc, AccessPathNil apnil
18911899
) {

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,22 @@ private predicate nodeCandFwd1(Node node, Configuration config) {
314314
)
315315
or
316316
// flow out of a callable
317-
exists(DataFlowCall call, ReturnNodeExt ret, ReturnKindExt kind |
318-
nodeCandFwd1(ret, config) and
319-
getReturnPosition(ret) = viableReturnPos(call, kind) and
317+
exists(DataFlowCall call, ReturnPosition pos, ReturnKindExt kind |
318+
nodeCandFwd1ReturnPosition(pos, config) and
319+
pos = viableReturnPos(call, kind) and
320320
node = kind.getAnOutNode(call)
321321
)
322322
)
323323
}
324324

325+
pragma[noinline]
326+
private predicate nodeCandFwd1ReturnPosition(ReturnPosition pos, Configuration config) {
327+
exists(ReturnNodeExt ret |
328+
nodeCandFwd1(ret, config) and
329+
getReturnPosition(ret) = pos
330+
)
331+
}
332+
325333
pragma[nomagic]
326334
private predicate nodeCandFwd1Read(Content f, Node node, Configuration config) {
327335
exists(Node mid |
@@ -1885,7 +1893,7 @@ private predicate paramFlowsThrough(
18851893
)
18861894
}
18871895

1888-
pragma[noinline]
1896+
pragma[nomagic]
18891897
private predicate pathThroughCallable0(
18901898
DataFlowCall call, PathNodeMid mid, ReturnKindExt kind, CallContext cc, AccessPathNil apnil
18911899
) {

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,22 @@ private predicate nodeCandFwd1(Node node, Configuration config) {
314314
)
315315
or
316316
// flow out of a callable
317-
exists(DataFlowCall call, ReturnNodeExt ret, ReturnKindExt kind |
318-
nodeCandFwd1(ret, config) and
319-
getReturnPosition(ret) = viableReturnPos(call, kind) and
317+
exists(DataFlowCall call, ReturnPosition pos, ReturnKindExt kind |
318+
nodeCandFwd1ReturnPosition(pos, config) and
319+
pos = viableReturnPos(call, kind) and
320320
node = kind.getAnOutNode(call)
321321
)
322322
)
323323
}
324324

325+
pragma[noinline]
326+
private predicate nodeCandFwd1ReturnPosition(ReturnPosition pos, Configuration config) {
327+
exists(ReturnNodeExt ret |
328+
nodeCandFwd1(ret, config) and
329+
getReturnPosition(ret) = pos
330+
)
331+
}
332+
325333
pragma[nomagic]
326334
private predicate nodeCandFwd1Read(Content f, Node node, Configuration config) {
327335
exists(Node mid |
@@ -1885,7 +1893,7 @@ private predicate paramFlowsThrough(
18851893
)
18861894
}
18871895

1888-
pragma[noinline]
1896+
pragma[nomagic]
18891897
private predicate pathThroughCallable0(
18901898
DataFlowCall call, PathNodeMid mid, ReturnKindExt kind, CallContext cc, AccessPathNil apnil
18911899
) {

csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,22 @@ private predicate nodeCandFwd1(Node node, Configuration config) {
314314
)
315315
or
316316
// flow out of a callable
317-
exists(DataFlowCall call, ReturnNodeExt ret, ReturnKindExt kind |
318-
nodeCandFwd1(ret, config) and
319-
getReturnPosition(ret) = viableReturnPos(call, kind) and
317+
exists(DataFlowCall call, ReturnPosition pos, ReturnKindExt kind |
318+
nodeCandFwd1ReturnPosition(pos, config) and
319+
pos = viableReturnPos(call, kind) and
320320
node = kind.getAnOutNode(call)
321321
)
322322
)
323323
}
324324

325+
pragma[noinline]
326+
private predicate nodeCandFwd1ReturnPosition(ReturnPosition pos, Configuration config) {
327+
exists(ReturnNodeExt ret |
328+
nodeCandFwd1(ret, config) and
329+
getReturnPosition(ret) = pos
330+
)
331+
}
332+
325333
pragma[nomagic]
326334
private predicate nodeCandFwd1Read(Content f, Node node, Configuration config) {
327335
exists(Node mid |
@@ -1885,7 +1893,7 @@ private predicate paramFlowsThrough(
18851893
)
18861894
}
18871895

1888-
pragma[noinline]
1896+
pragma[nomagic]
18891897
private predicate pathThroughCallable0(
18901898
DataFlowCall call, PathNodeMid mid, ReturnKindExt kind, CallContext cc, AccessPathNil apnil
18911899
) {

0 commit comments

Comments
 (0)