Michael Kruse 1606022fab [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
2021-11-05 00:43:40 -05:00

16 lines
648 B
C

// RUN: %clang_cc1 -E -o - %s | FileCheck %s
// RUN: %clang_cc1 -E -P -o - %s | FileCheck %s
// RUN: %clang_cc1 -E -fminimize-whitespace -o - %s | FileCheck %s
// RUN: %clang_cc1 -E -fminimize-whitespace -P -o - %s | FileCheck %s
// The PragmaAssumeNonNullHandler (and maybe others) passes an invalid
// SourceLocation when inside a _Pragma. Ensure we still emit semantic
// newlines.
// See report at https://reviews.llvm.org/D104601#3105044
_Pragma("clang assume_nonnull begin") test _Pragma("clang assume_nonnull end")
// CHECK: {{^}}#pragma clang assume_nonnull begin{{$}}
// CHECK: test
// CHECK: {{^}}#pragma clang assume_nonnull end{{$}}