This is an archive of the discontinued LLVM Phabricator instance.

[CodeComplete] suppress define X X macros
Needs ReviewPublic

Authored by sammccall on Jun 7 2018, 11:30 AM.

Details

Reviewers
ilya-biryukov
Summary

In particular, stderr etc where the equivalent symbols exist in the global
namespace. Having the symbol instead of the macro helps with ranking, and avoids
the current duplicate stderr suggestions.

@ilya-biryukov: think this is the right way to fix the duplicate completions?
Hiding the shadowed decl might be more correct, but it'd be hard *and* give
unfortunate ranking.

Diff Detail

Event Timeline

sammccall created this revision.Jun 7 2018, 11:30 AM

Hmm, musl does #define stderr (stderr) :-( And they discussed #define stderr (stderr+0).
(To enforce it's not assigned to etc)
https://github.com/cloudius-systems/musl/blob/master/include/stdio.h#L61

Ilya also pointed out offline the windows API convention: CreateFile is a macro for CreateFileW or CreateFileA. In these cases merely suppressing the macro isn't enough, we'd want to replace its info with the underlying decl.

Not sure how/whether to generalize this hack...

Hmm, musl does #define stderr (stderr) :-( And they discussed #define stderr (stderr+0).
(To enforce it's not assigned to etc)
https://github.com/cloudius-systems/musl/blob/master/include/stdio.h#L61

Ilya also pointed out offline the windows API convention: CreateFile is a macro for CreateFileW or CreateFileA. In these cases merely suppressing the macro isn't enough, we'd want to replace its info with the underlying decl.

Not sure how/whether to generalize this hack...

Yeah, I'm not sure. Maybe we should just special-case the known cases...

Going to put this on hold until someone actually reports the bug.