Skip to content

goto-cc: newlines in command files are just whitespace #6595

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

Merged
merged 1 commit into from
Jan 19, 2022

Conversation

tautschnig
Copy link
Collaborator

GCC's doc says that options are separated by whitespace, with no
particular significance of newlines. Therefore, process the entire file
at once rather than line-by-line.

Fixes: #6592

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

GCC's doc says that options are separated by whitespace, with no
particular significance of newlines. Therefore, process the entire file
at once rather than line-by-line.

Fixes: diffblue#6592
Copy link
Contributor

@chrisr-diffblue chrisr-diffblue left a comment

Choose a reason for hiding this comment

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

Approving because this is an improvement on the existing behaviour, and fixes a known bug. I've left a comment for consideration, but that may just be something to raise as a new bug, rather than to be fixed in this PR.

{
// erase leading whitespace
line.erase(0, line.find_first_not_of("\t "));
all_lines << ' ' << line;
Copy link
Contributor

@chrisr-diffblue chrisr-diffblue Jan 19, 2022

Choose a reason for hiding this comment

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

So this will effectively be replacing newlines with single spaces... it may be an edge case that we really don't care about too much, but just to check have you considered how this may/may not play with the quoting and escaping rules for @files ? It looks to me like theoretically a "backslash, newline" sequence is valid and should be preserved as a newline, for instance.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good call-out, but I'm not entirely sure how where I might be able to put such a newline. The following won't work with GCC:

-o
file.gb
-Dhello="  \
"
test.c

With the above, hello just expands to an empty token. I also tried

-o
file.gb
'-Dhello="  \
"'
test.c

but then I even get a warning:

<command-line>:0:7: warning: missing terminating " character

Any ideas what else I might try?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thats good enough for me to think that "theoretically" doesn't map to "actually supported by gcc in reality" :-)

@tautschnig tautschnig self-assigned this Jan 19, 2022
@codecov
Copy link

codecov bot commented Jan 19, 2022

Codecov Report

Merging #6595 (d9463a1) into develop (6776f0c) will increase coverage by 0.26%.
The diff coverage is 93.75%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #6595      +/-   ##
===========================================
+ Coverage    76.21%   76.48%   +0.26%     
===========================================
  Files         1578     1578              
  Lines       181393   181385       -8     
===========================================
+ Hits        138253   138736     +483     
+ Misses       43140    42649     -491     
Impacted Files Coverage Δ
unit/util/irep.cpp 99.48% <80.00%> (-0.52%) ⬇️
src/ansi-c/c_typecast.cpp 80.43% <100.00%> (-0.06%) ⬇️
src/ansi-c/c_typecheck_expr.cpp 75.02% <100.00%> (-0.02%) ⬇️
src/cpp/parse.cpp 68.56% <100.00%> (ø)
src/goto-cc/gcc_cmdline.cpp 75.38% <100.00%> (+0.58%) ⬆️
unit/interpreter/interpreter.cpp 100.00% <100.00%> (ø)
...olvers/flattening/c_bit_field_replacement_type.cpp 46.66% <0.00%> (-6.67%) ⬇️
src/goto-programs/xml_expr.cpp 53.98% <0.00%> (-0.29%) ⬇️
src/goto-programs/json_expr.cpp 62.20% <0.00%> (-0.07%) ⬇️
src/ansi-c/padding.cpp 93.46% <0.00%> (-0.03%) ⬇️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed7a0d3...d9463a1. Read the comment docs.

@tautschnig tautschnig merged commit cedd5ea into diffblue:develop Jan 19, 2022
@tautschnig tautschnig deleted the bugfixes/6592-param-files branch January 19, 2022 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

goto-cc with command line option file
2 participants