aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-01-03 19:44:02 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-01-03 19:44:02 +0000
commit3437f1f1294499d4ef306c1089fcb3e29ec2aa68 (patch)
tree87da70c55989fd61cdaa0eb884c71e6d7578c492 /lib/Parse/ParseStmt.cpp
parentdcaa1ca0b475dfa887e1d061678a1e3501288510 (diff)
Speed up code-completion by skipping function bodies.
When we are in code-completion mode, skip parsing of all function bodies except the one where the code-completion point resides. For big .cpp files like 'SemaExpr.cpp' the improvement makes a huge difference, in some cases cutting down code-completion time -62% ! We don't get diagnostics for the bodies though, so modify the code-completion tests that check for errors. See rdar://8814203. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122765 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseStmt.cpp')
-rw-r--r--lib/Parse/ParseStmt.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index dafe373778..d25cc110a8 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -1466,6 +1466,19 @@ 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();
+ }
+
PrettyDeclStackTraceEntry CrashInfo(Actions, Decl, LBraceLoc,
"parsing function body");