-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend .ccls #171
Extend .ccls #171
Conversation
Wow thanks for the quick response! I'm testing now but something is not quite right. At first I was getting an error in Messages (maybe while ccls was rebuilding the index?) but now I get no errors but the header doesn't appear to be included. I do see the |
I enabled lsp-print-io but it didn't seem to help me understand what's happening. Basically, I can see from the log that the
but ccls still can't find these types. I've created a test environment and attached it as a tar file here. Unpack it in
If I do the equivalent thing from the command line it works:
even if I comment out the |
OK more details: it appears to be related to the combination of compile_commands.json and .ccls. If I remove compile_commands.json and change my
then it works! If I put back compile_commands.json, even with the above .ccls, it doesn't work again. BTW, I think a more formal definition of the syntax of
then it doesn't work... is that intended? Using |
05f95d1
to
54e6f63
Compare
I pushed a commit to make
It should make it easy to observe what is going on. I have fixed Note With a change to
|
Awesome, I'll give it a try. I was confused about the precise syntax of the
which implies that flags on a line by themselves are valid...? Maybe I misunderstood it. |
9143ab3
to
de26ec9
Compare
dbcfcd1
to
c068f7b
Compare
With your comment #115 (comment) in mind, I've changed the semantic a bit. For you
See the updated description of the commit. The relevant log when
The source is still the best way to understand what's going on :) StringRef A(arg);
if (A == "%clang") {
args.push_back(lang == LanguageId::Cpp || lang == LanguageId::ObjCpp
? "clang++"
: "clang");
} else if (A[0] == '%') {
bool ok = false;
for (;;) {
if (A.consume_front("%c "))
ok |= lang == LanguageId::C;
else if (A.consume_front("%h "))
ok |= lang == LanguageId::C && header;
else if (A.consume_front("%cpp "))
ok |= lang == LanguageId::Cpp;
else if (A.consume_front("%hpp "))
ok |= lang == LanguageId::Cpp && header;
else if (A.consume_front("%objective-c "))
ok |= lang == LanguageId::ObjC;
else if (A.consume_front("%objective-cpp "))
ok |= lang == LanguageId::ObjCpp;
else
break;
}
if (ok)
args.push_back(A.data());
} else if (!excludeArgs.count(A)) {
args.push_back(arg);
} |
This didn't fix inclusion of headers at |
Can you give an example how |
Nevermind, I've noticed from discussion it's for files. |
@MaskRay OK tested in my real code... it works great!! Now all my headers have full type information. Love it! @oblitum Right, for files. It's for extra flags to be given to the compiler when ccls "compiles" header files alone, rather than as part of a source file. I don't expect it will be the most commonly-used option but it's critical in some situations. |
aa7eaf8
to
852cdef
Compare
f7a7e43
to
7e696fa
Compare
@oblitum For clang < 8, |
* Add %h for C header files (the suffix .h is considered a C header, not a C++ header) * Add %hpp for C++ header files * If .ccls exists, it provides full command line for files not specified by compile_commands.json (before, compile_commands.json was ignored) * If the first line of .ccls is %compile_commands.json, it appends flags to compile_commands.json "arguments", instead of overriding. Files not specified by compile_commands.json will not be added to folder.entries, but their command line can be inferred from other files. Also fix `#include <` completion of -I flags for clang < 8
Fix #115 @madscientist
%h
for C header files (the suffix.h
is considered a C header, not a C++ header)%hpp
for C++ header files.ccls
exists, it provides full command line for files not specified bycompile_commands.json
(before,compile_commands.json
was ignored)%compile_commands.json
, it appends flags tocompile_commands.json
"arguments", instead of overriding.Files not specified by
compile_commands.json
will not be added to folder.entries, but their command line can be inferred from other files.