Skip to content

Commit b13650b

Browse files
committed
wip
1 parent 75b7d4c commit b13650b

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2860,7 +2860,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
28602860

28612861
bindingset[c, tail]
28622862
Ap apCons(Content c, Ap tail) {
2863-
exists(boolean isSingleton | result.getAHead(isSingleton) = c |
2863+
exists(boolean isSingleton |
2864+
result.getAHead(isSingleton) = c and
28642865
if tail instanceof ApNil then isSingleton = true else isSingleton = false
28652866
)
28662867
}
@@ -3200,7 +3201,10 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
32003201
override predicate isCons(Content head, AccessPathApprox tail) {
32013202
head = c and
32023203
(
3203-
exists(Content c2 | Stage4::consCand(c, TFrontHead(c2, _)) |
3204+
exists(Content c2, boolean isSingleton |
3205+
Stage4::consCand(c, TFrontHead(c2, isSingleton)) and
3206+
if len > 2 then isSingleton = false else isSingleton = true
3207+
|
32043208
tail = TConsCons(c2, _, len - 1)
32053209
or
32063210
len = 2 and
@@ -3543,7 +3547,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
35433547
override predicate isCons(Content head, AccessPath tail) { head = head_ and tail = tail_ }
35443548

35453549
override AccessPathFrontHead getFront() {
3546-
if tail_.length() = 0
3550+
if this.length() = 1
35473551
then result = TFrontHead(head_, true)
35483552
else result = TFrontHead(head_, false)
35493553
}

shared/dataflow/codeql/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2521,10 +2521,13 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
25212521

25222522
class ApproxAccessPathFrontHead extends ApproxAccessPathFront, TApproxFrontHead {
25232523
private ContentApprox c;
2524+
private boolean isSingleton;
25242525

2525-
ApproxAccessPathFrontHead() { this = TApproxFrontHead(c, _) }
2526+
ApproxAccessPathFrontHead() { this = TApproxFrontHead(c, isSingleton) }
25262527

2527-
override string toString() { result = c.toString() }
2528+
override string toString() {
2529+
if isSingleton = true then result = c.toString() + " (singleton)" else result = c.toString()
2530+
}
25282531

25292532
override boolean toBoolNonEmpty() { result = true }
25302533
}
@@ -2561,7 +2564,9 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
25612564

25622565
AccessPathFrontHead() { this = TFrontHead(c, isSingleton) }
25632566

2564-
override string toString() { result = c.toString() }
2567+
override string toString() {
2568+
if isSingleton = true then result = c.toString() + " (singleton)" else result = c.toString()
2569+
}
25652570

25662571
override ApproxAccessPathFront toApprox() { result.getAHead(isSingleton) = c }
25672572
}

0 commit comments

Comments
 (0)