diff options
Diffstat (limited to 'clang/include')
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticParseKinds.td | 9 | ||||
| -rw-r--r-- | clang/include/clang/Parse/Parser.h | 13 | ||||
| -rw-r--r-- | clang/include/clang/Sema/DeclSpec.h | 47 |
3 files changed, 68 insertions, 1 deletions
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index 3764a409154..27b4f850eef 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -487,6 +487,15 @@ def err_paren_sizeof_parameter_pack : Error< def err_sizeof_parameter_pack : Error< "expected parenthesized parameter pack name in 'sizeof...' expression">; +// C++0x lambda expressions +def err_expected_comma_or_rsquare : Error< + "expected ',' or ']' in lambda capture list">; +def err_this_captured_by_reference : Error< + "'this' cannot be captured by reference">; +def err_expected_capture : Error< + "expected variable name or 'this' in lambda capture list">; +def err_expected_lambda_body : Error<"expected body of lambda expression">; + // Availability attribute def err_expected_version : Error< "expected a version of the form 'major[.minor[.subminor]]'">; diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 83b0cd455e9..af3f40ec40b 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -1186,6 +1186,17 @@ private: bool IsTypename = false); //===--------------------------------------------------------------------===// + // C++0x 5.1.2: Lambda expressions + + // [...] () -> type {...} + ExprResult ParseLambdaExpression(); + ExprResult TryParseLambdaExpression(); + llvm::Optional<unsigned> ParseLambdaIntroducer(LambdaIntroducer &Intro); + bool TryParseLambdaIntroducer(LambdaIntroducer &Intro); + ExprResult ParseLambdaExpressionAfterIntroducer( + LambdaIntroducer &Intro); + + //===--------------------------------------------------------------------===// // C++ 5.2p1: C++ Casts ExprResult ParseCXXCasts(); @@ -1226,7 +1237,7 @@ private: //===--------------------------------------------------------------------===// // C++0x 8: Function declaration trailing-return-type - TypeResult ParseTrailingReturnType(); + TypeResult ParseTrailingReturnType(SourceRange &Range); //===--------------------------------------------------------------------===// // C++ 2.13.5: C++ Boolean Literals diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h index ad96c458446..cdd7dbaa6d2 100644 --- a/clang/include/clang/Sema/DeclSpec.h +++ b/clang/include/clang/Sema/DeclSpec.h @@ -1828,6 +1828,53 @@ private: SourceLocation LastLocation; }; +/// LambdaCaptureDefault - The default, if any, capture method for a +/// lambda expression. +enum LambdaCaptureDefault { + LCD_None, + LCD_ByCopy, + LCD_ByRef +}; + +/// LambdaCaptureKind - The different capture forms in a lambda +/// introducer: 'this' or a copied or referenced variable. +enum LambdaCaptureKind { + LCK_This, + LCK_ByCopy, + LCK_ByRef +}; + +/// LambdaCapture - An individual capture in a lambda introducer. +struct LambdaCapture { + LambdaCaptureKind Kind; + SourceLocation Loc; + IdentifierInfo* Id; + + LambdaCapture(LambdaCaptureKind Kind, + SourceLocation Loc, + IdentifierInfo* Id = 0) + : Kind(Kind), Loc(Loc), Id(Id) + {} +}; + +/// LambdaIntroducer - Represents a complete lambda introducer. +struct LambdaIntroducer { + SourceRange Range; + LambdaCaptureDefault Default; + llvm::SmallVector<LambdaCapture, 4> Captures; + + LambdaIntroducer() + : Default(LCD_None) {} + + /// addCapture - Append a capture in a lambda introducer. + void addCapture(LambdaCaptureKind Kind, + SourceLocation Loc, + IdentifierInfo* Id = 0) { + Captures.push_back(LambdaCapture(Kind, Loc, Id)); + } + +}; + } // end namespace clang #endif |

