summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPDirectives.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2013-01-16 19:32:21 +0000
committerAaron Ballman <aaron@aaronballman.com>2013-01-16 19:32:21 +0000
commit6ce0000dd52815db5ad3e7ff67fd14df244a2d81 (patch)
treea4c5533bc291655897c0519843ca6ae0d909056a /clang/lib/Lex/PPDirectives.cpp
parent0fab22544f065c4be06e3f3eda495a76dce17ae7 (diff)
downloadbcm5719-llvm-6ce0000dd52815db5ad3e7ff67fd14df244a2d81.tar.gz
bcm5719-llvm-6ce0000dd52815db5ad3e7ff67fd14df244a2d81.zip
No longer crashing with an assert when __has_include or __has_include_next is used outside of a preprocessor directive. This fixes PR14837.
llvm-svn: 172639
Diffstat (limited to 'clang/lib/Lex/PPDirectives.cpp')
-rw-r--r--clang/lib/Lex/PPDirectives.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index bdca03637db..7e46a9cc28e 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -24,6 +24,7 @@
#include "clang/Lex/Pragma.h"
#include "llvm/ADT/APInt.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/SaveAndRestore.h"
using namespace clang;
//===----------------------------------------------------------------------===//
@@ -2071,6 +2072,7 @@ 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.
@@ -2162,6 +2164,7 @@ 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.
OpenPOWER on IntegriCloud