[Preamble] Allow recursive inclusion of header-guarded mainfile.
authorSam McCall <sam.mccall@gmail.com>
Fri, 17 Apr 2020 14:07:21 +0000 (16:07 +0200)
committerSam McCall <sam.mccall@gmail.com>
Mon, 20 Apr 2020 15:28:42 +0000 (17:28 +0200)
commitee12edcb76423c78b55cdddae2edfe45cbb2ccd6
tree039c30bcc6054363ce8d191923104a66a7716842
parent9986b3de26d31be26d978194333c44e82873f3ff
[Preamble] Allow recursive inclusion of header-guarded mainfile.

Summary:
This is guaranteed to be a no-op without the preamble, so should be a
no-op with it too.

Partially fixes https://github.com/clangd/clangd/issues/337
This doesn't yet work for #ifndef guards, which are not recognized in preambles.
see D78038

I can't for the life of me work out how to test this outside clangd.
The original reentrant preamble diagnostic was untested, I added a test
to clangd for that too.

Reviewers: kadircet

Subscribers: ilya-biryukov, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78366
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
clang/lib/Lex/PPDirectives.cpp