diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Parse/ParseAST.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Parse/ParseAST.cpp | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/contrib/llvm/tools/clang/lib/Parse/ParseAST.cpp b/contrib/llvm/tools/clang/lib/Parse/ParseAST.cpp index fdd7d0f..d1c2624 100644 --- a/contrib/llvm/tools/clang/lib/Parse/ParseAST.cpp +++ b/contrib/llvm/tools/clang/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 |