aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-01-03 22:33:06 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-01-03 22:33:06 +0000
commit0fe5397b26695926a835fa99eceb7fc879b307af (patch)
tree9bb623be3510bd5df174fd4d5871731ed5f698d5 /lib
parent69e5aed635946419d85a6be8639260e2eb476cb1 (diff)
When in code-completion, skip obj-c method bodies for speed up.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122781 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Parse/ParseObjc.cpp3
-rw-r--r--lib/Parse/ParseStmt.cpp37
-rw-r--r--lib/Sema/SemaDecl.cpp3
3 files changed, 30 insertions, 13 deletions
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index c48f6803b0..25829e8975 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -1718,6 +1718,9 @@ Decl *Parser::ParseObjCMethodDefinition() {
// specified Declarator for the method.
Actions.ActOnStartOfObjCMethodDef(getCurScope(), MDecl);
+ if (MaybeSkipFunctionBodyForCodeCompletion())
+ return Actions.ActOnFinishFunctionBody(MDecl, 0);
+
StmtResult FnBody(ParseCompoundStatementBody());
// If the function body could not be parsed, make a bogus compoundstmt.
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index d25cc110a8..28b140e731 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/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:
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index dc851a3e83..1c03f7d7f7 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -5415,7 +5415,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
} else if (ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
assert(MD == getCurMethodDecl() && "Method parsing confused");
MD->setBody(Body);
- MD->setEndLoc(Body->getLocEnd());
+ if (Body)
+ MD->setEndLoc(Body->getLocEnd());
if (!MD->isInvalidDecl()) {
DiagnoseUnusedParameters(MD->param_begin(), MD->param_end());
DiagnoseSizeOfParametersAndReturnValue(MD->param_begin(), MD->param_end(),