diff options
author | David Blaikie <dblaikie@gmail.com> | 2013-03-18 23:22:28 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2013-03-18 23:22:28 +0000 |
commit | abc0bea57d4e659d5cde178a4bb426acc48f999e (patch) | |
tree | 8c8301a4b015fc9fd640b3688c30e1400600d69d /lib/Lex | |
parent | e4d6112a4eaf341afacd95c9585efc28ec2eac5a (diff) |
PR15539: Record "evaluating if/elif condition" flag in the right place
The previous implementation missed the case where the elif condition was
evaluated from the context of an #ifdef that was false causing PR15539.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177345 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 2 | ||||
-rw-r--r-- | lib/Lex/PPExpressions.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 8379ca8719..e19eb31335 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -2082,7 +2082,6 @@ void Preprocessor::HandleIfdefDirective(Token &Result, bool isIfndef, /// void Preprocessor::HandleIfDirective(Token &IfToken, bool ReadAnyTokensBeforeDirective) { - SaveAndRestore<bool> PPDir(ParsingIfOrElifDirective, true); ++NumIf; // Parse and evaluate the conditional expression. @@ -2174,7 +2173,6 @@ void Preprocessor::HandleElseDirective(Token &Result) { /// HandleElifDirective - Implements the \#elif directive. /// void Preprocessor::HandleElifDirective(Token &ElifToken) { - SaveAndRestore<bool> PPDir(ParsingIfOrElifDirective, true); ++NumElse; // #elif directive in a non-skipping conditional... start skipping. diff --git a/lib/Lex/PPExpressions.cpp b/lib/Lex/PPExpressions.cpp index 49f4cbf71a..27ad7b4a1b 100644 --- a/lib/Lex/PPExpressions.cpp +++ b/lib/Lex/PPExpressions.cpp @@ -24,6 +24,7 @@ #include "clang/Lex/MacroInfo.h" #include "llvm/ADT/APSInt.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/SaveAndRestore.h" using namespace clang; namespace { @@ -730,6 +731,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec, /// to "!defined(X)" return X in IfNDefMacro. bool Preprocessor:: EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) { + SaveAndRestore<bool> PPDir(ParsingIfOrElifDirective, true); // Save the current state of 'DisableMacroExpansion' and reset it to false. If // 'DisableMacroExpansion' is true, then we must be in a macro argument list // in which case a directive is undefined behavior. We want macros to be able |