diff options
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 00cdbd774e..5f4c321715 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -298,7 +298,10 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, DiscardUntilEndOfDirective(); CurPPLexer->pushConditionalLevel(Tok.getLocation(), /*wasskipping*/true, /*foundnonskip*/false, - /*fnddelse*/false); + /*foundelse*/false); + + if (Callbacks) + Callbacks->Endif(); } } else if (Directive[0] == 'e') { llvm::StringRef Sub = Directive.substr(1); @@ -326,6 +329,9 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, // Note that we've seen a #else in this conditional. CondInfo.FoundElse = true; + if (Callbacks) + Callbacks->Else(); + // If the conditional is at the top level, and the #if block wasn't // entered, enter the #else block now. if (!CondInfo.WasSkipping && !CondInfo.FoundNonSkip) { @@ -336,6 +342,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, PPConditionalInfo &CondInfo = CurPPLexer->peekConditionalLevel(); bool ShouldEnter; + const SourceLocation ConditionalBegin = CurPPLexer->getSourceLocation(); // If this is in a skipping block or if we're already handled this #if // block, don't bother parsing the condition. if (CondInfo.WasSkipping || CondInfo.FoundNonSkip) { @@ -350,10 +357,14 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, ShouldEnter = EvaluateDirectiveExpression(IfNDefMacro); CurPPLexer->LexingRawMode = true; } + const SourceLocation ConditionalEnd = CurPPLexer->getSourceLocation(); // If this is a #elif with a #else before it, report the error. if (CondInfo.FoundElse) Diag(Tok, diag::pp_err_elif_after_else); + if (Callbacks) + Callbacks->Elif(SourceRange(ConditionalBegin, ConditionalEnd)); + // If this condition is true, enter it! if (ShouldEnter) { CondInfo.FoundNonSkip = true; |