[Preamble] Stop circular inclusion of main file when building preamble
authorNikolai Kosjar <nikolai.kosjar@qt.io>
Fri, 10 May 2019 10:25:35 +0000 (10:25 +0000)
committerNikolai Kosjar <nikolai.kosjar@qt.io>
Fri, 10 May 2019 10:25:35 +0000 (10:25 +0000)
commit3c28a2dc6bdc331e5a0d8097a5fa59d06682b9d0
tree8a3a3ca4f74d123c53d7ec4d27aa926ef22fd5bd
parenta2ab528c4ca8d03846ebf6ce42efd6424a6556f1
[Preamble] Stop circular inclusion of main file when building preamble

If a header file was processed for the second time, we could end up with a
wrong conditional stack and skipped ranges:

In the particular example, if the header guard is evaluated the second time and
it is decided to skip the conditional block, the corresponding "#endif" is
never seen since the preamble does not include it and we end up in the
Tok.is(tok::eof) case with a wrong conditional stack.

Detect the circular inclusion, emit a diagnostic and stop processing the
inclusion.

llvm-svn: 360418
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/lib/Basic/SourceManager.cpp
clang/lib/Lex/PPDirectives.cpp