Skip to content

Commit 2b424bf

Browse files
committed
C++: Clarify getAQualifierForMembers
1 parent df4c576 commit 2b424bf

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

cpp/ql/src/semmle/code/cpp/internal/QualifiedName.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,28 @@ class Namespace extends @namespace {
2626
else result = this.getName()
2727
}
2828

29-
string getQualifierForMembers() {
29+
/**
30+
* Gets a namespace qualifier, like `"namespace1::namespace2"`, through which
31+
* the members of this namespace can be named. When `inline namespace` is
32+
* used, this predicate may have multiple results.
33+
*
34+
* This predicate does not take namespace aliases into account. Unlike inline
35+
* namespaces, specialization of templates cannot happen through an alias.
36+
* Aliases are also local to the compilation unit, while inline namespaces
37+
* affect the whole program.
38+
*/
39+
string getAQualifierForMembers() {
3040
if namespacembrs(_, this)
3141
then
3242
exists(Namespace ns |
3343
namespacembrs(ns, this)
3444
|
35-
result = ns.getQualifierForMembers() + "::" + this.getName()
45+
result = ns.getAQualifierForMembers() + "::" + this.getName()
3646
or
3747
// If this is an inline namespace, its members are also visible in any
3848
// namespace where the members of the parent are visible.
3949
namespace_inline(this) and
40-
result = ns.getQualifierForMembers()
50+
result = ns.getAQualifierForMembers()
4151
)
4252
else result = this.getName()
4353
}
@@ -347,7 +357,7 @@ cached
347357
private predicate declarationHasQualifiedName(
348358
string baseName, string typeQualifier, string namespaceQualifier, Declaration d
349359
) {
350-
namespaceQualifier = d.getNamespace().getQualifierForMembers() and
360+
namespaceQualifier = d.getNamespace().getAQualifierForMembers() and
351361
(
352362
if hasTypeQualifier(d)
353363
then typeQualifier = d.getTypeQualifierWithoutArgs()

0 commit comments

Comments
 (0)