Golevka / emacs-clang-complete-async

An emacs plugin to complete C and C++ code using libclang
360 stars 71 forks source link

Incorrect completions #28

Open dabrahams opened 11 years ago

dabrahams commented 11 years ago

Here's an example; I set HOME to an empty directory, started emacs, installed auto-complete from marmalade or melpa, loaded auto-complete-config explicitly (that step is missing from your README), then loaded your .el file and eval'ed the code from README.org.

Then I started editing at https://github.com/llvm-mirror/llvm/blob/master/lib/CodeGen/Analysis.cpp#L37

Note the completions listed are actually global symbols, most (all?) of which aren't valid at that position.

quack

terranpro commented 11 years ago

Hi Dave, This wouldn't be too suprising if clang doesn't see the definition of whatever type Ty is - I've seen this issue many times when my cflags were set incorrectly. Doesn't look like you've set your `ac-clang-cflags' ? Can you check that it is set and clang is actually searching your include paths correctly?

FWIW, for projects I use some bad elisp code (eval'd through .dir-locals.el of project root directory) that concats the gcc reported system include paths with the project (CMakeLists.txt) specified include directories. The result is a long list of includes for the buffer local variable ac-clang-cflags that yields completion for medium+ sized projects but still with some noticeable latency.

dabrahams commented 11 years ago

Yes, setting ac-clang-cflags works. Still, this looks like a bug to me.

Thanks for the hint about projects. You do similar things with llvm-config, FWIW.

dabrahams commented 11 years ago

Actually, even with ac-clang-cflags set, it offers completions from the global scope after identifier. or identifier-> in addition to all the correct completions from the scope of identifier. Definitely a bug.

terranpro commented 11 years ago

Actually, without any ac-clang-cflags magic, I was able to get completions just from headers under /usr/local/include

When you say it offers all completions, do you mean the clang-complete process buffer, the AC popup menu, or both?

In past versions of AC, and before the async clang-complete, I remember having similar issues with completions and tracked it to erroneous column numbers being passed to the process. Are you running the latest version of AC?

For example, it's been awhile but I remember the case was something like:

3: object->

And after instrumenting the elisp to see what got sent to the process, I saw it passed row = 3 but column = 0 instead of column = 10. Sometimes it seemed to work, and other times it didn't. Additionally, the problem seemed to disappear in a later update of my AC (and I couldn't find what change seemed to have the effect)

Perhaps you could try to reproduce this from the command-line? And/Or instrument the elisp to see all messages sent to the clang-async process? Any difference b/t non-async and async versions?

P.S. I'm also having slightly different but annoying issues w/completion (the mass flood @ global scope causing slow response time being one).

screenshot from 2013-04-30 14 42 06