[cfe-dev] PR23929 - Code completion for macros broken when modules enabled

Richard Smith richard at metafoo.co.uk
Tue Jun 23 14:15:58 PDT 2015


On Tue, Jun 23, 2015 at 10:53 AM, Jordan Rose <jordan_rose at apple.com> wrote:

> Hi, Richard. Thanks for all your improvements to modules this year! I just
> filed PR23929 <https://llvm.org/bugs/show_bug.cgi?id=23929>, which shows
> how code completion is no longer finding macros that come from modules. Any
> idea what should be changed here? If you don't have time to fix this I'm
> happy to be the one who actually codes it up, but at the moment I'm not
> even quite sure what piece is missing.
>

Identifiers that have macro names imported from modules get lazily updated,
and macro_begin isn't triggering enough updating to produce a complete map.
The easiest thing to do would be to walk the ModuleMacros map from within
macro_begin, and add entries for each identifier with any module macros to
the MacroMap in the CurSubmoduleState. (Alternatively, you could change
macro_begin/macro_end to return iterators over the identifier table that
filter out non-macro identifiers. Either way is a little wasteful, but
avoiding that waste would require implementing a rather fancy iterator,
which seems like overkill for this problem.)

I think this should be a straightforward fix; if you have problems, let me
know and I'll tackle it. Sorry for breaking you :-)

(Apart from code completion, this also affects a few other features that
> want to know all names provided by a particular header file.
> *cough*Swift*cough*)
>
> Thanks,
> Jordan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150623/8fd9dddd/attachment.html>


More information about the cfe-dev mailing list