Given a class with a private member of a different namespace
namespace Test { namespace Cfg {
class ExampleApi {
public:
ExampleApi() = default;
int someVar;
};
}}
class Example {
public:
Example() = default;
private:
Test::Cfg::ExampleApi _cfgApi;
};
I'm trying to match on the nested namespace Cfg for a cxxConstructorExpr as my final goal is to read some variable names from the ExampleApi class
I can match _cfgApi
by doing something like:
cxxConstructExpr(hasType(asString("Test::Cfg::ExampleApi")))
But this isn't good enough since the code base auto generates classes under Test::Cfg::*Api
and I haven't found usage of wild cards predicates.
I tried doing doing something with:
nestedNameSpecificierLoc(hasPrefix(loc(specifiesNamespace(hasName("Test")))))
which matches the namespace but not the nested namespace. I think it might be too much noise to go through in post-processing after the match happens.
I was playing with the hasParent
matcher but have had no luck so far.
So my question is: How do i match on the nested namespace for a class initialization.