From 5aa0429e978666049e19dc9882db32031ddcaa9f Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Tue, 30 Jun 2026 23:46:53 +0100 Subject: [PATCH] Revert "Merge pull request #21941 from hvitved/python/content-approx" This reverts commit f5919875b7c03ab3f907a871faf208d330ab41d9, reversing changes made to 8d456df26f6af41ef9f3562e4e04e42e8e163052. --- .../dataflow/new/internal/DataFlowPrivate.qll | 59 +------------------ 1 file changed, 3 insertions(+), 56 deletions(-) diff --git a/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll b/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll index 04e8ad0587f..4a3740da861 100644 --- a/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll +++ b/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll @@ -1249,65 +1249,12 @@ predicate allowParameterReturnInSelf(ParameterNode p) { ) } -bindingset[s] -private string getFirstChar(string s) { - result = - min(int i, string c | - c = s.charAt(i) and c != "_" - or - c = "" and i = s.length() - | - c order by i - ) -} - -private string getAttributeContentFirstChar(AttributeContent ac) { - result = getFirstChar(ac.getAttribute()) -} - -private string getDictionaryElementContentKeyFirstChar(DictionaryElementContent dec) { - result = getFirstChar(dec.getKey()) -} - -private newtype TContentApprox = - TListElementContentApprox() or - TSetElementContentApprox() or - TTupleElementContentApprox() or - TDictionaryElementContentApprox(string first) { - first = "" // for `TDictionaryElementAnyContent` - or - first = getDictionaryElementContentKeyFirstChar(_) - } or - TAttributeContentApprox(string first) { first = getAttributeContentFirstChar(_) } or - TCapturedVariableContentApprox() - /** An approximated `Content`. */ -class ContentApprox extends TContentApprox { - /** Gets a textual representation of this element. */ - string toString() { result = "" } -} +class ContentApprox = Unit; /** Gets an approximated value for content `c`. */ -ContentApprox getContentApprox(Content c) { - c = TListElementContent() and - result = TListElementContentApprox() - or - c = TSetElementContent() and - result = TSetElementContentApprox() - or - c = TTupleElementContent(_) and - result = TTupleElementContentApprox() - or - result = TDictionaryElementContentApprox(getDictionaryElementContentKeyFirstChar(c)) - or - c = TDictionaryElementAnyContent() and - result = TDictionaryElementContentApprox("") - or - result = TAttributeContentApprox(getAttributeContentFirstChar(c)) - or - c = TCapturedVariableContent(_) and - result = TCapturedVariableContentApprox() -} +pragma[inline] +ContentApprox getContentApprox(Content c) { any() } /** Helper for `.getEnclosingCallable`. */ DataFlowCallable getCallableScope(Scope s) {