diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-02-15 15:34:24 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-02-15 15:34:24 +0000 |
commit | 81f3bff7c202d688c9298bc049fdb5b6f77057b1 (patch) | |
tree | 3351f7acd82263793c2a57f316ddf5a08c0e5c20 /lib/Parse/ParseExprCXX.cpp | |
parent | 31c4690047f5f362ecf886f1586844b1aef0c4d2 (diff) |
Implement code completion support for lambda capture lists.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150583 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExprCXX.cpp')
-rw-r--r-- | lib/Parse/ParseExprCXX.cpp | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index 380237082b..5996e2a264 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -615,7 +615,7 @@ ExprResult Parser::TryParseLambdaExpression() { /// ParseLambdaExpression - Parse a lambda introducer. /// /// Returns a DiagnosticID if it hit something unexpected. -llvm::Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro) { +llvm::Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro){ typedef llvm::Optional<unsigned> DiagResult; assert(Tok.is(tok::l_square) && "Lambda expressions begin with '['."); @@ -640,13 +640,33 @@ llvm::Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro) while (Tok.isNot(tok::r_square)) { if (!first) { - if (Tok.isNot(tok::comma)) + if (Tok.isNot(tok::comma)) { + if (Tok.is(tok::code_completion)) { + Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, + /*AfterAmpersand=*/false); + ConsumeCodeCompletionToken(); + break; + } + return DiagResult(diag::err_expected_comma_or_rsquare); + } ConsumeToken(); } - first = false; + if (Tok.is(tok::code_completion)) { + // If we're in Objective-C++ and we have a bare '[', then this is more + // likely to be a message receiver. + if (getLang().ObjC1 && first) + Actions.CodeCompleteObjCMessageReceiver(getCurScope()); + else + Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, + /*AfterAmpersand=*/false); + ConsumeCodeCompletionToken(); + break; + } + first = false; + // Parse capture. LambdaCaptureKind Kind = LCK_ByCopy; SourceLocation Loc; @@ -660,6 +680,13 @@ llvm::Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro) if (Tok.is(tok::amp)) { Kind = LCK_ByRef; ConsumeToken(); + + if (Tok.is(tok::code_completion)) { + Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, + /*AfterAmpersand=*/true); + ConsumeCodeCompletionToken(); + break; + } } if (Tok.is(tok::identifier)) { @@ -687,7 +714,7 @@ llvm::Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro) return DiagResult(); } -/// TryParseLambdaExpression - Tentatively parse a lambda introducer. +/// TryParseLambdaIntroducer - Tentatively parse a lambda introducer. /// /// Returns true if it hit something unexpected. bool Parser::TryParseLambdaIntroducer(LambdaIntroducer &Intro) { |