diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2019-05-10 10:25:35 +0000 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2019-05-10 10:25:35 +0000 |
commit | 3c28a2dc6bdc331e5a0d8097a5fa59d06682b9d0 (patch) | |
tree | 8a3a3ca4f74d123c53d7ec4d27aa926ef22fd5bd /clang/lib/Basic/SourceManager.cpp | |
parent | a2ab528c4ca8d03846ebf6ce42efd6424a6556f1 (diff) | |
download | bcm5719-llvm-3c28a2dc6bdc331e5a0d8097a5fa59d06682b9d0.tar.gz bcm5719-llvm-3c28a2dc6bdc331e5a0d8097a5fa59d06682b9d0.zip |
[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
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 0ffad1bc475..712cbb0d0ea 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -1582,7 +1582,7 @@ FileID SourceManager::translateFile(const FileEntry *SourceFile) const { if (MainSLoc.isFile()) { const ContentCache *MainContentCache = MainSLoc.getFile().getContentCache(); - if (!MainContentCache) { + if (!MainContentCache || !MainContentCache->OrigEntry) { // Can't do anything } else if (MainContentCache->OrigEntry == SourceFile) { FirstFID = MainFileID; |