diff --git a/shared/dataflow/codeql/dataflow/internal/ContentDataFlowImpl.qll b/shared/dataflow/codeql/dataflow/internal/ContentDataFlowImpl.qll index f413c6dd7ad..b972fc533ce 100644 --- a/shared/dataflow/codeql/dataflow/internal/ContentDataFlowImpl.qll +++ b/shared/dataflow/codeql/dataflow/internal/ContentDataFlowImpl.qll @@ -271,6 +271,38 @@ module MakeImplContentDataFlow Lang> { result = head + "." + tail ) } + + private ContentSet getAtIndex(int i) { + i = 0 and + result = this.getHead() + or + i > 0 and + result = this.getTail().getAtIndex(i - 1) + } + + private AccessPath reverse0(int i) { + i = -1 and result = TAccessPathNil() + or + i >= 0 and + result = TAccessPathCons(this.getAtIndex(i), this.reverse0(i - 1)) + } + + /** + * Gets the length of this access path. + */ + private int length() { + result = 0 and this = TAccessPathNil() + or + result = 1 + this.getTail().length() + } + + /** + * Gets the reversed access path, if any. + * + * Note that not all access paths have a reverse as these are not + * included by default in the IPA type. + */ + AccessPath reverse() { result = this.reverse0(this.length() - 1) } } /**