Commit Graph

57 Commits

Author SHA1 Message Date
Michael Jeanson 9efa96eb94
fix: cflags parser: no absolute path for '-include' (#3775)
Both '-include' and '-imacros' take a file as an argument that will then
be searched in the include path like a regular '#include "..."'
statement in a source file. As such, they should not have their path
converted to an absolute path.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
2021-07-04 21:27:55 +09:00
w0rp 9fe7b1fe6a
Close #2281 - Separate cwd commands from commands
Working directories are now set seperately from the commands so they
can later be swapped out when running linters over projects is
supported, and also better support filename mapping for running linters
on other machines in future.
2021-03-01 20:11:10 +00:00
Hugo Gualandi 77c034884b
Bugfix: ParseCFlagsFromMakeOutput was never being called (#3574)
Previously, the make output was never being parsed, even when the
`c_parse_makefile` option was set.
2021-02-06 19:06:01 +00:00
Hugo Musso Gualandi 4c7e843fd0 Have c_parse_makefile look for GNUmakefile as well
Makefiles using GNU-make features might be called "GNUmakefile" instead
of "Makefile". This commit teaches the `c_parse_makefile` feature to
look for a GNUmakefile file if a Makefile is not present.
2021-02-03 19:15:03 -03:00
Manoel Brunnen 96d8415946 Add -imacros to C flags 2020-11-03 23:10:15 +01:00
w0rp 7e0cdb53ec
Fix #3247 - Use --always-make for make -n by default 2020-08-29 16:05:49 +01:00
w0rp 7d4ce4e6aa
Close #3325 - Apply new formatting where possible 2020-08-28 19:50:36 +01:00
w0rp 7545b18ba1
Fix #3318 - Escape macros when parsing C flags 2020-08-27 21:17:24 +01:00
w0rp 6d843715f3
Fix C flag parsing and tests on Windows 2020-08-27 20:18:13 +01:00
w0rp af177d7825
#3318 Refactor C flag parsing to set up for quoting arguments 2020-08-27 19:33:43 +01:00
w0rp 17605777d6
Fix #3317 - Parse -include from C flags 2020-08-27 13:05:50 +01:00
w0rp f5aa0e8457
Fix #3307 - Handle compile_commands paths better
ALE now converts paths from compile_commands.json files into absolute
paths and prefers matching against absolute file and directory names for
determining which flags to use for files. As a result, parsing
compile_commands.json to determine flags should work for a lot more C
and C++ projects.
2020-08-27 11:44:35 +01:00
awang 4d42ebc160
Keep -iframework if present in parsed C/C++ flags (#3057)
* Keep -iframework if present in parsed C/C++ flags
* Add test to make sure -iframework is parsed

Co-authored-by: Alex Wang <ts826848@gmail.com>
2020-08-20 00:09:02 +01:00
w0rp 90abb7e7ef
Try to fix Windows tests again 2020-08-19 01:22:43 +01:00
w0rp de7b0567b1
Try to fix tests on Windows 2020-08-19 01:10:33 +01:00
w0rp 361027eac6
Fix #3200 - Do not use -fstack-usage from parsed flags 2020-08-19 01:04:08 +01:00
w0rp e27d4377b5
Merge pull request #3178 from sudobash1/expand_at
Fixes #3092 - Implement loading `@file` c arguments
2020-08-19 00:15:34 +01:00
w0rp 2237f9b462
#2919 Use compile_commands.json for headers 2020-08-10 02:14:23 +01:00
w0rp 9e1f511003
#3276 - Disable make -n by default again 2020-08-09 20:08:42 +01:00
w0rp affeed7a87
Enable C flag parsing by default
The options for parsing `make -n` and `compile_commands.json` flags
are now enabled by default, so people can start getting better flags
for their files by default.

`compile_commands.json` flags are now preferred over `make -n` results,
to make the options work better by default.
2020-08-09 04:23:32 +01:00
Stephen Robinson b209315714 Fixes #3092 - Implement loading `@file` c arguments 2020-05-20 18:15:52 -07:00
Mo Zhonghua b8949aaac3 `arguments` needs to be handled for `compile_commands.json` in addition to `command` (#2123)
* c linter: compatible with compile_commands.json without command field
2019-09-19 20:20:37 +01:00
fx-carton b62e306222 Fix cflags parsing (#2510, #2265) (#2590)
* Parse CFLAGS that can be passed using a whitelist

I went through GCC's man page and selected flags that can safely be
passed to GCC and that can be useful to syntax checking. These include:

- -I/-i* include flags
- preprocessor flags such as -D
- -W* warning flags
- -O* optimization flags
- most -f options
- -m arch dependent options

* Fix CFLAGS tests: -Idir is now parsed to -I dir
* Added two tests for flags we want or don't want to pass.
* Also check for / in addition to s:sep
2019-08-17 19:08:14 +01:00
w0rp 143af2b9fd
Fix #2421 - Use compile_commands.json in build dirs to find roots 2019-05-20 19:57:08 +01:00
w0rp 5e64acc6ab
Fix #2512 - Use -o /dev/null for gcc linting 2019-05-20 13:00:32 +01:00
w0rp 23a8208498
#782 - Use compile commands for matching source files for headers 2019-04-15 21:38:11 +01:00
w0rp 3bebcb5d48
#2132 - Replace command_chain and chain_with with ale#command#Run 2019-04-07 14:58:06 +01:00
w0rp 3ba7d02708
Merge pull request #2272 from Rahlir/fix-c-compilecommand
Fix error when parsing compile_commands for c languages
2019-02-08 20:06:12 +00:00
w0rp 3e11cbd18d
Update syntax checking
* Line continuation characters should be on the same lines.
* .vim file line indentation should be a multiple of 4.
2019-02-06 18:05:13 +00:00
Tadeas Uhlir 37daedafed Fix error when parsing compile_commands for c langs
This little error caused that when parsing compile_commands json, the
filename was used to fetch entries in directory dictionary, hence, when
adding new json commands, it never found anything in dir_lookup and
instead rewrote the previous entry. Hence, the dir_lookup always
contained list of only one compile_command per directory instead of all
compile_commands for given directory.
2019-02-04 16:50:46 -05:00
w0rp 20b9dfdb4a
Fix #2195 - Handle the command key being missing 2019-01-27 09:12:59 +00:00
Louis Xu 8037f472ef Parse more C/C++ compiler options 2019-01-24 09:44:52 +08:00
w0rp d8a53cc7a5
Merge pull request #2191 from davidvandebunte/fixCompDbDir
bugfix: c.vim: Pull build directory from compilation database
2019-01-10 18:59:13 +00:00
François-Xavier Carton 4bbb10b46a Cflags parser: fix special chars matching algorithm 2019-01-09 16:53:36 +01:00
David VandeBunte 4f72023e16 bugfix: c.vim: Pull build directory from compilation database
The LLVM compiler database JSON already includes a directory where the
build was performed:
https://clang.llvm.org/docs/JSONCompilationDatabase.html

Prefer this directory for fixing relative paths in compiler include
arguments in ale#c#ParseCFlags.

Without this change, users cannot create a symlink to their compilation
database as suggested in the LLVM tooling setup instructions:
https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
2019-01-08 19:09:02 -06:00
Jacob Segal cb0a5c7a36 Improve perf for compile dbs in large projects
When using a compilation database (compile_commands.json) in very large
projects, significant delays would occur when changing files --
particularly those that happened to be far down the db. Rather than
iterating over the whole list every time, we now build up a lookup table
based on the tail of the filename (and tail of the directory for
widening searches) and iterate over the much smaller list of compile
commands for files with the given name.

Test metrics (from compile_database_perf/test.sh) show a 90% performance
improvement -- from 25 seconds to 2.5 seconds per run.
2019-01-06 00:41:57 -08:00
François-Xavier Carton f7c4c403eb Fix CFLAGS parsing
Split by space instead of dash.
This prevents incorrect parsing where space-separated arguments are
merged (in particular, .c or .o files were appended to -I or -D
arguments).

Handle shell escape: quotes and escaped quotes \" and shell
substitutions are recognised. This is done by verifying that no special
character (" ' ` ()) has not a matching character.

Fixes #2049
2018-12-29 12:16:22 +01:00
Jacob Segal 1b3fa9828c Fix bug where last c flag was ignored
There is currently a check that tries to prevent c-flags that contain
'-' in them from being unintentionally split and included in the list of
commands. For example, we wouldn't want "-fno-exceptions " to appear as
"-fno" and "-exceptions ". The way this check was done was by making sure
the last character of the split string was a space.

This meant that the very last option to appear in the compile command
was ignored (as it doesn't end with a space). This fix explicitly skips
the ends-with-space check on the last option in the command-line.

This isn't the best fix. Really we should be using the same
argument-processing rules as a shell would rather than just splitting on
'-'. That's a much larger and more complicated change though.
2018-11-17 04:04:39 -08:00
James Ye 87743faf2a c#ParseCFlags: don't index empty list 2018-09-16 22:57:43 +10:00
w0rp d476578a40
Improve ALE project style checking
* The project style linter now runs while you type.
* Now the scripts for checking the project require blank lines.
* Many style issues have been found and fixed.
2018-09-04 16:51:18 +01:00
fenuks 9d7c48038c
Add clazy as cpp linter 2018-08-24 10:52:33 +01:00
w0rp 217284360d
Simplify the code for most linters and tests with closures 2018-08-02 23:44:12 +01:00
w0rp 94270402cb
Fall back on flags for other C/C++ files in the same directory 2018-08-02 21:48:56 +01:00
w0rp ac4bac8ea4
Add support for parsing compile_commands.json files for C compilers 2018-07-29 19:24:27 +01:00
w0rp 2a861dfd40
Make the test C import path test fail less 2018-07-23 22:03:28 +01:00
roel0 dfb3e194d7 Extended unit tests + simplified parsing algoritme #1167 2018-03-27 10:18:24 +02:00
roel0 69237a7e57 Added additional unit tests + adapted review comments #1167 2018-03-21 20:44:35 +01:00
roel0 7593e20377 Fix failing unit tests for windows 2018-03-21 07:37:32 +01:00
roel0 18d0aeb1a0 * Shell commands should by called async with the help of a command chain
* The makefile parser unit test should only test the cflag parser itself
#1167
2018-03-20 21:49:31 +01:00
roel0 3fb7efa2c6 Added some unit tests and fixed some linting errors for automatic makefile parsing in C #1167 2018-03-20 11:56:46 +01:00