[all-commits] [llvm/llvm-project] 66e37c: [Preprocessor] Elide empty line(s) at start of file.

Michael Kruse via All-commits all-commits at lists.llvm.org
Wed Aug 25 10:50:43 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 66e37c99ef5d7da1b17b3bbaa4ef05b633a473f7
      https://github.com/llvm/llvm-project/commit/66e37c99ef5d7da1b17b3bbaa4ef05b633a473f7
  Author: Michael Kruse <llvm-project at meinersbur.de>
  Date:   2021-08-25 (Wed, 25 Aug 2021)

  Changed paths:
    M clang/lib/Frontend/PrintPreprocessedOutput.cpp
    A clang/test/Preprocessor/print_empty_include.c
    A clang/test/Preprocessor/print_empty_include.h
    M clang/test/Preprocessor/print_line_track.c

  Log Message:
  -----------
  [Preprocessor] Elide empty line(s) at start of file.

In -P mode, PrintPPOutputPPCallbacks::MoveToLine started at least one
newline if current and target line number mismatched. The method is also
called when entering a new file, be it the main file or an include file.
In this situation line numbers always almost mismatch, resulting in a
newline for each occurance even if no tokens have been printed
in-between.

Empty lines at the beginning of the output must be trimmed because it
may be parsed by scripts expecting the result to appear on the first
output line, as done by LibreOffice's configure script.

Fix by only emitting a newline if tokens have been printed so far using
the EmittedTokensOnThisLine flag. Also adding a test case of FileChanged
callbacks occuring with empty include files.

This fixes llvm.org/PR51616


  Commit: 666906a8032709e59ca6c9fb7b7a5e05cafbd3bf
      https://github.com/llvm/llvm-project/commit/666906a8032709e59ca6c9fb7b7a5e05cafbd3bf
  Author: Michael Kruse <llvm-project at meinersbur.de>
  Date:   2021-08-25 (Wed, 25 Aug 2021)

  Changed paths:
    M clang/test/Preprocessor/skip-empty-lines.c

  Log Message:
  -----------
  [test] Fix indention. NFC.


Compare: https://github.com/llvm/llvm-project/compare/846e562dcc6a...666906a80327


More information about the All-commits mailing list