Matching a function in global namespace

Hi all,

I know how to match a function by its name, but how is it possible to check that it’s in the global namespace or namespace Foo?

Regards

Matthieu Brucher

Hi,

Hi,

I know how to match a function by its name, but how is it possible to check
that it’s in the global namespace or namespace Foo?

Let’s say you have:


int foo();

namespace n
{
int foo();
}

If you load this into clang-query, then just functionDecl() matches both
function declarations, but
functionDecl(hasParent(translationUnitDecl())) only matches the one in
the global namespace.

HTH,

Miklos

That was my missing piece, thanks a lot! With allOf, I can combine this with what I want to create and I suppose that even I could use namespaceDecl for hasParent as well.

Thanks, I will end up figuring this by myself…

Regards

Matthieu Brucher