[all-commits] [llvm/llvm-project] 8f099d: [Preprocessor] Fix warning: left and right subexpr...

Michael Kruse via All-commits all-commits at lists.llvm.org
Thu Nov 4 22:45:47 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8f099d17a1bee857ada3c5af032cfcb559252024
      https://github.com/llvm/llvm-project/commit/8f099d17a1bee857ada3c5af032cfcb559252024
  Author: Michael Kruse <llvm-project at meinersbur.de>
  Date:   2021-11-05 (Fri, 05 Nov 2021)

  Changed paths:
    M clang/lib/Frontend/PrintPreprocessedOutput.cpp

  Log Message:
  -----------
  [Preprocessor] Fix warning: left and right subexpressions are identical. NFCI.

This is reported by msvc as
warning C6287: redundant code: the left and right subexpressions are identical

EmittedDirectiveOnThisLine implies EmittedTokensOnThisLine
making this an NFC change. To be on the safe side and because both of
them are checked at other places as well, we continue to check both.

Compiler warning reported here:
https://reviews.llvm.org/D104601#2957333


  Commit: 1606022fab2d90ed8ee6d15800ec1c2c293db20e
      https://github.com/llvm/llvm-project/commit/1606022fab2d90ed8ee6d15800ec1c2c293db20e
  Author: Michael Kruse <llvm-project at meinersbur.de>
  Date:   2021-11-05 (Fri, 05 Nov 2021)

  Changed paths:
    M clang/lib/Frontend/PrintPreprocessedOutput.cpp
    A clang/test/Preprocessor/_Pragma-newline.c

  Log Message:
  -----------
  [Preprocessor] Fix newline before/after _Pragma.

The PragmaAssumeNonNullHandler (and maybe others) passes an invalid
SourceLocation to its callback, hence PrintPreprocessedOutput does not
know how many lines to insert between the previous token and the
pragma and does nothing.

With this patch we instead assume that the unknown token is on the same
line as the previous such that we can call the procedure that also emits
semantically significant whitespace.

Fixes bug reported here: https://reviews.llvm.org/D104601#3105044


Compare: https://github.com/llvm/llvm-project/compare/96950270669a...1606022fab2d


More information about the All-commits mailing list