Make Preprocessor::Lex non-recursive.
Before this patch, Lex() would recurse whenever the current lexer changed (e.g. upon entry into a macro). This patch turns the recursion into a loop: the various lex routines now don't return a token when the current lexer changes, and at the top level Preprocessor::Lex() now loops until it finds a token. Normally, the recursion wouldn't end up being very deep, but the recursion depth can explode in edge cases like a bunch of consecutive macros which expand to nothing (like in the testcase test/Preprocessor/macro_expand_empty.c in this patch). <rdar://problem/14569770> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190980 91177308-0d34-0410-b5e6-96231b3b80d8
Showing
- include/clang/Lex/Lexer.h 29 additions, 27 deletionsinclude/clang/Lex/Lexer.h
- include/clang/Lex/PTHLexer.h 1 addition, 1 deletioninclude/clang/Lex/PTHLexer.h
- include/clang/Lex/Preprocessor.h 9 additions, 13 deletionsinclude/clang/Lex/Preprocessor.h
- include/clang/Lex/Token.h 4 additions, 2 deletionsinclude/clang/Lex/Token.h
- include/clang/Lex/TokenLexer.h 3 additions, 1 deletioninclude/clang/Lex/TokenLexer.h
- lib/Frontend/VerifyDiagnosticConsumer.cpp 1 addition, 1 deletionlib/Frontend/VerifyDiagnosticConsumer.cpp
- lib/Lex/Lexer.cpp 163 additions, 90 deletionslib/Lex/Lexer.cpp
- lib/Lex/PPLexerChange.cpp 16 additions, 0 deletionslib/Lex/PPLexerChange.cpp
- lib/Lex/PPMacroExpansion.cpp 6 additions, 28 deletionslib/Lex/PPMacroExpansion.cpp
- lib/Lex/PTHLexer.cpp 8 additions, 17 deletionslib/Lex/PTHLexer.cpp
- lib/Lex/Preprocessor.cpp 33 additions, 3 deletionslib/Lex/Preprocessor.cpp
- lib/Lex/PreprocessorLexer.cpp 4 additions, 1 deletionlib/Lex/PreprocessorLexer.cpp
- lib/Lex/TokenLexer.cpp 17 additions, 12 deletionslib/Lex/TokenLexer.cpp
- test/Preprocessor/hash_line.c 7 additions, 6 deletionstest/Preprocessor/hash_line.c
- test/Preprocessor/macro_expand_empty.c 14 additions, 0 deletionstest/Preprocessor/macro_expand_empty.c
- test/SemaCXX/warn-empty-body.cpp 5 additions, 0 deletionstest/SemaCXX/warn-empty-body.cpp
Loading
Please register or sign in to comment