From f223c957baeaf82ea0893c536f8f727fd09ee7ef Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Fri, 27 Feb 2026 12:02:24 +0000 Subject: [PATCH] C++: Cache 'toString' and 'getLocation'. --- .../code/cpp/ir/dataflow/internal/DataFlowPrivate.qll | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll index 31dba3a245b..5b7736de2da 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll @@ -35,6 +35,17 @@ private module Cached { not Ssa::ignoreOperand(op) and exists(Ssa::getIRRepresentationOfOperand(op)) } + cached + string toStringCached(Node n) { + result = toExprString(n) + or + not exists(toExprString(n)) and + result = n.toStringImpl() + } + + cached + Location getLocationCached(Node n) { result = n.getLocationImpl() } + cached newtype TContentApprox = TFieldApproxContent(string s) { fieldHasApproxName(_, s) } or