On reflection, can we delay building the initialization expressions for
captures until we get to the end of the lambda expression? There seems to be no
need to build them early, and delaying would solve the wrong-context problem
implicitly.
================
Comment at: lib/Sema/SemaExpr.cpp:12118-12136
@@ +12117,21 @@
+
+ struct TemporarilyJumpOutToDeclContextScopeGuard {
+ Sema &S;
+ Scope *CurScope;
+ DeclContext *CurContext;
+ TemporarilyJumpOutToDeclContextScopeGuard(Sema &S, LambdaScopeInfo *LSI)
+ : S(S), CurScope(S.getCurScope()), CurContext(S.CurContext) {
+ S.CurContext = LSI->Lambda->getDeclContext();
+ // FVQUESTION: Do we really need to mess with the Scope - or can I just
+ // ignore it since, unless I am entirely mistake, its raison d'ĂȘtre seems
+ // to be to aid the Parser, which will not be invoked from the ensuing
+ // sequence?
+ S.setCurScope(S.getScopeForContext(S.CurContext));
+ }
+ ~TemporarilyJumpOutToDeclContextScopeGuard() {
+ S.CurContext = CurContext;
+ S.setCurScope(CurScope);
+ }
+ } DeclContextScopeGuard(S, LSI);
+
+ // Construct the entity that we will be initializing. For an array, this will
----------------
This is:
ContextRAII SwitchToLambdaContext(S, LSI->Lambda->getDeclContext());
================
Comment at: lib/Sema/SemaExpr.cpp:12125-12128
@@ +12124,6 @@
+ S.CurContext = LSI->Lambda->getDeclContext();
+ // FVQUESTION: Do we really need to mess with the Scope - or can I just
+ // ignore it since, unless I am entirely mistake, its raison d'ĂȘtre seems
+ // to be to aid the Parser, which will not be invoked from the ensuing
+ // sequence?
+ S.setCurScope(S.getScopeForContext(S.CurContext));
----------------
You shouldn't need this; `CurScope` should only be used while parsing (and
ideally shouldn't be used in Sema for C++ at all); if we use `CurScope` in
here, we will do the wrong thing during template instantiation, where
`CurScope` is not set.
http://reviews.llvm.org/D6171
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits