|
@@ -20,7 +20,7 @@
|
|
#include "clang/AST/TemplateBase.h"
|
|
#include "clang/AST/TemplateBase.h"
|
|
#include "clang/AST/UnresolvedSet.h"
|
|
#include "clang/AST/UnresolvedSet.h"
|
|
#include "clang/Basic/ExpressionTraits.h"
|
|
#include "clang/Basic/ExpressionTraits.h"
|
|
-#include "clang/Basic/Lambda.h"
|
|
|
|
|
|
+#include "clang/AST/LambdaCapture.h"
|
|
#include "clang/Basic/TypeTraits.h"
|
|
#include "clang/Basic/TypeTraits.h"
|
|
#include "llvm/Support/Compiler.h"
|
|
#include "llvm/Support/Compiler.h"
|
|
|
|
|
|
@@ -1310,18 +1310,6 @@ public:
|
|
/// includes an initializing expression (rather than capturing a variable),
|
|
/// includes an initializing expression (rather than capturing a variable),
|
|
/// and which can never occur implicitly.
|
|
/// and which can never occur implicitly.
|
|
class LambdaExpr : public Expr {
|
|
class LambdaExpr : public Expr {
|
|
- enum {
|
|
|
|
- /// \brief Flag used by the Capture class to indicate that the given
|
|
|
|
- /// capture was implicit.
|
|
|
|
- Capture_Implicit = 0x01,
|
|
|
|
-
|
|
|
|
- /// \brief Flag used by the Capture class to indicate that the
|
|
|
|
- /// given capture was by-copy.
|
|
|
|
- ///
|
|
|
|
- /// This includes the case of a non-reference init-capture.
|
|
|
|
- Capture_ByCopy = 0x02
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
/// \brief The source range that covers the lambda introducer ([...]).
|
|
/// \brief The source range that covers the lambda introducer ([...]).
|
|
SourceRange IntroducerRange;
|
|
SourceRange IntroducerRange;
|
|
|
|
|
|
@@ -1360,93 +1348,8 @@ class LambdaExpr : public Expr {
|
|
// expression, along with the index variables used to initialize by-copy
|
|
// expression, along with the index variables used to initialize by-copy
|
|
// array captures.
|
|
// array captures.
|
|
|
|
|
|
-public:
|
|
|
|
- /// \brief Describes the capture of a variable or of \c this, or of a
|
|
|
|
- /// C++1y init-capture.
|
|
|
|
- class Capture {
|
|
|
|
- llvm::PointerIntPair<Decl *, 2> DeclAndBits;
|
|
|
|
- SourceLocation Loc;
|
|
|
|
- SourceLocation EllipsisLoc;
|
|
|
|
-
|
|
|
|
- friend class ASTStmtReader;
|
|
|
|
- friend class ASTStmtWriter;
|
|
|
|
-
|
|
|
|
- public:
|
|
|
|
- /// \brief Create a new capture of a variable or of \c this.
|
|
|
|
- ///
|
|
|
|
- /// \param Loc The source location associated with this capture.
|
|
|
|
- ///
|
|
|
|
- /// \param Kind The kind of capture (this, byref, bycopy), which must
|
|
|
|
- /// not be init-capture.
|
|
|
|
- ///
|
|
|
|
- /// \param Implicit Whether the capture was implicit or explicit.
|
|
|
|
- ///
|
|
|
|
- /// \param Var The local variable being captured, or null if capturing
|
|
|
|
- /// \c this.
|
|
|
|
- ///
|
|
|
|
- /// \param EllipsisLoc The location of the ellipsis (...) for a
|
|
|
|
- /// capture that is a pack expansion, or an invalid source
|
|
|
|
- /// location to indicate that this is not a pack expansion.
|
|
|
|
- Capture(SourceLocation Loc, bool Implicit,
|
|
|
|
- LambdaCaptureKind Kind, VarDecl *Var = nullptr,
|
|
|
|
- SourceLocation EllipsisLoc = SourceLocation());
|
|
|
|
-
|
|
|
|
- /// \brief Determine the kind of capture.
|
|
|
|
- LambdaCaptureKind getCaptureKind() const;
|
|
|
|
-
|
|
|
|
- /// \brief Determine whether this capture handles the C++ \c this
|
|
|
|
- /// pointer.
|
|
|
|
- bool capturesThis() const { return DeclAndBits.getPointer() == nullptr; }
|
|
|
|
-
|
|
|
|
- /// \brief Determine whether this capture handles a variable.
|
|
|
|
- bool capturesVariable() const {
|
|
|
|
- return dyn_cast_or_null<VarDecl>(DeclAndBits.getPointer());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// \brief Determine whether this is an init-capture.
|
|
|
|
- bool isInitCapture() const {
|
|
|
|
- return capturesVariable() && getCapturedVar()->isInitCapture();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// \brief Retrieve the declaration of the local variable being
|
|
|
|
- /// captured.
|
|
|
|
- ///
|
|
|
|
- /// This operation is only valid if this capture is a variable capture
|
|
|
|
- /// (other than a capture of \c this).
|
|
|
|
- VarDecl *getCapturedVar() const {
|
|
|
|
- assert(capturesVariable() && "No variable available for 'this' capture");
|
|
|
|
- return cast<VarDecl>(DeclAndBits.getPointer());
|
|
|
|
- }
|
|
|
|
|
|
+ typedef LambdaCapture Capture;
|
|
|
|
|
|
- /// \brief Determine whether this was an implicit capture (not
|
|
|
|
- /// written between the square brackets introducing the lambda).
|
|
|
|
- bool isImplicit() const { return DeclAndBits.getInt() & Capture_Implicit; }
|
|
|
|
-
|
|
|
|
- /// \brief Determine whether this was an explicit capture (written
|
|
|
|
- /// between the square brackets introducing the lambda).
|
|
|
|
- bool isExplicit() const { return !isImplicit(); }
|
|
|
|
-
|
|
|
|
- /// \brief Retrieve the source location of the capture.
|
|
|
|
- ///
|
|
|
|
- /// For an explicit capture, this returns the location of the
|
|
|
|
- /// explicit capture in the source. For an implicit capture, this
|
|
|
|
- /// returns the location at which the variable or \c this was first
|
|
|
|
- /// used.
|
|
|
|
- SourceLocation getLocation() const { return Loc; }
|
|
|
|
-
|
|
|
|
- /// \brief Determine whether this capture is a pack expansion,
|
|
|
|
- /// which captures a function parameter pack.
|
|
|
|
- bool isPackExpansion() const { return EllipsisLoc.isValid(); }
|
|
|
|
-
|
|
|
|
- /// \brief Retrieve the location of the ellipsis for a capture
|
|
|
|
- /// that is a pack expansion.
|
|
|
|
- SourceLocation getEllipsisLoc() const {
|
|
|
|
- assert(isPackExpansion() && "No ellipsis location for a non-expansion");
|
|
|
|
- return EllipsisLoc;
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
-private:
|
|
|
|
/// \brief Construct a lambda expression.
|
|
/// \brief Construct a lambda expression.
|
|
LambdaExpr(QualType T, SourceRange IntroducerRange,
|
|
LambdaExpr(QualType T, SourceRange IntroducerRange,
|
|
LambdaCaptureDefault CaptureDefault,
|
|
LambdaCaptureDefault CaptureDefault,
|