summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-03-18 23:22:28 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-03-18 23:22:28 +0000
commit1dc4a3dfd6f99f28d73a3d7ebd6285fe6dd7187f (patch)
tree4b475aa58cd4555c8f7b367fe5e28b1d82ad0edc /clang/lib
parent008322f2b071412798ec74c79d1987a7cc317225 (diff)
downloadbcm5719-llvm-1dc4a3dfd6f99f28d73a3d7ebd6285fe6dd7187f.tar.gz
bcm5719-llvm-1dc4a3dfd6f99f28d73a3d7ebd6285fe6dd7187f.zip
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. llvm-svn: 177345
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Lex/PPDirectives.cpp2
-rw-r--r--clang/lib/Lex/PPExpressions.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 8379ca8719c..e19eb31335a 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/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/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index 49f4cbf71a2..27ad7b4a1ba 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/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
OpenPOWER on IntegriCloud