Skip to content
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

Fix cflags parsing (#2510, #2265) #2590

Merged
merged 8 commits into from
Aug 17, 2019
Merged

Fix cflags parsing (#2510, #2265) #2590

merged 8 commits into from
Aug 17, 2019

Conversation

fx-carton
Copy link
Contributor

This PR fixes the cflags parsing problem I had in #2510: some filenames were passed as arguments. I believe it should fix #2265 as well.

  1. The splitting is now done in ale#c#ShellSplit, which is intended to split the command line closely to how a shell would do.
  2. Flags are selected following a whitelist of arguments. I went through GCC's man page to select which flags made sense to be parsed. I believe the others either don't need to be passed for syntax checking or cannot be passed (because of output files or non-wanted behaviour).
  3. Added two tests for flags we want or don't want to be passed.

Ping for testing: @0mco @davidvandebunte @ranebrown

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
test/test_c_flag_parsing.vader Outdated Show resolved Hide resolved
test/test_c_flag_parsing.vader Outdated Show resolved Hide resolved
@fx-carton
Copy link
Contributor Author

My bad. It was caused by the revert.

Copy link
Member

@w0rp w0rp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be fine. I'll ask people to test this to see if it fixes their issues.

@w0rp
Copy link
Member

w0rp commented Jun 19, 2019

@0mco @davidvandebunte @ranebrown What do you think?

@ranebrown
Copy link

That fixes #2265 for me. Thanks!

@0mco
Copy link
Contributor

0mco commented Jul 7, 2019

It works for me. But since this just considered GCC's options, I still personally prefer the blacklist approach.

@fx-carton
Copy link
Contributor Author

I prefer the whitelist option, because there are a lot of options that should be removed. And gcc/clang may add more unwanted options in future versions, so we would have to be more careful about that.

However, we could add an option for additional whitelisted flags, which would enable easy configuring for other compilers and/or newer versions without changing the source code.

@w0rp
Copy link
Member

w0rp commented Aug 17, 2019

Okay, I'll merge this now. Thanks for this!

@w0rp w0rp merged commit b62e306 into dense-analysis:master Aug 17, 2019
@w0rp w0rp mentioned this pull request Aug 17, 2019
suoto pushed a commit to suoto/ale that referenced this pull request Sep 11, 2019
…analysis#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
timlag1305 pushed a commit to timlag1305/ale that referenced this pull request Nov 5, 2019
…analysis#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

C/C++ compiler flag -MMD creates -.d file
4 participants