Skip to content

Commit 53c20cc

Browse files
committed
Shared: Some model generator re-factoring.
1 parent 0cd4ccb commit 53c20cc

File tree

1 file changed

+9
-24
lines changed

1 file changed

+9
-24
lines changed

shared/mad/codeql/mad/modelgenerator/internal/ModelGeneratorImpl.qll

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -571,15 +571,7 @@ module MakeModelGenerator<
571571
}
572572

573573
private string getContent(PropagateContentFlow::AccessPath ap, int i) {
574-
exists(DataFlow::ContentSet head, PropagateContentFlow::AccessPath tail |
575-
head = ap.getHead() and
576-
tail = ap.getTail()
577-
|
578-
i = 0 and
579-
result = "." + printContent(head)
580-
or
581-
i > 0 and result = getContent(tail, i - 1)
582-
)
574+
result = "." + printContent(ap.getAtIndex(i))
583575
}
584576

585577
/**
@@ -600,12 +592,7 @@ module MakeModelGenerator<
600592
* Holds if the access path `ap` contains a field or synthetic field access.
601593
*/
602594
private predicate mentionsField(PropagateContentFlow::AccessPath ap) {
603-
exists(DataFlow::ContentSet head, PropagateContentFlow::AccessPath tail |
604-
head = ap.getHead() and
605-
tail = ap.getTail()
606-
|
607-
mentionsField(tail) or isField(head)
608-
)
595+
isField(ap.getAtIndex(_))
609596
}
610597

611598
private predicate apiFlow(
@@ -668,21 +655,19 @@ module MakeModelGenerator<
668655
* Holds if any of the content sets in `path` translates into a synthetic field.
669656
*/
670657
private predicate hasSyntheticContent(PropagateContentFlow::AccessPath path) {
671-
exists(PropagateContentFlow::AccessPath tail, DataFlow::ContentSet head |
672-
head = path.getHead() and
673-
tail = path.getTail()
674-
|
675-
exists(getSyntheticName(head)) or
676-
hasSyntheticContent(tail)
677-
)
658+
exists(getSyntheticName(path.getAtIndex(_)))
659+
}
660+
661+
private string getHashAtIndex(PropagateContentFlow::AccessPath ap, int i) {
662+
result = getSyntheticName(ap.getAtIndex(i))
678663
}
679664

680665
private string getReversedHash(PropagateContentFlow::AccessPath ap) {
681-
result = concat(int i | | getSyntheticName(ap.getAtIndex(i)), "" order by i desc)
666+
result = concat(int i | | getHashAtIndex(ap, i), "" order by i desc)
682667
}
683668

684669
private string getHash(PropagateContentFlow::AccessPath ap) {
685-
result = concat(int i | | getSyntheticName(ap.getAtIndex(i)), "" order by i)
670+
result = concat(int i | | getHashAtIndex(ap, i), "" order by i)
686671
}
687672

688673
/**

0 commit comments

Comments
 (0)