Andersbakken / rtags

A client/server indexer for c/c++/objc[++] with integration for Emacs based on clang.
http://www.rtags.net
GNU General Public License v3.0
1.83k stars 253 forks source link

Cannot get code completion with company to work #989

Closed clearmisp closed 6 years ago

clearmisp commented 7 years ago

Please mark appropriate

Problem description

I have successfully configured RTags to navigate symbols, now I try to move from Irony to RTags for code completion and I cannot make it work. I compiled and installed RTags using M-x rtags-install. This is my configuration in init.el.

`(use-package company :ensure t :diminish "Comp" :init (global-company-mode) :config (setq company-global-modes '(not eshell-mode shell-mode)) ;; company already includes company-clang but we have to delete company-semantic which have higher ;; precedence in company-backends. This together with include paths in .dir-local.el is the only ;; configuration needed for company-clang. (setq company-backends (delete 'company-semantic company-backends)))

(defun my-flycheck-rtags-setup () "RTags create more accurate overlays than Flychceck." (flycheck-select-checker 'rtags) (setq-local flycheck-highlighting-mode nil) (setq-local flycheck-check-syntax-automatically nil))

(use-package rtags :ensure t :config (add-hook 'c-mode-common-hook 'rtags-start-process-unless-running) (rtags-enable-standard-keybindings) (setq rtags-autostart-diagnostics t) (rtags-diagnostics) (setq rtags-completions-enabled t) (push 'company-rtags company-backends) (use-package helm-rtags :ensure t :config (setq rtags-display-result-backend 'helm)) (use-package flycheck-rtags :ensure t :init (add-hook 'c-mode-common-hook 'my-flycheck-rtags-setup)))`

Expected behavior

Code should be completed using company mode.

Actual behavior

Nothing happens when company tries to complete code. Sometimes I get completions that are incorrect in the sense that it's not what I want, most of the time nothing happens.

If I examine company-backends I can see that company-rtags is prepended correctly. But when I do company-complete nothing shows up in the rdm log. If I do rc --code-complete-aton the command line it shows up in the rdm log but the command doesn't return anything.

Environment

myrgy commented 7 years ago

Hi, I have similar configuration with use-package. rtags 2.10, 2.11 + company-rtags + helm

One important thing is that I have special toolchaing instead of system one, but I still have wrong -system path in file options. I was trying to add my system path to .rdmrc and now it looks like: -isystem /opt/mytools/vendor/gcc/6.3.0/include/ -isystem /usr/lib64/clang/3.9.1/include/

Main issue is that completion works from time to time. for example it works for my classes, but no for std.

UPD: code sample: .... lo ... I did a brief investigation (tried to connect to rdm service to grab some logs) so, it's able to complete when I pass /usr/bin/rc --current-file=test.h -b --unsaved-file=test.h :30411 -z --verify-version=124 --code-complete-at test.h :119:5: --synchronous-completions --elisp --code-complete-prefix=lo

then I'm able to get completion and now it looks like ... logger_ ... when I'm tryping -> and trying to get some completion it looks like: /usr/bin/rc --current-file=test.h -b --unsaved-file=test.h:30413 -z --verify-version=124 --code-complete-at test.h:119:14: --synchronous-completions --elisp --code-complete-prefix= No completion results available test.h:119:14: 0

I have another project and completion there works. even after -> and .

but first project is using C++14 and rtags-reparse-file cause such messages: Output from test.cpp: /../lib/gcc/x86_64-redhat-linux/6.3.1/../../../../include/c++/6.3.1/atomic:185:7: error: exception specification of explicitly defaulted default constructor does not match the calculated one Loop.h:207:27: note: in instantiation of template class 'std::atomic<std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1, 1000000000> > > >' requested here (https://stackoverflow.com/questions/29483120/program-with-noexcept-constructor-accepted-by-gcc-rejected-by-clang)

here is rtags build logs: https://copr-be.cloud.fedoraproject.org/results/myrgy/rtags/fedora-25-x86_64/00581074-rtags/builder-live.log

UPD2: I fixed that issue - but as a result completion was broken. rdm doesn't complains about any issue - just 0 completions.

UPD3: it's a bit strangle error about but it's compileable with my stdlibc++ static_assert(std::is_trivially_copyable::value, "Time point should be trivially copyable for std::atomic");

UPD4: I noticed that rdm is using wrong system include dir. I have multiple toolchaings installed and cmake was configure to use non-default one. but -system path is wrong and headers location is wrong as well

myrgy commented 7 years ago

@Andersbakken , in my case completion doesn't work because instead of my std implementation ram is trying to load clang version. (My compiler and std are located in a separate location)

I was trying to pass my library location using .rmdrc cat ~/.rdmrc --isystem=/opt/my_toolchaing/vendor/gcc/6.3.0/include

but it doesn't solve the issue. Solution was to disable clang search path: https://github.com/Andersbakken/rtags/blob/master/src/Server.cpp#L87 ` // Absolute paths to search (under) for (clang) system include files // Iterate until we find a dir at /clang//include. // As of clang 4.0.0 we don't need (and can't have) these includes on Mac.

if CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR) >= CINDEX_VERSION_ENCODE(0, 37) && defined(OS_Darwin)

static const List sSystemIncludePaths;

else

static const List sSystemIncludePaths = {

Any hints about proper fix implementation? maybe some flag to be able to control that behaviour? Is there any was to ask compiler about std location?

Andersbakken commented 7 years ago

I added a switch to disable the libclang includepath.

You can now do:

rdm --no-libclang-include-path

Does this take care of it?

myrgy commented 7 years ago

Hi Anders In my case it might be a solution - but he best way is to be able to configure it per-project. For example I have one "pet" project which is compiles with system-default compiler and several projects with dedicated toolchaings. Is it possible to behave in that way? (I mean configre projects using .dir-locales.el and for some projects allows to use default path while for other force there own configurations)

myrgy commented 7 years ago

@Andersbakken , I was trying to use new flag, but it sill works in a bit odd way: here is content of my ~/.rdmrc

--no-libclang-include-path --isystem=/opt/cresearch/vendor/gcc/6.3.0/ --isystem=/opt/cresearch/vendor/gcc/6.3.0/include/c++/6.3.0 --isystem=/opt/cresearch/vendor/gcc/6.3.0/include --isystem=/opt/cresearch/vendor/gcc/6.3.0/lib/gcc/x86_64-cwr-linux-gnu/6.3.0/include/

rc --dump-compile-tests prints something like:

{
        "command":  "/opt/cresearch/bin/g++ -std=c++14 -Wall -Wextra -Wpedantic -Wsuggest-attribute=const -Wsuggest-final-types -Wsuggest-final-methods -Wsuggest-override -fvisibility=hidden -g -c -ferror-limit=50 -Wall -fspell-checking -Wno-unknown-warning-option -DRTAGS= -I/home/user/Workspace/feeds/common -I/home/user/Workspace/feeds/vendor -I/home/user/Workspace/feeds/fix/include -I/home/user/Workspace/feeds/core/include -I/home/user/Workspace/feeds/vendor/spdlog/include -I/home/user/Workspace/feeds/vendor/. -isystem /opt/cresearch/vendor/gcc/6.3.0/ -isystem /opt/cresearch/vendor/gcc/6.3.0/include/c++/6.3.0/ -isystem /opt/cresearch/vendor/gcc/6.3.0/include/ -isystem /opt/cresearch/vendor/gcc/6.3.0/lib/gcc/x86_64-cwr-linux-gnu/6.3.0/include/ -o /home/user/Workspace/feeds/build/fix/CMakeFiles/FIXBookTest.dir/test/BookTest.cpp.o /home/user/Workspace/feeds/fix/test/BookTest.cpp",
        "directory":    "/home/user/Workspace/feeds/build/fix/",
        "file": "/home/user/Workspace/feeds/fix/test/BookTest.cpp"
    }, 

but rc --rdm-log still print something like:

Output from /home/user/Workspace/feeds/fix/test/Server.cpp:
/usr/include/limits.h:123:16: fatal error: 'limits.h' file not found
handleInclude failed (nil) inclusion directive include limits.h /usr/include/limits.h:123:1
handleInclude failed (nil) inclusion directive include limits.h /usr/include/limits.h:123:1

so my question is - do you have any idea how can I control that behavior? Why we have some path as include, while it was not specified?

NOTE: but - I don't know why - but completion now works even with this errors.

And thanks a lot for you support!

VanLaser commented 7 years ago

I have a similar problem (I guess) - a simple test.c file with a main function and including <stdio.h> can not complete fprintf, but it can complete ::fprintf.

➭ rc --rdm-log                     
[100%] 1/1 23:05:15 ~/tests/test.c in 124ms. (4495 syms, 4284 symNames, 99 includes, 53 of 53 files, symbols: 4950 of 4950, 5860 cursors, 3027855 bytes written, 52 queried 4ms) (28/45/22ms). (priority 0)
Jobs took 0.15s. We're using 7mb of memory. 
Output from /home/laser/tests/test.c:
CI::parse loading unit: clang "-ferror-limit=50" "-Wall" "-fspell-checking" "-Wno-unknown-warning-option" "-DRTAGS=" "-isystem" "/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/include/" "-isystem" "/usr/local/include/" "-isystem" "/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/include-fixed/" "-isystem" "/usr/include/" /home/laser/tests/test.c true
➭ rc --dump-compile-commands
[{
        "command":  "/usr/bin/gcc -ferror-limit=50 -Wall -fspell-checking -Wno-unknown-warning-option -DRTAGS= -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/include/ -isystem /usr/local/include/ -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/include-fixed/ -isystem /usr/include/ -o /home/laser/tests/test /home/laser/tests/test.c",
        "directory":    "/home/laser/tests/",
        "file": "/home/laser/tests/test.c"
    }]

Arch Linux, stock clang version 4.0.1 with rtags-git from AUR (version 2.13.118). Any clues?

myrgy commented 7 years ago

could you please share you test.c file?

VanLaser commented 7 years ago

It really was a test file:

#include <stdio.h>

int main()
{
    <cursor here>
    return 0;
}
VanLaser commented 7 years ago

Actually, it's even more fishy. After writing fp the completion only offers fpos_t (I do check with company-diag to see what backend is active, and yep it's company-rtags). But, if I have only f for completion, fprintf is offered for completion! company-diag looks as in the listing below. So what could it be? A bug in selecting candidates? My Emacs version? BTW, company-clang backend has no such problem, when I'm using it instead of company-rtags ... although in that case the completion results are sorted - is sorting used in reducing the candidates after pressing another letter?

Emacs 26.0.50 (x86_64-pc-linux-gnu) of 2017-08-06 on i7
Company 0.9.4

company-backends: (company-rtags company-bbdb company-nxml company-css company-eclim company-clang company-xcode company-cmake company-capf company-files
           (company-dabbrev-code company-gtags company-etags company-keywords)
           company-oddmuse company-dabbrev)

Used backend: company-rtags
Major mode: c-mode
Prefix: #("f" 0 1
  (fontified t))

Completions:
  #("fopen" 0 1 (meta-insert "FILE * fopen(const char *restrict __filename, const char *restrict __modes)" meta "FILE * fopen(const char *restrict __filename, const char *restrict __modes)" brief "")) "(const char *restrict __filename, const char *restrict __modes)"
  #("fexecve" 0 1 (meta-insert "int fexecve(int __fd, char *const *__argv, char *const *__envp)" meta "int fexecve(int __fd, char *const *__argv, char *const *__envp)" brief "")) "(int __fd, char *const *__argv, char *const *__envp)"
  #("ftello" 0 1 (meta-insert "__off_t ftello(FILE *__stream)" meta "__off_t ftello(FILE *__stream)" brief "")) "(FILE *__stream)"
  #("fdopen" 0 1 (meta-insert "FILE * fdopen(int __fd, const char *__modes)" meta "FILE * fdopen(int __fd, const char *__modes)" brief "")) "(int __fd, const char *__modes)"
  #("fdatasync" 0 1 (meta-insert "int fdatasync(int __fildes)" meta "int fdatasync(int __fildes)" brief "")) "(int __fildes)"
  #("fgetc_unlocked" 0 1 (meta-insert "int fgetc_unlocked(FILE *__stream)" meta "int fgetc_unlocked(FILE *__stream)" brief "")) "(FILE *__stream)"
  #("fread" 0 1 (meta-insert "size_t fread(void *restrict __ptr, size_t __size, size_t __n, FILE *restrict __stream)" meta "size_t fread(void *restrict __ptr, size_t __size, size_t __n, FILE *restrict __stream)" brief "")) "(void *restrict __ptr, size_t __size, size_t __n, FILE *restrict __stream)"
  #("fputc_unlocked" 0 1 (meta-insert "int fputc_unlocked(int __c, FILE *__stream)" meta "int fputc_unlocked(int __c, FILE *__stream)" brief "")) "(int __c, FILE *__stream)"
  #("fseek" 0 1 (meta-insert "int fseek(FILE *__stream, long __off, int __whence)" meta "int fseek(FILE *__stream, long __off, int __whence)" brief "")) "(FILE *__stream, long __off, int __whence)"
  #("feof_unlocked" 0 1 (meta-insert "int feof_unlocked(FILE *__stream)" meta "int feof_unlocked(FILE *__stream)" brief "")) "(FILE *__stream)"
  #("fseeko" 0 1 (meta-insert "int fseeko(FILE *__stream, __off_t __off, int __whence)" meta "int fseeko(FILE *__stream, __off_t __off, int __whence)" brief "")) "(FILE *__stream, __off_t __off, int __whence)"
  #("fork" 0 1 (meta-insert "__pid_t fork()" meta "__pid_t fork()" brief "")) "()"
  #("fclose" 0 1 (meta-insert "int fclose(FILE *__stream)" meta "int fclose(FILE *__stream)" brief "")) "(FILE *__stream)"
  #("faccessat" 0 1 (meta-insert "int faccessat(int __fd, const char *__file, int __type, int __flag)" meta "int faccessat(int __fd, const char *__file, int __type, int __flag)" brief "")) "(int __fd, const char *__file, int __type, int __flag)"
  #("fd_set" 0 1 (meta-insert "fd_set" meta "fd_set" brief ""))
  #("ferror" 0 1 (meta-insert "int ferror(FILE *__stream)" meta "int ferror(FILE *__stream)" brief "")) "(FILE *__stream)"
  #("fchownat" 0 1 (meta-insert "int fchownat(int __fd, const char *__file, __uid_t __owner, __gid_t __group, int __flag)" meta "int fchownat(int __fd, const char *__file, __uid_t __owner, __gid_t __group, int __flag)" brief "")) "(int __fd, const char *__file, __uid_t __owner, __gid_t __group, int __flag)"
  #("fflush_unlocked" 0 1 (meta-insert "int fflush_unlocked(FILE *__stream)" meta "int fflush_unlocked(FILE *__stream)" brief "")) "(FILE *__stream)"
  #("fpathconf" 0 1 (meta-insert "long fpathconf(int __fd, int __name)" meta "long fpathconf(int __fd, int __name)" brief "")) "(int __fd, int __name)"
  #("fsid_t" 0 1 (meta-insert "fsid_t" meta "fsid_t" brief ""))
  #("flockfile" 0 1 (meta-insert "void flockfile(FILE *__stream)" meta "void flockfile(FILE *__stream)" brief "")) "(FILE *__stream)"
  #("fd_mask" 0 1 (meta-insert "fd_mask" meta "fd_mask" brief ""))
  #("fread_unlocked" 0 1 (meta-insert "size_t fread_unlocked(void *restrict __ptr, size_t __size, size_t __n, FILE *restrict __stream)" meta "size_t fread_unlocked(void *restrict __ptr, size_t __size, size_t __n, FILE *restrict __stream)" brief "")) "(void *restrict __ptr, size_t __size, size_t __n, FILE *restrict __stream)"
  #("free" 0 1 (meta-insert "void free(void *__ptr)" meta "void free(void *__ptr)" brief "")) "(void *__ptr)"
  #("fsetpos" 0 1 (meta-insert "int fsetpos(FILE *__stream, const fpos_t *__pos)" meta "int fsetpos(FILE *__stream, const fpos_t *__pos)" brief "")) "(FILE *__stream, const fpos_t *__pos)"
  #("ftruncate" 0 1 (meta-insert "int ftruncate(int __fd, __off_t __length)" meta "int ftruncate(int __fd, __off_t __length)" brief "")) "(int __fd, __off_t __length)"
  #("fchown" 0 1 (meta-insert "int fchown(int __fd, __uid_t __owner, __gid_t __group)" meta "int fchown(int __fd, __uid_t __owner, __gid_t __group)" brief "")) "(int __fd, __uid_t __owner, __gid_t __group)"
  #("fcvt_r" 0 1 (meta-insert "int fcvt_r(double __value, int __ndigit, int *restrict __decpt, int *restrict __sign, char *restrict __buf, size_t __len)" meta "int fcvt_r(double __value, int __ndigit, int *restrict __decpt, int *restrict __sign, char *restrict __buf, size_t __len)" brief "")) "(double __value, int __ndigit, int *restrict __decpt, int *restrict __sign, char *restrict __buf, size_t __len)"
  #("ftell" 0 1 (meta-insert "long ftell(FILE *__stream)" meta "long ftell(FILE *__stream)" brief "")) "(FILE *__stream)"
  #("fprintf" 0 1 (meta-insert "int fprintf(FILE *restrict __stream, const char *restrict __format, ...)" meta "int fprintf(FILE *restrict __stream, const char *restrict __format, ...)" brief "")) "(FILE *restrict __stream, const char *restrict __format, ...)"
  #("fsfilcnt_t" 0 1 (meta-insert "fsfilcnt_t" meta "fsfilcnt_t" brief ""))
  #("fpos_t" 0 1 (meta-insert "fpos_t" meta "fpos_t" brief ""))
  #("freopen" 0 1 (meta-insert "FILE * freopen(const char *restrict __filename, const char *restrict __modes, FILE *restrict __stream)" meta "FILE * freopen(const char *restrict __filename, const char *restrict __modes, FILE *restrict __stream)" brief "")) "(const char *restrict __filename, const char *restrict __modes, FILE *restrict __stream)"
  #("fileno_unlocked" 0 1 (meta-insert "int fileno_unlocked(FILE *__stream)" meta "int fileno_unlocked(FILE *__stream)" brief "")) "(FILE *__stream)"
  #("fgetpos" 0 1 (meta-insert "int fgetpos(FILE *restrict __stream, fpos_t *restrict __pos)" meta "int fgetpos(FILE *restrict __stream, fpos_t *restrict __pos)" brief "")) "(FILE *restrict __stream, fpos_t *restrict __pos)"
  #("ffs" 0 1 (meta-insert "int ffs(int __i)" meta "int ffs(int __i)" brief "")) "(int __i)"
  #("fgetc" 0 1 (meta-insert "int fgetc(FILE *__stream)" meta "int fgetc(FILE *__stream)" brief "")) "(FILE *__stream)"
  #("fgets" 0 1 (meta-insert "char * fgets(char *restrict __s, int __n, FILE *restrict __stream)" meta "char * fgets(char *restrict __s, int __n, FILE *restrict __stream)" brief "")) "(char *restrict __s, int __n, FILE *restrict __stream)"
  #("fcvt" 0 1 (meta-insert "char * fcvt(double __value, int __ndigit, int *restrict __decpt, int *restrict __sign)" meta "char * fcvt(double __value, int __ndigit, int *restrict __decpt, int *restrict __sign)" brief "")) "(double __value, int __ndigit, int *restrict __decpt, int *restrict __sign)"
  #("fsync" 0 1 (meta-insert "int fsync(int __fd)" meta "int fsync(int __fd)" brief "")) "(int __fd)"
  #("fwrite" 0 1 (meta-insert "size_t fwrite(const void *restrict __ptr, size_t __size, size_t __n, FILE *restrict __s)" meta "size_t fwrite(const void *restrict __ptr, size_t __size, size_t __n, FILE *restrict __s)" brief "")) "(const void *restrict __ptr, size_t __size, size_t __n, FILE *restrict __s)"
  #("fscanf" 0 1 (meta-insert "int fscanf(FILE *restrict __stream, const char *restrict __format, ...)" meta "int fscanf(FILE *restrict __stream, const char *restrict __format, ...)" brief "")) "(FILE *restrict __stream, const char *restrict __format, ...)"
  #("fchdir" 0 1 (meta-insert "int fchdir(int __fd)" meta "int fchdir(int __fd)" brief "")) "(int __fd)"
  #("fwrite_unlocked" 0 1 (meta-insert "size_t fwrite_unlocked(const void *restrict __ptr, size_t __size, size_t __n, FILE *restrict __stream)" meta "size_t fwrite_unlocked(const void *restrict __ptr, size_t __size, size_t __n, FILE *restrict __stream)" brief "")) "(const void *restrict __ptr, size_t __size, size_t __n, FILE *restrict __stream)"
  #("fmemopen" 0 1 (meta-insert "FILE * fmemopen(void *__s, size_t __len, const char *__modes)" meta "FILE * fmemopen(void *__s, size_t __len, const char *__modes)" brief "")) "(void *__s, size_t __len, const char *__modes)"
  #("feof" 0 1 (meta-insert "int feof(FILE *__stream)" meta "int feof(FILE *__stream)" brief "")) "(FILE *__stream)"
  #("fflush" 0 1 (meta-insert "int fflush(FILE *__stream)" meta "int fflush(FILE *__stream)" brief "")) "(FILE *__stream)"
  #("fputc" 0 1 (meta-insert "int fputc(int __c, FILE *__stream)" meta "int fputc(int __c, FILE *__stream)" brief "")) "(int __c, FILE *__stream)"
  #("funlockfile" 0 1 (meta-insert "void funlockfile(FILE *__stream)" meta "void funlockfile(FILE *__stream)" brief "")) "(FILE *__stream)"
  #("fputs" 0 1 (meta-insert "int fputs(const char *restrict __s, FILE *restrict __stream)" meta "int fputs(const char *restrict __s, FILE *restrict __stream)" brief "")) "(const char *restrict __s, FILE *restrict __stream)"
  #("ferror_unlocked" 0 1 (meta-insert "int ferror_unlocked(FILE *__stream)" meta "int ferror_unlocked(FILE *__stream)" brief "")) "(FILE *__stream)"
  #("fileno" 0 1 (meta-insert "int fileno(FILE *__stream)" meta "int fileno(FILE *__stream)" brief "")) "(FILE *__stream)"
  #("ftrylockfile" 0 1 (meta-insert "int ftrylockfile(FILE *__stream)" meta "int ftrylockfile(FILE *__stream)" brief "")) "(FILE *__stream)"
  #("fsblkcnt_t" 0 1 (meta-insert "fsblkcnt_t" meta "fsblkcnt_t" brief ""))

Update: same happens if I try from the command line, e.g.:

➭  /usr/bin/rc -b  -z --verify-version=124 --code-complete-at /home/laser/tests/test.c:4:2: --synchronous-completions  --code-complete-prefix=fp
 fpos_t fpos_t TypedefDecl   
 _G_fpos_t _G_fpos_t TypedefDecl   
 _G_fpos64_t _G_fpos64_t TypedefDecl   
 _IO_fpos_t _IO_fpos_t macro definition   
 _IO_fpos64_t _IO_fpos64_t macro definition 
myrgy commented 7 years ago

I gave a try and it works. rtags - master. llvm 3.9.1

btw, I saw that 2.13 version was released, but unfortunately I was unable to install it due to some download issues.

But in general autocompletion is still unstable. At lest on my projects, but I suspect llvm 3.9 which is unable to compile some code, which works fine with gcc 6.3.

Company 0.9.4                                                                                                                             

company-backends: (company-rtags company-c-headers                                                                                        
               (company-dabbrev-code company-gtags company-etags company-keywords)                                                        
               company-files company-dabbrev)                                                                                             

Used backend: company-rtags                                                                                                               
Major mode: c++-mode                                                                                                                      
Prefix: #("fp" 0 2                                                                                                                        
  (fontified t))                                                                                                                          

Completions:                                                                                                                              
  #("fprintf" 0 1 (meta-insert "int fprintf(FILE *__restrict __stream, const char *__restrict __format, ...)" meta "int fprintf(FILE *__r\
estrict __stream, const char *__restrict __format, ...)" brief "")) "(FILE *__restrict __stream, const char *__restrict __format, ...)"   
  #("fputs_unlocked" 0 1 (meta-insert "int fputs_unlocked(const char *__restrict __s, FILE *__restrict __stream)" meta "int fputs_unlocke\
d(const char *__restrict __s, FILE *__restrict __stream)" brief "")) "(const char *__restrict __s, FILE *__restrict __stream)"            
  #("fpos64_t" 0 1 (meta-insert "fpos64_t" meta "fpos64_t" brief ""))                                                                     
  #("fputc" 0 1 (meta-insert "int fputc(int __c, FILE *__stream)" meta "int fputc(int __c, FILE *__stream)" brief "")) "(int __c, FILE *_\
_stream)"                                                                                                                                 
  #("fputs" 0 1 (meta-insert "int fputs(const char *__restrict __s, FILE *__restrict __stream)" meta "int fputs(const char *__restrict __\
s, FILE *__restrict __stream)" brief "")) "(const char *__restrict __s, FILE *__restrict __stream)"                                       
  #("fputc_unlocked" 0 1 (meta-insert "int fputc_unlocked(int __c, FILE *__stream)" meta "int fputc_unlocked(int __c, FILE *__stream)" br\
ief "")) "(int __c, FILE *__stream)"                                                                                                      
  #("fpos_t" 0 1 (meta-insert "fpos_t" meta "fpos_t" brief ""))     
VanLaser commented 7 years ago

I have llvm 4.0.1 - I did try changing to 3.9 and rebuilding rtags, same thing ... The only way it works is when I change company completion prefix to 1, then I press f, wait for the completion popup to appear (fprintf included), then press p ... If instead I press fp very quickly, I only get the fpos_t completion candidate. This is pretty frustrating. I'll probably switch to company-clang backend. @myrgy - thanks for testing!

myrgy commented 7 years ago

@VanLaser , btw, have you try to call rtags-reparse-file? in some cases it looks like rtags doesn't sync emacs version with it's internal -- as a result autocompletion might be broken.

VanLaser commented 7 years ago

@myrgy I tried (after you told me about it), but - same thing. I don't think it's something to do with Emacs, since I get the same completion from command-line's rc tool:

$ rc -b -z --code-complete-at /home/laser/tests/test.c:4:2: --synchronous-completions --code-complete-prefix=fp                     
 fpos_t fpos_t TypedefDecl   
 _G_fpos_t _G_fpos_t TypedefDecl   
 _G_fpos64_t _G_fpos64_t TypedefDecl   
 _IO_fpos_t _IO_fpos_t macro definition   
 _IO_fpos64_t _IO_fpos64_t macro definition   

I can't quite believe I'm the only one that experiences that (since I'm using fairly standard clang/llvm in Arch Linux) ??

myrgy commented 7 years ago

here is my test.cpp https://github.com/myrgy/rtags_test Fedora 24

➜  test git:(master) ✗ ~/.emacs.d/elpa/rtags-20170825.1410/rtags-2.13/bin/rc -b -z --code-complete-at /home/adalshov/Documents/test/main.cpp:4:3: --synchronous-completions --code-complete-prefix=fp
 fputs int fputs(const char *__restrict __s, FILE *__restrict __stream) FunctionDecl   
 fpos64_t fpos64_t TypedefDecl   
 fputc_unlocked int fputc_unlocked(int __c, FILE *__stream) FunctionDecl   
 fpos_t fpos_t TypedefDecl   
 fputs_unlocked int fputs_unlocked(const char *__restrict __s, FILE *__restrict __stream) FunctionDecl   
 fprintf int fprintf(FILE *__restrict __stream, const char *__restrict __format, ...) FunctionDecl   
 fputc int fputc(int __c, FILE *__stream) FunctionDecl   
 _G_fpos_t _G_fpos_t TypedefDecl   
 _G_fpos64_t _G_fpos64_t TypedefDecl   
 _IO_fpos_t _IO_fpos_t macro definition   
 _IO_fpos64_t _IO_fpos64_t macro definition   
 _IO_FILE_plus _IO_FILE_plus StructDecl  
casch-at commented 6 years ago

Duplicate of #1123