[cfe-commits] r150088 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
Douglas Gregor
dgregor at apple.com
Wed Feb 8 13:23:54 PST 2012
On Feb 8, 2012, at 11:17 AM, David Blaikie wrote:
> On Wed, Feb 8, 2012 at 12:56 PM, Douglas Gregor <dgregor at apple.com> wrote:
>> Author: dgregor
>> Date: Wed Feb 8 14:56:50 2012
>> New Revision: 150088
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=150088&view=rev
>> Log:
>> When computing the type of a local variable reference within a lambda,
>> only add 'const' for variables captured by copy in potentially
>> evaluated expressions of non-mutable lambdas. (The "by copy" part was
>> missing).
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=150088&r1=150087&r2=150088&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Feb 8 14:56:50 2012
>> @@ -2094,6 +2094,15 @@
>> return S.getCurBlock() != 0;
>> }
>>
>> +/// \brief Determine whether the given lambda would capture the given
>> +/// variable by copy.
>> +static bool willCaptureByCopy(LambdaScopeInfo *LSI, VarDecl *Var) {
>> + if (LSI->isCaptured(Var))
>> + return LSI->getCapture(Var).isCopyCapture();
>> +
>> + return LSI->ImpCaptureStyle == CapturingScopeInfo::ImpCap_LambdaByval;
>> +}
>> +
>> static bool shouldAddConstQualToVarRef(ValueDecl *D, Sema &S) {
>> VarDecl *var = dyn_cast<VarDecl>(D);
>> if (!var)
>> @@ -2117,7 +2126,8 @@
>> // about decltype hints that it might apply in unevaluated contexts
>> // as well... and there's precent in our blocks implementation.
>> return !LSI->Mutable &&
>> - S.ExprEvalContexts.back().Context != Sema::Unevaluated;
>> + S.ExprEvalContexts.back().Context != Sema::Unevaluated &&
>> + willCaptureByCopy(LSI, var);
>> }
>>
>> static ExprResult BuildBlockDeclRefExpr(Sema &S, ValueDecl *VD,
>>
>> Modified: cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp?rev=150088&r1=150087&r2=150088&view=diff
>> ==============================================================================
>> --- cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp (original)
>> +++ cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp Wed Feb 8 14:56:50 2012
>> @@ -6,7 +6,40 @@
>> // expected-error{{lambda expressions are not supported yet}}
>> }
>>
>> -// FIXME: Also check translation of captured vars to data members,
>> -// most of which isn't in the AST.
>> +// Check that we get the right types of captured variables (the semantic-analysis part of
>
> Did part of this comment go missing?
Committee meetings are bad for continuous trains of thought... r150090.
- Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120208/db8728ae/attachment.html>
More information about the cfe-commits
mailing list