Serialize PragmaAssumeNonNullLoc to support preambles
authorDavid Goldman <davg@google.com>
Mon, 21 Mar 2022 17:45:21 +0000 (13:45 -0400)
committerDavid Goldman <davg@google.com>
Thu, 31 Mar 2022 15:08:01 +0000 (11:08 -0400)
commitd9739f29cdd4c066763275d09e1d26ee315cfdf5
tree737164056639067b899dcdc3c19a6d784d061202
parent1711020c3769d38e146c2c116376a2255630613a
Serialize PragmaAssumeNonNullLoc to support preambles

Previously, if a `#pragma clang assume_nonnull begin` was at the
end of a premable with a `#pragma clang assume_nonnull end` at the
end of the main file, clang would diagnose an unterminated begin in
the preamble and an unbalanced end in the main file.

With this change, those errors no longer occur and the case above is
now properly handled. I've added a corresponding test to clangd,
which makes use of preambles, in order to verify this works as
expected.

Differential Revision: https://reviews.llvm.org/D122179
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Lex/PreprocessorOptions.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/Lex/PPLexerChange.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/Index/preamble-assume-nonnull.c [new file with mode: 0644]