summaryrefslogtreecommitdiffstats
path: root/lib/Lex
diff options
context:
space:
mode:
authorVolodymyr Sapsai <vsapsai@apple.com>2018-07-25 19:16:26 +0000
committerVolodymyr Sapsai <vsapsai@apple.com>2018-07-25 19:16:26 +0000
commitcb27abbb2b60f0f3c40844e81f1d1a378a05e360 (patch)
treedf5aab4c586eecf44869e25189195481cb92df83 /lib/Lex
parentb4e6971ad794232deb402af54d49e215f5bab364 (diff)
[Preprocessor] Stop entering included files after hitting a fatal error.
Fixes a problem when we have multiple inclusion cycles and try to enumerate all possible ways to reach the max inclusion depth. rdar://problem/38871876 Reviewers: bruno, rsmith, jkorous, aaron.ballman Reviewed By: bruno, jkorous, aaron.ballman Subscribers: dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D48786 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337953 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r--lib/Lex/PPDirectives.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index 4ea0f485d3..d8dae73037 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -1896,6 +1896,12 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
if (PPOpts->SingleFileParseMode)
ShouldEnter = false;
+ // Any diagnostics after the fatal error will not be visible. As the
+ // compilation failed already and errors in subsequently included files won't
+ // be visible, avoid preprocessing those files.
+ if (ShouldEnter && Diags->hasFatalErrorOccurred())
+ ShouldEnter = false;
+
// Determine whether we should try to import the module for this #include, if
// there is one. Don't do so if precompiled module support is disabled or we
// are processing this module textually (because we're building the module).