diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2012-04-14 14:01:31 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2012-04-14 14:01:31 +0000 |
commit | dbe13110f59f48b4dbb7552b3ac2935acdeece7f (patch) | |
tree | be1815eb79b42ff482a8562b13c2dcbf0c5dcbee /lib/Parse/ParseAST.cpp | |
parent | 9da628931ebf2609493570f87824ca22402cc65f (diff) |
Notes
Diffstat (limited to 'lib/Parse/ParseAST.cpp')
-rw-r--r-- | lib/Parse/ParseAST.cpp | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/lib/Parse/ParseAST.cpp b/lib/Parse/ParseAST.cpp index fdd7d0f151a6..d1c2624f8cb3 100644 --- a/lib/Parse/ParseAST.cpp +++ b/lib/Parse/ParseAST.cpp @@ -38,23 +38,24 @@ using namespace clang; void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, ASTContext &Ctx, bool PrintStats, TranslationUnitKind TUKind, - CodeCompleteConsumer *CompletionConsumer) { + CodeCompleteConsumer *CompletionConsumer, + bool SkipFunctionBodies) { - llvm::OwningPtr<Sema> S(new Sema(PP, Ctx, *Consumer, + OwningPtr<Sema> S(new Sema(PP, Ctx, *Consumer, TUKind, CompletionConsumer)); // Recover resources if we crash before exiting this method. - llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleaupSema(S.get()); + llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleanupSema(S.get()); - ParseAST(*S.get(), PrintStats); + ParseAST(*S.get(), PrintStats, SkipFunctionBodies); } -void clang::ParseAST(Sema &S, bool PrintStats) { +void clang::ParseAST(Sema &S, bool PrintStats, bool SkipFunctionBodies) { // Collect global stats on Decls/Stmts (until we have a module streamer). if (PrintStats) { - Decl::CollectingStats(true); - Stmt::CollectingStats(true); + Decl::EnableStatistics(); + Stmt::EnableStatistics(); } // Also turn on collection of stats inside of the Sema object. @@ -63,14 +64,15 @@ void clang::ParseAST(Sema &S, bool PrintStats) { ASTConsumer *Consumer = &S.getASTConsumer(); - llvm::OwningPtr<Parser> ParseOP(new Parser(S.getPreprocessor(), S)); + OwningPtr<Parser> ParseOP(new Parser(S.getPreprocessor(), S, + SkipFunctionBodies)); Parser &P = *ParseOP.get(); PrettyStackTraceParserEntry CrashInfo(P); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar<Parser> - CleaupParser(ParseOP.get()); + CleanupParser(ParseOP.get()); S.getPreprocessor().EnterMainSourceFile(); P.Initialize(); @@ -79,18 +81,23 @@ void clang::ParseAST(Sema &S, bool PrintStats) { if (ExternalASTSource *External = S.getASTContext().getExternalSource()) External->StartTranslationUnit(Consumer); + bool Abort = false; Parser::DeclGroupPtrTy ADecl; while (!P.ParseTopLevelDecl(ADecl)) { // Not end of file. // If we got a null return and something *was* parsed, ignore it. This // is due to a top-level semicolon, an action override, or a parse error // skipping something. - if (ADecl) - Consumer->HandleTopLevelDecl(ADecl.get()); + if (ADecl) { + if (!Consumer->HandleTopLevelDecl(ADecl.get())) { + Abort = true; + break; + } + } }; - // Check for any pending objective-c implementation decl. - while ((ADecl = P.FinishPendingObjCActions())) - Consumer->HandleTopLevelDecl(ADecl.get()); + + if (Abort) + return; // Process any TopLevelDecls generated by #pragma weak. for (SmallVector<Decl*,2>::iterator |