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/Parse/Parser.cpp | |
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/Parse/Parser.cpp')
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 9613ad0f853..dd339f53948 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -475,6 +475,11 @@ void Parser::Initialize() { bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result) { DelayedCleanupPoint CleanupRAII(TopLevelDeclCleanupPool); + // Skip over the EOF token, flagging end of previous input for incremental + // processing + if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::eof)) + ConsumeToken(); + while (Tok.is(tok::annot_pragma_unused)) HandlePragmaUnused(); @@ -483,15 +488,17 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result) { // Late template parsing can begin. if (getLangOpts().DelayedTemplateParsing) Actions.SetLateTemplateParser(LateTemplateParserCallback, this); + if (!PP.isIncrementalProcessingEnabled()) + Actions.ActOnEndOfTranslationUnit(); + //else don't tell Sema that we ended parsing: more input might come. - Actions.ActOnEndOfTranslationUnit(); return true; } ParsedAttributesWithRange attrs(AttrFactory); MaybeParseCXX0XAttributes(attrs); MaybeParseMicrosoftAttributes(attrs); - + Result = ParseExternalDeclaration(attrs); return false; } |