CodeQL library for C/C++
codeql/cpp-all 0.12.10 (changelog, source)

Member predicate Declaration::getNamespace

Gets the innermost namespace which contains this declaration.

The result will either be GlobalNamespace, or the tightest lexically enclosing namespace block. In particular, note that for declarations within structures, the namespace of the declaration is the same as the namespace of the structure.

Namespace getNamespace()