[Preprocessor] Fix newline before/after _Pragma.
authorMichael Kruse <llvm-project@meinersbur.de>
Fri, 5 Nov 2021 05:03:26 +0000 (00:03 -0500)
committerMichael Kruse <llvm-project@meinersbur.de>
Fri, 5 Nov 2021 05:43:40 +0000 (00:43 -0500)
commit1606022fab2d90ed8ee6d15800ec1c2c293db20e
tree2a14e5c7176d5cb570d597efa9218e4b24c6e6cb
parent8f099d17a1bee857ada3c5af032cfcb559252024
[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
clang/lib/Frontend/PrintPreprocessedOutput.cpp
clang/test/Preprocessor/_Pragma-newline.c [new file with mode: 0644]