Delete %clang and add an example about -march=armv7a

Fangrui Song 2019-01-10 00:00:29 +08:00
parent f951e6d451
commit aa86353e97

@ -152,12 +152,6 @@ By default `.ccls` specify compiler flags of files not listed in
`compile_commands.json` is parsed, the rest lines of `.ccls` will be appended `compile_commands.json` is parsed, the rest lines of `.ccls` will be appended
to the compiler flags. to the compiler flags.
### `%clang`
Resolves to either `clang` (C) or `clang++` (C++). This is useful if your
project has both C and C++ source files, because if unconditional `clang++` is
used instead, `clang++ a.c` parses `a.c` as C++.
### `%c` / `%cpp` / `%objective-c` / `%objective-cpp` ### `%c` / `%cpp` / `%objective-c` / `%objective-cpp`
This argument should be added only when parsing C (`%c`), C++ (`%cpp`), This argument should be added only when parsing C (`%c`), C++ (`%cpp`),
@ -168,12 +162,19 @@ Objective-C (`%objective-c`), or Objective-C++ (`%objective-c++`) files.
This argument should be added only when indexing C header files (`%h`: `*.h`) or C++ This argument should be added only when indexing C header files (`%h`: `*.h`) or C++
header files (`%hpp`: `*.hh` `*.hpp`). Note, `*.h` files are considered as C, not C++. header files (`%hpp`: `*.hh` `*.hpp`). Note, `*.h` files are considered as C, not C++.
### Compiler driver
The compiler driver (the first line unless `%compile_commands.json` is used) can usually just be `clang`.
`clang++` is usually unnecessary, and incorrect if some files are C.
Note that `clang a.cc` and `clang++ a.cc` are different, but the difference is only related to linking (what default runtime libraries are passed) and is not relevant for the frontend actions ccls performs.
## `.ccls` examples ## `.ccls` examples
#### Example A #### Example A
``` ```
%clang clang
%c -std=c11 %c -std=c11
%cpp -std=c++2a %cpp -std=c++2a
%h %hpp --include=Global.h %h %hpp --include=Global.h
@ -194,7 +195,19 @@ header files (`%hpp`: `*.hh` `*.hpp`). Note, `*.h` files are considered as C, no
-Iinc -Iinc
``` ```
It appends flags so `%clang` should not be used. It appends flags so `clang` should not be used.
#### Example: `-march=armv7a`
See <https://github.com/MaskRay/ccls/issues/107>.
If the compiler driver is a GCC cross-compiler, `--target=` may be required. Suppose `arm-linux-gnueabi-gcc -march=armv7a` is used, add a `--target=`:
```
%compile_commands.json
--target=armv7a-linux-gnueabi
```
Otherwise clang will `error: unknown target CPU 'armv7a'`.
## `compile_commands.json` examples ## `compile_commands.json` examples