summaryrefslogtreecommitdiffstats
path: root/include/clang/Sema/ScopeInfo.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-02-01 01:18:43 +0000
committerDouglas Gregor <dgregor@apple.com>2012-02-01 01:18:43 +0000
commit93962e5360a43200faa70939571afc4fb9326cf7 (patch)
treefdf5ea75ff50a5501e38630d0e1c90aa832859f2 /include/clang/Sema/ScopeInfo.h
parentee625afea71ef5a9c1e386564919b86915d96b0d (diff)
Improve checking of explicit captures in a C++11 lambda expression:
- Actually building the var -> capture mapping properly (there was an off-by-one error) - Keeping track of the source location of each capture - Minor QoI improvements, e.g, highlighing the prior capture if there are multiple captures, pointing at the variable declaration we found if we reject it. As part of this, add standard citations for the various semantic checks we perform, and note where we're not performing those checks as we should. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149462 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Sema/ScopeInfo.h')
-rw-r--r--include/clang/Sema/ScopeInfo.h24
1 files changed, 16 insertions, 8 deletions
diff --git a/include/clang/Sema/ScopeInfo.h b/include/clang/Sema/ScopeInfo.h
index 7ffc3bcfb9..bff2cf8ad2 100644
--- a/include/clang/Sema/ScopeInfo.h
+++ b/include/clang/Sema/ScopeInfo.h
@@ -140,15 +140,18 @@ public:
// copy constructor.
llvm::PointerIntPair<Expr*, 1, bool> CopyExprAndNested;
+ /// \brief The source location at which the first capture occurred..
+ SourceLocation Loc;
+
public:
- Capture(VarDecl *Var, bool isByref, bool isNested, Expr *Cpy)
+ Capture(VarDecl *Var, bool isByref, bool isNested, SourceLocation Loc,
+ Expr *Cpy)
: VarAndKind(Var, isByref ? Cap_ByRef : Cap_ByVal),
CopyExprAndNested(Cpy, isNested) {}
enum IsThisCapture { ThisCapture };
- Capture(IsThisCapture, bool isNested)
- : VarAndKind(0, Cap_This),
- CopyExprAndNested(0, isNested) {
+ Capture(IsThisCapture, bool isNested, SourceLocation Loc)
+ : VarAndKind(0, Cap_This), CopyExprAndNested(0, isNested), Loc(Loc) {
}
bool isThisCapture() const { return VarAndKind.getInt() == Cap_This; }
@@ -160,6 +163,10 @@ public:
VarDecl *getVariable() const {
return VarAndKind.getPointer();
}
+
+ /// \brief Retrieve the location at which this variable was captured.
+ SourceLocation getLocation() const { return Loc; }
+
Expr *getCopyExpr() const {
return CopyExprAndNested.getPointer();
}
@@ -188,13 +195,14 @@ public:
/// or null if unknown.
QualType ReturnType;
- void AddCapture(VarDecl *Var, bool isByref, bool isNested, Expr *Cpy) {
- Captures.push_back(Capture(Var, isByref, isNested, Cpy));
+ void AddCapture(VarDecl *Var, bool isByref, bool isNested, SourceLocation Loc,
+ Expr *Cpy) {
+ Captures.push_back(Capture(Var, isByref, isNested, Loc, Cpy));
CaptureMap[Var] = Captures.size();
}
- void AddThisCapture(bool isNested) {
- Captures.push_back(Capture(Capture::ThisCapture, isNested));
+ void AddThisCapture(bool isNested, SourceLocation Loc) {
+ Captures.push_back(Capture(Capture::ThisCapture, isNested, Loc));
CXXThisCaptureIndex = Captures.size();
}