diff options
author | Axel Naumann <Axel.Naumann@cern.ch> | 2012-03-16 10:40:17 +0000 |
---|---|---|
committer | Axel Naumann <Axel.Naumann@cern.ch> | 2012-03-16 10:40:17 +0000 |
commit | 2eb1d90fd864fd48d4206924f734564c9285beaf (patch) | |
tree | 82df5a097d5b2d879c522f31da1350fb6fcae1cd /clang/lib/Lex | |
parent | 371badaa478283b73c5dc1565f3162a780c4aae7 (diff) | |
download | bcm5719-llvm-2eb1d90fd864fd48d4206924f734564c9285beaf.tar.gz bcm5719-llvm-2eb1d90fd864fd48d4206924f734564c9285beaf.zip |
From Vassil Vassilev:
Enable incremental parsing by the Preprocessor,
where more code can be provided after an EOF.
It mainly prevents the tearing down of the topmost lexer.
To be used like this:
PP.enableIncrementalProcessing();
while (getMoreSource()) {
while (Parser.ParseTopLevelDecl(ADecl)) {...}
}
PP.enableIncrementalProcessing(false);
llvm-svn: 152914
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r-- | clang/lib/Lex/PPLexerChange.cpp | 10 | ||||
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 9 |
2 files changed, 11 insertions, 8 deletions
diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp index 3056e0c41a0..b6689df1868 100644 --- a/clang/lib/Lex/PPLexerChange.cpp +++ b/clang/lib/Lex/PPLexerChange.cpp @@ -328,15 +328,17 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) { CurLexer->BufferPtr = EndPos; CurLexer->FormTokenWithChars(Result, EndPos, tok::eof); - // We're done with the #included file. - CurLexer.reset(); + if (!isIncrementalProcessingEnabled()) + // We're done with lexing. + CurLexer.reset(); } else { assert(CurPTHLexer && "Got EOF but no current lexer set!"); CurPTHLexer->getEOF(Result); CurPTHLexer.reset(); } - - CurPPLexer = 0; + + if (!isIncrementalProcessingEnabled()) + CurPPLexer = 0; // This is the end of the top-level file. 'WarnUnusedMacroLocs' has collected // all macro locations that we need to warn because they are not used. diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 6142436e6d1..f7f63ee01fb 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -54,18 +54,19 @@ Preprocessor::Preprocessor(DiagnosticsEngine &diags, LangOptions &opts, HeaderSearch &Headers, ModuleLoader &TheModuleLoader, IdentifierInfoLookup* IILookup, bool OwnsHeaders, - bool DelayInitialization) + bool DelayInitialization, + bool IncrProcessing) : Diags(&diags), LangOpts(opts), Target(target),FileMgr(Headers.getFileMgr()), SourceMgr(SM), HeaderInfo(Headers), TheModuleLoader(TheModuleLoader), - ExternalSource(0), - Identifiers(opts, IILookup), CodeComplete(0), + ExternalSource(0), Identifiers(opts, IILookup), + IncrementalProcessing(IncrProcessing), CodeComplete(0), CodeCompletionFile(0), CodeCompletionOffset(0), CodeCompletionReached(0), SkipMainFilePreamble(0, true), CurPPLexer(0), CurDirLookup(0), CurLexerKind(CLK_Lexer), Callbacks(0), MacroArgCache(0), Record(0), MIChainHead(0), MICache(0) { OwnsHeaderSearch = OwnsHeaders; - + if (!DelayInitialization) { assert(Target && "Must provide target information for PP initialization"); Initialize(*Target); |