From 2625c304bf275e782f604fa77ca6fea7ccbcc3dc Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Mon, 29 Jun 2026 12:42:12 +0100 Subject: [PATCH] C++: Support fully qualified field names in MaD. --- .../cpp/dataflow/internal/FlowSummaryImpl.qll | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cpp/ql/lib/semmle/code/cpp/dataflow/internal/FlowSummaryImpl.qll b/cpp/ql/lib/semmle/code/cpp/dataflow/internal/FlowSummaryImpl.qll index d91dc41febe..379e033d56b 100644 --- a/cpp/ql/lib/semmle/code/cpp/dataflow/internal/FlowSummaryImpl.qll +++ b/cpp/ql/lib/semmle/code/cpp/dataflow/internal/FlowSummaryImpl.qll @@ -40,12 +40,24 @@ module Input implements InputSig { arg = repeatStars(rk.(NormalReturnKind).getIndirectionIndex()) } + bindingset[namespace, type, base] + private string formatQualifiedName(string namespace, string type, string base) { + if namespace = "" + then result = type + "::" + base + else result = namespace + "::" + type + "::" + base + } + string encodeContent(ContentSet cs, string arg) { - exists(FieldContent c | + exists(FieldContent c, string namespace, string type, string base | cs.isSingleton(c) and // FieldContent indices have 0 for the address, 1 for content, so we need to subtract one. result = "Field" and - arg = repeatStars(c.getIndirectionIndex() - 1) + c.getField().getName() + c.getField().hasQualifiedName(namespace, type, base) + | + if arg.matches("%::%") + then + arg = repeatStars(c.getIndirectionIndex() - 1) + formatQualifiedName(namespace, type, base) + else arg = repeatStars(c.getIndirectionIndex() - 1) + base ) or exists(ElementContent ec |