mirror of
https://github.com/github/codeql.git
synced 2026-05-03 12:45:27 +02:00
C++: Support inline namespaces in hasQualifiedName
This commit is contained in:
@@ -26,6 +26,22 @@ class Namespace extends @namespace {
|
||||
else result = this.getName()
|
||||
}
|
||||
|
||||
string getQualifierForMembers() {
|
||||
if namespacembrs(_, this)
|
||||
then
|
||||
exists(Namespace ns |
|
||||
namespacembrs(ns, this)
|
||||
|
|
||||
result = ns.getQualifierForMembers() + "::" + this.getName()
|
||||
or
|
||||
// If this is an inline namespace, its members are also visible in any
|
||||
// namespace where the members of the parent are visible.
|
||||
namespace_inline(this) and
|
||||
result = ns.getQualifierForMembers()
|
||||
)
|
||||
else result = this.getName()
|
||||
}
|
||||
|
||||
Declaration getADeclaration() {
|
||||
if this.getName() = ""
|
||||
then result.isTopLevel() and not namespacembrs(_, result)
|
||||
@@ -331,7 +347,7 @@ cached
|
||||
private predicate declarationHasQualifiedName(
|
||||
string baseName, string typeQualifier, string namespaceQualifier, Declaration d
|
||||
) {
|
||||
namespaceQualifier = d.getNamespace().getQualifiedName() and
|
||||
namespaceQualifier = d.getNamespace().getQualifierForMembers() and
|
||||
(
|
||||
if hasTypeQualifier(d)
|
||||
then typeQualifier = d.getTypeQualifierWithoutArgs()
|
||||
|
||||
@@ -62,12 +62,12 @@ namespace templates {
|
||||
|
||||
namespace std {
|
||||
inline namespace cpp17 {
|
||||
void functionInTwoNamespaces(); // BUG: should also show up in `std`
|
||||
class classInTwoNameSpaces { // BUG: should also show up in `std`
|
||||
void functionInTwoNamespaces();
|
||||
class classInTwoNameSpaces {
|
||||
};
|
||||
inline namespace implementation {
|
||||
namespace ns {
|
||||
void functionInFourNamespaces(); // BUG: should also show up the outer namespaces
|
||||
void functionInFourNamespaces();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,10 +52,17 @@
|
||||
| qualifiedNames.cpp:53:12:53:12 | getMember | templates::getMember | templates | | getMember | (not global) |
|
||||
| qualifiedNames.cpp:53:12:53:20 | getMember | templates::getMember | templates | | getMember | (not global) |
|
||||
| qualifiedNames.cpp:57:8:57:10 | use | templates::use | templates | | use | (not global) |
|
||||
| qualifiedNames.cpp:65:10:65:32 | functionInTwoNamespaces | std::cpp17::functionInTwoNamespaces | std | | functionInTwoNamespaces | (not global) |
|
||||
| qualifiedNames.cpp:65:10:65:32 | functionInTwoNamespaces | std::cpp17::functionInTwoNamespaces | std::cpp17 | | functionInTwoNamespaces | (not global) |
|
||||
| qualifiedNames.cpp:66:11:66:11 | operator= | std::cpp17::classInTwoNameSpaces::operator= | std | classInTwoNameSpaces | operator= | (not global) |
|
||||
| qualifiedNames.cpp:66:11:66:11 | operator= | std::cpp17::classInTwoNameSpaces::operator= | std | classInTwoNameSpaces | operator= | (not global) |
|
||||
| qualifiedNames.cpp:66:11:66:11 | operator= | std::cpp17::classInTwoNameSpaces::operator= | std::cpp17 | classInTwoNameSpaces | operator= | (not global) |
|
||||
| qualifiedNames.cpp:66:11:66:11 | operator= | std::cpp17::classInTwoNameSpaces::operator= | std::cpp17 | classInTwoNameSpaces | operator= | (not global) |
|
||||
| qualifiedNames.cpp:66:11:66:30 | classInTwoNameSpaces | std::cpp17::classInTwoNameSpaces | std | | classInTwoNameSpaces | (not global) |
|
||||
| qualifiedNames.cpp:66:11:66:30 | classInTwoNameSpaces | std::cpp17::classInTwoNameSpaces | std::cpp17 | | classInTwoNameSpaces | (not global) |
|
||||
| qualifiedNames.cpp:70:14:70:37 | functionInFourNamespaces | std::cpp17::implementation::ns::functionInFourNamespaces | std::cpp17::implementation::ns | | functionInFourNamespaces | (not global) |
|
||||
| qualifiedNames.cpp:70:14:70:37 | functionInFourNamespaces | std::cpp17::implementation::ns::functionInFourNamespaces | std::cpp17::ns | | functionInFourNamespaces | (not global) |
|
||||
| qualifiedNames.cpp:70:14:70:37 | functionInFourNamespaces | std::cpp17::implementation::ns::functionInFourNamespaces | std::implementation::ns | | functionInFourNamespaces | (not global) |
|
||||
| qualifiedNames.cpp:70:14:70:37 | functionInFourNamespaces | std::cpp17::implementation::ns::functionInFourNamespaces | std::ns | | functionInFourNamespaces | (not global) |
|
||||
| qualifiedNames.cpp:78:7:78:15 | void_fptr | void_fptr | | | void_fptr | void_fptr |
|
||||
| qualifiedNames.cpp:79:11:79:14 | ptrs | ptrs | | | ptrs | ptrs |
|
||||
|
||||
Reference in New Issue
Block a user