[cfe-dev] Questions about Getting the Full Name in Using Declaration
Manuel Klimek via cfe-dev
cfe-dev at lists.llvm.org
Thu Oct 25 00:37:05 PDT 2018
The ::foo::bar is the nested name specifier.
According to https://clang.llvm.org/doxygen/classclang_1_1UsingDecl.html
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 <
ywu19 at students.claremontmckenna.edu> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181025/7e745b72/attachment.html>
More information about the cfe-dev
mailing list