diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-01-07 01:08:17 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-01-07 01:08:17 +0000 |
commit | e81d7e9810eed0d805263791d761ec545d2cf779 (patch) | |
tree | a48a534d55c3e1430f8475c8b9219d1052c6d669 /include/clang/Sema/ScopeInfo.h | |
parent | 3070e13dca5bbefa32acb80ce4a7b217a6220983 (diff) |
Lambdas: semantic analysis of explicit captures.
This patch (and some of my other commits related to lambdas) is heavily based off of John Freeman's work-in-progress patches.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147706 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Sema/ScopeInfo.h')
-rw-r--r-- | include/clang/Sema/ScopeInfo.h | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/include/clang/Sema/ScopeInfo.h b/include/clang/Sema/ScopeInfo.h index 1edeff5b43..6a6f395c87 100644 --- a/include/clang/Sema/ScopeInfo.h +++ b/include/clang/Sema/ScopeInfo.h @@ -160,6 +160,29 @@ public: class LambdaScopeInfo : public FunctionScopeInfo { public: + + class Capture { + llvm::PointerIntPair<VarDecl*, 2, LambdaCaptureKind> InitAndKind; + + public: + Capture(VarDecl *Var, LambdaCaptureKind Kind) + : InitAndKind(Var, Kind) {} + + enum IsThisCapture { ThisCapture }; + Capture(IsThisCapture) + : InitAndKind(0, LCK_This) {} + + bool isThisCapture() const { return InitAndKind.getInt() == LCK_This; } + bool isVariableCapture() const { return !isThisCapture(); } + bool isCopyCapture() const { return InitAndKind.getInt() == LCK_ByCopy; } + bool isReferenceCapture() const { return InitAndKind.getInt() == LCK_ByRef; } + + VarDecl *getVariable() const { + return InitAndKind.getPointer(); + } + + }; + /// \brief The class that describes the lambda. CXXRecordDecl *Lambda; @@ -169,9 +192,7 @@ public: /// \brief The list of captured variables, starting with the explicit /// captures and then finishing with any implicit captures. - // TODO: This is commented out until an implementation of LambdaExpr is - // committed. - // llvm::SmallVector<LambdaExpr::Capture, 4> Captures; + llvm::SmallVector<Capture, 4> Captures; /// \brief The number of captures in the \c Captures list that are /// explicit captures. |