Skip to content

Commit 2625c30

Browse files
committed
C++: Support fully qualified field names in MaD.
1 parent 49bde56 commit 2625c30

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

cpp/ql/lib/semmle/code/cpp/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,24 @@ module Input implements InputSig<Location, DataFlowImplSpecific::CppDataFlow> {
4040
arg = repeatStars(rk.(NormalReturnKind).getIndirectionIndex())
4141
}
4242

43+
bindingset[namespace, type, base]
44+
private string formatQualifiedName(string namespace, string type, string base) {
45+
if namespace = ""
46+
then result = type + "::" + base
47+
else result = namespace + "::" + type + "::" + base
48+
}
49+
4350
string encodeContent(ContentSet cs, string arg) {
44-
exists(FieldContent c |
51+
exists(FieldContent c, string namespace, string type, string base |
4552
cs.isSingleton(c) and
4653
// FieldContent indices have 0 for the address, 1 for content, so we need to subtract one.
4754
result = "Field" and
48-
arg = repeatStars(c.getIndirectionIndex() - 1) + c.getField().getName()
55+
c.getField().hasQualifiedName(namespace, type, base)
56+
|
57+
if arg.matches("%::%")
58+
then
59+
arg = repeatStars(c.getIndirectionIndex() - 1) + formatQualifiedName(namespace, type, base)
60+
else arg = repeatStars(c.getIndirectionIndex() - 1) + base
4961
)
5062
or
5163
exists(ElementContent ec |

0 commit comments

Comments
 (0)