summaryrefslogtreecommitdiffstats
path: root/lib/Lex
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2017-06-21 18:52:44 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2017-06-21 18:52:44 +0000
commitb5b472a91f6b26ce2aba5a81d13b36cdefbb3dc1 (patch)
tree899031317241568c02d95a1991fdd45333a1893a /lib/Lex
parentdba970f4d143480b964f77b363ec23f22cea0390 (diff)
[preprocessor] Fix assertion hit when 'SingleFileParseMode' option is enabled and #if with an undefined identifier and without #else
'HandleEndifDirective' asserts that 'WasSkipping' is false, so switch to using 'FoundNonSkip' as the hint for 'SingleFileParseMode' to keep going with parsing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305940 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r--lib/Lex/PPDirectives.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index 422bfc8968..8c79e50176 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -2658,7 +2658,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result, bool isIfndef,
// In 'single-file-parse mode' undefined identifiers trigger parsing of all
// the directive blocks.
CurPPLexer->pushConditionalLevel(DirectiveTok.getLocation(),
- /*wasskip*/true, /*foundnonskip*/false,
+ /*wasskip*/false, /*foundnonskip*/false,
/*foundelse*/false);
} else if (!MI == isIfndef) {
// Yes, remember that we are inside a conditional, then lex the next token.
@@ -2705,7 +2705,7 @@ void Preprocessor::HandleIfDirective(Token &IfToken,
if (PPOpts->SingleFileParseMode && DER.IncludedUndefinedIds) {
// In 'single-file-parse mode' undefined identifiers trigger parsing of all
// the directive blocks.
- CurPPLexer->pushConditionalLevel(IfToken.getLocation(), /*wasskip*/true,
+ CurPPLexer->pushConditionalLevel(IfToken.getLocation(), /*wasskip*/false,
/*foundnonskip*/false, /*foundelse*/false);
} else if (ConditionalTrue) {
// Yes, remember that we are inside a conditional, then lex the next token.
@@ -2768,11 +2768,11 @@ void Preprocessor::HandleElseDirective(Token &Result) {
if (Callbacks)
Callbacks->Else(Result.getLocation(), CI.IfLoc);
- if (PPOpts->SingleFileParseMode && CI.WasSkipping) {
+ if (PPOpts->SingleFileParseMode && !CI.FoundNonSkip) {
// In 'single-file-parse mode' undefined identifiers trigger parsing of all
// the directive blocks.
CurPPLexer->pushConditionalLevel(CI.IfLoc, /*wasskip*/false,
- /*foundnonskip*/true, /*foundelse*/true);
+ /*foundnonskip*/false, /*foundelse*/true);
return;
}
@@ -2811,10 +2811,10 @@ void Preprocessor::HandleElifDirective(Token &ElifToken) {
SourceRange(ConditionalBegin, ConditionalEnd),
PPCallbacks::CVK_NotEvaluated, CI.IfLoc);
- if (PPOpts->SingleFileParseMode && CI.WasSkipping) {
+ if (PPOpts->SingleFileParseMode && !CI.FoundNonSkip) {
// In 'single-file-parse mode' undefined identifiers trigger parsing of all
// the directive blocks.
- CurPPLexer->pushConditionalLevel(ElifToken.getLocation(), /*wasskip*/true,
+ CurPPLexer->pushConditionalLevel(ElifToken.getLocation(), /*wasskip*/false,
/*foundnonskip*/false, /*foundelse*/false);
return;
}