[cfe-dev] Questions on Accessing Fully Qualified Names

Manuel Klimek via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 14 23:22:48 PST 2018


On Thu, 15 Nov 2018, 01:56 Shyan Akmal <sakmal at g.hmc.edu wrote:

> Thanks for your response.
>
> I worded my question very poorly, sorry about that. In 1, I meant to ask
> *how* one can find the location of a name being declared (in the file
> overall - included the expanded headers). This is because plan was to find
> the declaration location, and then try to use getUnderlyingDecl() at that
> node to figure out the full nested-name-specifier required for a fully
> qualified name.
>

I'm a bit confused by this - there might not be a fqn ever spelled out.
Perhaps if you give an example that would help :)


> There could definitely be an alternate, better approach that I'm not
> seeing though.
>
> Thanks for the suggestion - I'll look into printQualifiedName.
>
> - Shyan
>
> On Tue, Nov 13, 2018 at 1:00 AM Manuel Klimek <klimek at google.com> wrote:
>
>> 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/20181115/f7bd910c/attachment.html>


More information about the cfe-dev mailing list