[cfe-dev] Questions on Accessing Fully Qualified Names

Manuel Klimek via cfe-dev cfe-dev at lists.llvm.org
Tue Nov 13 01:00:35 PST 2018


On Tue, Nov 13, 2018 at 3:25 AM Shyan Akmal <sakmal at g.hmc.edu> wrote:

> Hello,
>
> I'm working on a check for fully qualifying names in using declarations.
>
> When creating an alias for an object outside the file, this just involves
> prepending the global specifier, so that " using foo::f; " becomes " using
> ::foo::f; ".
>
> However, this shouldn't work in general for objects declaring in the
> existing file.
>
> For example, for code like
>
> namespace example {
>
> namespace util {
>
>
>
> namespace internal {
>
> enum Color {Red, Green, Blue};
>
> }
>
> using internal::Color;
>
>
>
> }
>
> }
>
>
> I'd like to replace "internal::Color" with
> "::example::util::internal::Color" instead of "::internal::Color".
>
> Given this motivation, I have two questions:
>
>    1. Given a name inside a using declaration, what's the best way to
>    check if that name is declared in the current file?
>
>
Why does that matter? Can't the same happen across files?

>
>    1. Given an object declaration, what is the recommended way of finding
>    it's full nested-name-specifier? (I think getUnderlyingDecl() probably
>    works here)
>
> I think printQualifiedName on the namedDecl is your best bet; I don't know
how getUnderlyingDecl() would help?

Cheers,
/Manuel

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181113/9dfef021/attachment.html>


More information about the cfe-dev mailing list