diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-01-03 22:33:06 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-01-03 22:33:06 +0000 |
commit | d5756a609dbb14dff99cd83a0a50042da5275233 (patch) | |
tree | cccd9bc999630f88f69b567bd9464668fba56bab /clang/lib/Parse/ParseStmt.cpp | |
parent | 7ec835f35b80d6b61c63d0dd2a2b9cc2956c36bb (diff) | |
download | bcm5719-llvm-d5756a609dbb14dff99cd83a0a50042da5275233.tar.gz bcm5719-llvm-d5756a609dbb14dff99cd83a0a50042da5275233.zip |
When in code-completion, skip obj-c method bodies for speed up.
llvm-svn: 122781
Diffstat (limited to 'clang/lib/Parse/ParseStmt.cpp')
-rw-r--r-- | clang/lib/Parse/ParseStmt.cpp | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index d25cc110a8a..28b140e731b 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -1466,18 +1466,8 @@ Decl *Parser::ParseFunctionStatementBody(Decl *Decl) { assert(Tok.is(tok::l_brace)); SourceLocation LBraceLoc = Tok.getLocation(); - // When in code-completion, skip parsing for all function bodies unless - // the body contains the code-completion point. - if (PP.isCodeCompletionEnabled()) { - TentativeParsingAction PA(*this); - ConsumeBrace(); - if (SkipUntil(tok::r_brace, /*StopAtSemi=*/false, /*DontConsume=*/false, - /*StopAtCodeCompletion=*/true)) { - PA.Commit(); - return Actions.ActOnFinishFunctionBody(Decl, 0); - } - PA.Revert(); - } + if (MaybeSkipFunctionBodyForCodeCompletion()) + return Actions.ActOnFinishFunctionBody(Decl, 0); PrettyDeclStackTraceEntry CrashInfo(Actions, Decl, LBraceLoc, "parsing function body"); @@ -1511,6 +1501,9 @@ Decl *Parser::ParseFunctionTryBlock(Decl *Decl) { if (Tok.is(tok::colon)) ParseConstructorInitializer(Decl); + if (MaybeSkipFunctionBodyForCodeCompletion()) + return Actions.ActOnFinishFunctionBody(Decl, 0); + SourceLocation LBraceLoc = Tok.getLocation(); StmtResult FnBody(ParseCXXTryBlockCommon(TryLoc)); // If we failed to parse the try-catch, we just give the function an empty @@ -1522,6 +1515,26 @@ Decl *Parser::ParseFunctionTryBlock(Decl *Decl) { return Actions.ActOnFinishFunctionBody(Decl, FnBody.take()); } +bool Parser::MaybeSkipFunctionBodyForCodeCompletion() { + assert(Tok.is(tok::l_brace)); + + if (!PP.isCodeCompletionEnabled()) + return false; + + // We're in code-completion mode. Skip parsing for all function bodies unless + // the body contains the code-completion point. + TentativeParsingAction PA(*this); + ConsumeBrace(); + if (SkipUntil(tok::r_brace, /*StopAtSemi=*/false, /*DontConsume=*/false, + /*StopAtCodeCompletion=*/true)) { + PA.Commit(); + return true; + } + + PA.Revert(); + return false; +} + /// ParseCXXTryBlock - Parse a C++ try-block. /// /// try-block: |