[all-commits] [llvm/llvm-project] c6b0b1: [Preprocessor] -E -P: Ensure newline after 8 skipp...
Michael Kruse via All-commits
all-commits at lists.llvm.org
Wed Jul 28 20:51:56 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: c6b0b16c0f55c34f4eaa05184815bbbe97f4b750
https://github.com/llvm/llvm-project/commit/c6b0b16c0f55c34f4eaa05184815bbbe97f4b750
Author: Michael Kruse <llvm-project at meinersbur.de>
Date: 2021-07-28 (Wed, 28 Jul 2021)
Changed paths:
M clang/lib/Frontend/PrintPreprocessedOutput.cpp
R clang/test/Preprocessor/line-directive-output-mincol.c
M clang/test/Preprocessor/minimize-whitespace.c
A clang/test/Preprocessor/skip-empty-lines.c
Log Message:
-----------
[Preprocessor] -E -P: Ensure newline after 8 skipped lines.
The implementation of -fminimize-whitespace (D104601) revised the logic
when to emit newlines. There was no case to handle when more than
8 lines were skippped in -P (DisableLineMarkers) mode and instead fell
through the case intended for -fminimize-whitespace, i.e. emit nothing.
This patch will emit one newline in this case.
The newline logic is slightly reorganized. The `-P -fminimize-whitespace`
case is handled explicitly and emitting at least one newline is the new
fallback case. The choice between emitting a line marker or up to
7 empty lines is now a choice only with enabled line markers. The up to
8 newlines likely are fewer characters than a line directive, but
in -P mode this had the paradoxic effect that it would print up to
7 empty lines, but none at all if more than 8 lines had to be skipped.
Now with DisableLineMarkers, we don't consider printing empty lines
(just start a new line) which matches gcc's behavior.
The line-directive-output-mincol.c test is replaced with a more
comprehensive test skip-empty-lines.c also testing the more than
8 skipped lines behaviour with all flag combinations.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D106924
More information about the All-commits
mailing list