Skip to content

Commit db341cb

Browse files
committed
C++: Fix the definition of GlobalNamespace.getADeclaration()
Globals can still have declarations in declaration statements. We already rule out local variables etc via the isTopLevel check, so we don't need to consider DeclStmt.
1 parent 08f1748 commit db341cb

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

cpp/ql/src/semmle/code/cpp/Namespace.qll

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,6 @@ class GlobalNamespace extends Namespace {
190190

191191
override Declaration getADeclaration() {
192192
suppressWarningForUnused(this) and
193-
not exists(DeclStmt d |
194-
d.getADeclaration() = result and
195-
not result instanceof Function
196-
) and
197-
not exists(ConditionDeclExpr cde | cde.getVariable() = result) and
198193
result.isTopLevel() and
199194
not namespacembrs(_, unresolveElement(result))
200195
}

cpp/ql/test/library-tests/namespaces/namespaces/decls.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
| file://:0:0:0:0 | (global namespace) | file://:0:0:0:0 | operator= | false |
66
| file://:0:0:0:0 | (global namespace) | file://:0:0:0:0 | overflow_arg_area | false |
77
| file://:0:0:0:0 | (global namespace) | file://:0:0:0:0 | reg_save_area | false |
8+
| file://:0:0:0:0 | (global namespace) | namespaces.cpp:40:5:40:13 | globalInt | true |
89
| file://:0:0:0:0 | (global namespace) | namespaces.cpp:42:6:42:18 | globalIntUser | true |
910
| file://:0:0:0:0 | <none> | file://:0:0:0:0 | auto | false |
10-
| file://:0:0:0:0 | <none> | namespaces.cpp:40:5:40:13 | globalInt | true |
1111
| file://:0:0:0:0 | B | namespaces.cpp:32:7:32:7 | x | true |
1212
| namespaces.cpp:11:13:11:13 | C::D | file://:0:0:0:0 | p#0 | false |
1313
| namespaces.cpp:11:13:11:13 | C::D | file://:0:0:0:0 | p#0 | false |

0 commit comments

Comments
 (0)