[cfe-dev] Ensure name doesn't already exist

Manuel Klimek klimek at google.com
Thu Jul 3 10:57:00 PDT 2014


On Thu, Jul 3, 2014 at 6:31 PM, Daniel Dilts <diltsman at gmail.com> wrote:

> I seem to remember reading somewhere that you could implement autocomplete
> using Clang, and it would list all symbols that are valid at that
> location.  Couldn't something like this be done to determine if a name
> already exists at a location?
>

The way autocomplete works (if I'm not mistaken) is that it parses up the
the point of completion and then halts in the semantic analysis and outputs
what can come there.
The problem is that this information is lost once the AST is built.


>
>
> On Thu, Jul 3, 2014 at 6:02 AM, Manuel Klimek <klimek at google.com> wrote:
>
>> On Tue, Jul 1, 2014 at 9:11 PM, Daniel Dilts <diltsman at gmail.com> wrote:
>>
>>> I am possibly renaming a class.  I would like to make sure that the new
>>> name doesn't already exist.  Given that I am generating the new name, I
>>> have it in a std::string.
>>>
>>> How would I check to see if there is already something with the new name
>>> in the DeclContext?  I assume I would use DeclContext::lockup of some
>>> flavor.  Also, the new name does not specify any namespaces (no :: anywhere
>>> in it).
>>>
>>
>> Unfortunately that's basically impossible in C++ (argument dependent
>> lookup etc). But the easy cases should be handled by doing
>> DeclContext::lookup throught all parent contexts.
>>
>>
>>>
>>> _______________________________________________
>>> cfe-dev mailing list
>>> cfe-dev at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140703/296d0f65/attachment.html>


More information about the cfe-dev mailing list