Re: Questions about Getting the Full Name in Using Declaration

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Questions about Getting the Full Name in Using Declaration

David Blaikie via cfe-dev
The ::foo::bar is the nested name specifier. 
UsingDecl has getQualifier().
In clang-query you can follow this for a file like this:
t.cc:
namespace a { namespace b { class C; } }; 
using ::a::b::C

clang_query t.cc --
> set output print
clang-query> m usingDecl(has(nestedNameSpecifier().bind("x")))

Match #1:

Binding for "root":
using ::a::b::C
Binding for "x":
::a::b::
1 match.

On Thu, Oct 25, 2018 at 2:26 AM Yucheng Wu <[hidden email]> wrote:
Hello,

I'm working on writing new checks for clang-tidy with a group of students. In one of our checks, I want to get the full name of the alias of using declarations by calling getNameAsString() on the MatchedDecl (which is Result.Nodes.getNodeAs<UsingDecl>("x")), but the resulting string is only part of the full name. For example, for using ::foo::bar, the string after the above operation is bar instead of ::foo::bar. Is there a standard way of accessing the full name of the alias in a using declaration?

Best,
Yucheng Wu

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev