aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Lex/PreprocessorLexer.h
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-11-13 01:03:15 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-11-13 01:03:15 +0000
commit4d10b40ea8ee489c7b9194aa2b025df4ecd2ab01 (patch)
tree7adfd8cc2aa293a71835909050723cd420c73933 /include/clang/Lex/PreprocessorLexer.h
parent3185d4ac30378995ef70421e2848f77524c2b5d5 (diff)
[preprocessor] When #including something that contributes no tokens at all,
don't recursively continue lexing. This avoids a stack overflow with a sequence of many empty #includes. rdar://11988695 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167801 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex/PreprocessorLexer.h')
-rw-r--r--include/clang/Lex/PreprocessorLexer.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/include/clang/Lex/PreprocessorLexer.h b/include/clang/Lex/PreprocessorLexer.h
index 20fb8a0c48..b85729dd08 100644
--- a/include/clang/Lex/PreprocessorLexer.h
+++ b/include/clang/Lex/PreprocessorLexer.h
@@ -61,6 +61,10 @@ protected:
/// Note that in raw mode that the PP pointer may be null.
bool LexingRawMode;
+ /// \brief When true, if EOF of the current lexer is found, tok::included_eof
+ /// is returned instead of continuing lexing higher in the include stack.
+ bool EnableIncludedEOF;
+
/// \brief A state machine that detects the \#ifndef-wrapping a file
/// idiom for the multiple-include optimization.
MultipleIncludeOpt MIOpt;
@@ -79,7 +83,8 @@ protected:
: PP(0), InitialNumSLocEntries(0),
ParsingPreprocessorDirective(false),
ParsingFilename(false),
- LexingRawMode(false) {}
+ LexingRawMode(false),
+ EnableIncludedEOF(false) {}
virtual ~PreprocessorLexer() {}
@@ -147,6 +152,11 @@ public:
/// \brief Return true if this lexer is in raw mode or not.
bool isLexingRawMode() const { return LexingRawMode; }
+ /// \brief When true, if EOF of the current lexer is found, tok::included_eof
+ /// is returned instead of continuing lexing higher in the include stack.
+ /// False is the default behavior.
+ void setEnableIncludedEOF(bool Enable) { EnableIncludedEOF = Enable; }
+
/// \brief Return the preprocessor object for this lexer.
Preprocessor *getPP() const { return PP; }