[cfe-commits] r122781 - in /cfe/trunk: include/clang/Parse/Parser.h lib/Parse/ParseObjc.cpp lib/Parse/ParseStmt.cpp lib/Sema/SemaDecl.cpp test/Index/complete-synthesized.m
Argyrios Kyrtzidis
akyrtzi at gmail.com
Mon Jan 3 14:33:07 PST 2011
Author: akirtzidis
Date: Mon Jan 3 16:33:06 2011
New Revision: 122781
URL: http://llvm.org/viewvc/llvm-project?rev=122781&view=rev
Log:
When in code-completion, skip obj-c method bodies for speed up.
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Index/complete-synthesized.m
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=122781&r1=122780&r2=122781&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Jan 3 16:33:06 2011
@@ -1262,6 +1262,12 @@
Decl *ParseFunctionStatementBody(Decl *Decl);
Decl *ParseFunctionTryBlock(Decl *Decl);
+ /// \brief When in code-completion, skip parsing of the function/method body
+ /// unless the body contains the code-completion point.
+ ///
+ /// \returns true if the function body was skipped.
+ bool MaybeSkipFunctionBodyForCodeCompletion();
+
bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
const ParsedTemplateInfo &TemplateInfo,
AccessSpecifier AS);
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=122781&r1=122780&r2=122781&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Mon Jan 3 16:33:06 2011
@@ -1718,6 +1718,9 @@
// 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.
Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=122781&r1=122780&r2=122781&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Mon Jan 3 16:33:06 2011
@@ -1466,18 +1466,8 @@
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 @@
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 @@
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:
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=122781&r1=122780&r2=122781&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jan 3 16:33:06 2011
@@ -5415,7 +5415,8 @@
} 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(),
Modified: cfe/trunk/test/Index/complete-synthesized.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-synthesized.m?rev=122781&r1=122780&r2=122781&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-synthesized.m (original)
+++ cfe/trunk/test/Index/complete-synthesized.m Mon Jan 3 16:33:06 2011
@@ -51,6 +51,6 @@
// RUN: c-index-test -code-completion-at=%s:34:2 -Xclang -fobjc-nonfragile-abi2 %s | FileCheck -check-prefix=CHECK-CC3 %s
// CHECK-CC3: NotImplemented:{TypedText _Bool} (50)
// CHECK-CC3: ObjCIvarDecl:{ResultType float}{TypedText _prop2} (35)
-// CHECK-CC3: ObjCIvarDecl:{ResultType double}{TypedText prop4}
+// CHECK-CC3: ObjCPropertyDecl:{ResultType double}{TypedText prop4}
// CHECK-CC3-NOT: ObjCPropertyDecl:{ResultType double}{TypedText prop4} (35)
// CHECK-CC1: restrict
More information about the cfe-commits
mailing list