Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Revert r167801, "[preprocessor] When #including something that contri…

…butes no

tokens at all,". This change broke External/Nurbs in LLVM test-suite.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167858 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information...
commit 6e649737898ffb627c377fd8fa0a437d0a42ae4a 1 parent e5afdcf
@ddunbar ddunbar authored
View
2  include/clang/Basic/TokenKinds.def
@@ -103,8 +103,6 @@ TOK(unknown) // Not a token.
TOK(eof) // End of file.
TOK(eod) // End of preprocessing directive (end of line inside a
// directive).
-TOK(included_eof) // End of included file, only if
- // PreprocessorLexer::EnableIncludedEOF is true.
TOK(code_completion) // Code completion marker
TOK(cxx_defaultarg_end) // C++ default argument end marker
View
12 include/clang/Lex/PreprocessorLexer.h
@@ -61,10 +61,6 @@ class PreprocessorLexer {
/// 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;
@@ -83,8 +79,7 @@ class PreprocessorLexer {
: PP(0), InitialNumSLocEntries(0),
ParsingPreprocessorDirective(false),
ParsingFilename(false),
- LexingRawMode(false),
- EnableIncludedEOF(false) {}
+ LexingRawMode(false) {}
virtual ~PreprocessorLexer() {}
@@ -152,11 +147,6 @@ class PreprocessorLexer {
/// \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; }
View
22 lib/Lex/Lexer.cpp
@@ -2594,14 +2594,8 @@ void Lexer::LexTokenInternal(Token &Result) {
// Read the PP instance variable into an automatic variable, because
// LexEndOfFile will often delete 'this'.
Preprocessor *PPCache = PP;
- bool EnableIncludedEOFCache = EnableIncludedEOF;
if (LexEndOfFile(Result, CurPtr-1)) // Retreat back into the file.
return; // Got a token to return.
-
- if (EnableIncludedEOFCache) {
- Result.setKind(tok::included_eof);
- return;
- }
assert(PPCache && "Raw buffer::LexEndOfFile should return a token");
return PPCache->Lex(Result);
}
@@ -3239,21 +3233,5 @@ void Lexer::LexTokenInternal(Token &Result) {
}
goto LexNextToken; // GCC isn't tail call eliminating.
}
-
- if (PreprocessorLexer *PPLex = PP->getCurrentLexer()) {
- // If we #include something that contributes no tokens at all, return with
- // a tok::included_eof instead of recursively continuing lexing.
- // This avoids a stack overflow with a sequence of many empty #includes.
- PPLex->setEnableIncludedEOF(true);
- PP->Lex(Result);
- if (Result.isNot(tok::included_eof)) {
- if (Result.isNot(tok::eof) && Result.isNot(tok::eod))
- PPLex->setEnableIncludedEOF(false);
- return;
- }
- if (PP->isCurrentLexer(this))
- goto LexNextToken;
- }
-
return PP->Lex(Result);
}
View
2  lib/Lex/PreprocessorLexer.cpp
@@ -22,7 +22,7 @@ void PreprocessorLexer::anchor() { }
PreprocessorLexer::PreprocessorLexer(Preprocessor *pp, FileID fid)
: PP(pp), FID(fid), InitialNumSLocEntries(0),
ParsingPreprocessorDirective(false),
- ParsingFilename(false), LexingRawMode(false), EnableIncludedEOF(false) {
+ ParsingFilename(false), LexingRawMode(false) {
if (pp)
InitialNumSLocEntries = pp->getSourceManager().local_sloc_entry_size();
}
View
0  test/Index/Inputs/empty.h
No changes.
View
208 test/Index/pp-many-includes.c
@@ -1,208 +0,0 @@
-// RUN: env LIBCLANG_THREAD_SMALLSTACK=1 c-index-test -index-file %s | FileCheck %s
-
-// rdar://11988695
-// Check that we don't get stack overflow while including a lot of empty includes.
-
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-#include "Inputs/empty.h"
-
-// CHECK: [indexDeclaration]: kind: function | name: foo
-void foo();
View
2  tools/libclang/CIndex.cpp
@@ -6119,8 +6119,6 @@ namespace clang {
bool RunSafely(llvm::CrashRecoveryContext &CRC,
void (*Fn)(void*), void *UserData,
unsigned Size) {
- if (getenv("LIBCLANG_THREAD_SMALLSTACK"))
- Size = 0x10000; // 64K.
if (!Size)
Size = GetSafetyThreadStackSize();
if (Size)
Please sign in to comment.
Something went wrong with that request. Please try again.