summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorJohn Thompson <John.Thompson.JTSoftware@gmail.com>2013-12-04 20:19:30 +0000
committerJohn Thompson <John.Thompson.JTSoftware@gmail.com>2013-12-04 20:19:30 +0000
commit17c357342a7397aca0710613b72139a7256836f8 (patch)
treefea6cc907669db6b36a59143f6d4068f6383d561 /clang
parent711ee8381e12e4a011ac9aabf151444080f710c3 (diff)
downloadbcm5719-llvm-17c357342a7397aca0710613b72139a7256836f8.tar.gz
bcm5719-llvm-17c357342a7397aca0710613b72139a7256836f8.zip
Enea Zaffanella's fix for the PPCallbacks Elif callback, with a slight re-org, and an update of the new PPCallbacks test (soon to be moved to clang from extra), rather the unittest.
llvm-svn: 196407
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Lex/PPDirectives.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 446eac36418..7d4c788f660 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -404,35 +404,33 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc,
} else if (Sub == "lif") { // "elif".
PPConditionalInfo &CondInfo = CurPPLexer->peekConditionalLevel();
- bool ShouldEnter;
- const SourceLocation ConditionalBegin = 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 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) {
DiscardUntilEndOfDirective();
- ShouldEnter = false;
} else {
+ const SourceLocation CondBegin = CurPPLexer->getSourceLocation();
// Restore the value of LexingRawMode so that identifiers are
// looked up, etc, inside the #elif expression.
assert(CurPPLexer->LexingRawMode && "We have to be skipping here!");
CurPPLexer->LexingRawMode = false;
IdentifierInfo *IfNDefMacro = 0;
- ShouldEnter = EvaluateDirectiveExpression(IfNDefMacro);
+ const bool CondValue = 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 this condition is true, enter it!
- if (ShouldEnter) {
- CondInfo.FoundNonSkip = true;
- if (Callbacks)
+ if (Callbacks) {
+ const SourceLocation CondEnd = CurPPLexer->getSourceLocation();
Callbacks->Elif(Tok.getLocation(),
- SourceRange(ConditionalBegin, ConditionalEnd),
- ShouldEnter, CondInfo.IfLoc);
- break;
+ SourceRange(CondBegin, CondEnd),
+ CondValue, CondInfo.IfLoc);
+ }
+ // If this condition is true, enter it!
+ if (CondValue) {
+ CondInfo.FoundNonSkip = true;
+ break;
+ }
}
}
}
OpenPOWER on IntegriCloud