This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Fix code completion in MACROs with stringification.
ClosedPublic

Authored by ioeric on May 23 2018, 6:27 AM.

Details

Summary

Currently, we only handle the first callback from sema code completion
and ignore results from potential following callbacks. This causes
causes loss of completion results when multiple contexts are tried by Sema.

For example, we wouldn't get any completion result in the following completion
as the first attemped context is natural language which has no
candidate. The parser would backtrack and tried a completion with AST
semantic, which would find candidate "::x".

void f(const char*, int);
#define F(x) f(#x, x)
int x;
void main() {
	F(::^);
}

To fix this, we only process a sema callback when it gives completion results or
the context supports index-based completion.

Diff Detail

Repository
rL LLVM

Event Timeline

ioeric created this revision.May 23 2018, 6:27 AM
ioeric updated this revision to Diff 148206.May 23 2018, 7:07 AM
  • Fix broken test
This revision is now accepted and ready to land.May 24 2018, 2:10 AM
This revision was automatically updated to reflect the committed changes.