Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 25200b4

Browse files
committed
C++: Implement the namespace field.
1 parent a552790 commit 25200b4

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

cpp/ql/lib/semmle/code/cpp/dataflow/ExternalFlow.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,11 @@ private Element interpretElement0(
391391
string namespace, string type, boolean subtypes, string name, string signature
392392
) {
393393
elementSpec(namespace, type, subtypes, name, signature, _) and
394-
namespace = "" and // TODO: Fill out when we properly extract modules.
395394
(
396395
// Non-member functions
397396
exists(Function func |
398397
func.getName() = name and
398+
func.getNamespace().getQualifiedName() = namespace and
399399
type = "" and
400400
matchesSignature(func, signature) and
401401
subtypes = false and
@@ -406,6 +406,7 @@ private Element interpretElement0(
406406
// Member functions
407407
exists(Class namedClass, Class classWithMethod, Function method |
408408
classWithMethod = method.getClassAndName(name) and
409+
classWithMethod.getNamespace().getQualifiedName() = namespace and
409410
namedClass.getName() = type and
410411
matchesSignature(method, signature) and
411412
result = method
@@ -424,6 +425,7 @@ private Element interpretElement0(
424425
exists(Class namedClass, Class classWithMember, MemberVariable member |
425426
member.getName() = name and
426427
member = classWithMember.getAMember() and
428+
classWithMember.getNamespace().getQualifiedName() = namespace and
427429
namedClass.getName() = type and
428430
result = member
429431
|

cpp/ql/test/library-tests/dataflow/models-as-data/tests.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ void test_sources() {
5555
int e = localMadSource();
5656
sink(e); // $ ir
5757

58-
sink(MyNamespace::namespaceLocalMadSource()); // $ MISSING: ir
58+
sink(MyNamespace::namespaceLocalMadSource()); // $: ir
5959
sink(MyNamespace::namespaceLocalMadSourceVar); // $ MISSING: ir
60-
sink(MyNamespace::MyNamespace2::namespace2LocalMadSource()); // $ MISSING: ir
61-
sink(MyNamespace::localMadSource()); // $ SPURIOUS: ir (the MyNamespace version of this function is not a source)
60+
sink(MyNamespace::MyNamespace2::namespace2LocalMadSource()); // $ ir
61+
sink(MyNamespace::localMadSource()); // $ (the MyNamespace version of this function is not a source)
6262
sink(namespaceLocalMadSource()); // (the global namespace version of this function is not a source)
6363
}
6464

@@ -241,8 +241,8 @@ void test_class_members() {
241241

242242
mc.memberMadSinkVar = source(); // $ MISSING: ir
243243

244-
mnc.namespaceMemberMadSinkArg0(source()); // $ MISSING: ir
245-
MyNamespace::MyClass::namespaceStaticMemberMadSinkArg0(source()); // $ MISSING: ir
244+
mnc.namespaceMemberMadSinkArg0(source()); // $ ir
245+
MyNamespace::MyClass::namespaceStaticMemberMadSinkArg0(source()); // $ ir
246246
mnc.namespaceMemberMadSinkVar = source(); // $ MISSING: ir
247247
MyNamespace::MyClass::namespaceStaticMemberMadSinkVar = source(); // $ MISSING: ir
248248

0 commit comments

Comments
 (0)