History log of /external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
651f13cea278ec967336033dd032faef0e9fc2ec 24-Apr-2014 Stephen Hines <srhines@google.com> Updated to Clang 3.5a.

Change-Id: I8127eb568f674c2e72635b639a3295381fe8af82
/external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
b7accd0f5690bdeb4bfa23380f33b0c38bfb4e52 05-Dec-2013 Bill Wendling <isanbard@gmail.com> Merging r196423:
------------------------------------------------------------------------
r196423 | faisalv | 2013-12-04 14:43:08 -0800 (Wed, 04 Dec 2013) | 17 lines

Fix for PR18052 - Lambdas within NSDMI's and default arguments in Nested classes.

Clang currently croaks on the following:
struct X1 {
struct X2 {
int L = ([] (int i) { return i; })(2);
};
};

asserting that the containing lexical context of the lambda is not Sema's cur context, when pushing the lambda's decl context on.

This occurs because (prior to this patch) getContainingDC always returns the non-nested class for functions at class scope (even for inline member functions of nested classes (to account for delayed parsing of their bodies)). The patch addresses this by having getContainingDC always return the lexical DC for a lambda's call operator.

Link to the bug: http://llvm.org/bugs/show_bug.cgi?id=18052
Link to Richard Smith's feedback on phabricator: http://llvm-reviews.chandlerc.com/D2331

Thanks!
------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@196469 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
394558e6a1329b791de69d0fc7c618eac0dbc982 12-Nov-2013 Faisal Vali <faisalv@yahoo.com> A quick fix to PR17877 that was introduced by r194188 (generic-lambda-capturing) that broke libc++.

See http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-November/033369.html for discussion on cfe-dev.

This fix explicitly checks whether we are within the declcontext of a lambda's call operator - which is what I had intended to be true (and assumed would be true if getCurLambda returns a valid pointer) before checking whether a lambda can capture the potential-captures of the innermost lambda.

A deeper fix (that addresses why getCurLambda() returns a valid pointer when perhaps it shouldn't?) - as proposed by Richard Smith in http://llvm.org/bugs/show_bug.cgi?id=17877 - has been suggested as a FIXME.

Patch was LGTM'd by Richard (just barely :)

http://llvm-reviews.chandlerc.com/D2144

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194448 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
c00e4194296e994efab0e4bf64ca66737850bdf0 07-Nov-2013 Faisal Vali <faisalv@yahoo.com> This patch implements capturing of variables within generic lambdas.

Both Richard and I felt that the current wording in the working paper needed some tweaking - Please see http://llvm-reviews.chandlerc.com/D2035 for additional context and references to core-reflector messages that discuss wording tweaks.

What is implemented is what we had intended to specify in Bristol; but, recently felt that the specification might benefit from some tweaking and fleshing.

As a rough attempt to explain the semantics: If a nested lambda with a default-capture names a variable within its body, and if the enclosing full expression that contains the name of that variable is instantiation-dependent - then an enclosing lambda that is capture-ready (i.e. within a non-dependent context) must capture that variable, if all intervening nested lambdas can potentially capture that variable if they need to, and all intervening parent lambdas of the capture-ready lambda can and do capture the variable.

Of note, 'this' capturing is also currently underspecified in the working paper for generic lambdas. What is implemented here is if the set of candidate functions in a nested generic lambda includes both static and non-static member functions (regardless of viability checking - i.e. num and type of parameters/arguments) - and if all intervening nested-inner lambdas between the capture-ready lambda and the function-call containing nested lambda can capture 'this' and if all enclosing lambdas of the capture-ready lambda can capture 'this', then 'this' is speculatively captured by that capture-ready lambda.

Hopefully a paper for the C++ committee (that Richard and I had started some preliminary work on) is forthcoming.

This essentially makes generic lambdas feature complete, except for known bugs. The more prominent ones (and the ones I am currently aware of) being:
- generic lambdas and init-captures are broken - but a patch that fixes this is already in the works ...
- nested variadic expansions such as:
auto K = [](auto ... OuterArgs) {
vp([=](auto ... Is) {
decltype(OuterArgs) OA = OuterArgs;
return 0;
}(5)...);
return 0;
};
auto M = K('a', ' ', 1, " -- ", 3.14);
currently cause crashes. I think I know how to fix this (since I had done so in my initial implementation) - but it will probably take some work and back & forth with Doug and Richard.

A warm thanks to all who provided feedback - and especially to Doug Gregor and Richard Smith for their pivotal guidance: their insight and prestidigitation in such matters is boundless!

Now let's hope this commit doesn't upset the buildbot gods ;)

Thanks!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194188 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
32b5ca012c42d418c9ff0d4175b17f174459e187 01-Nov-2013 Faisal Vali <faisalv@yahoo.com> Support return type deduction for templates in -fdelayed-template-parsing (microsoft) mode

Please see http://llvm-reviews.chandlerc.com/D2053 for discussion and Richard's stamp.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193849 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
9bd1c1332f7b2a82ed7b328b216a35a299a5945a 25-Oct-2013 Faisal Vali <faisalv@yahoo.com> Refactor: Extract specializing the generic lambda call operator during conversion to fptr deduction into its own function.

No functionality change.

All clang regression tests pass.

Thanks!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193383 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
c4fe0a62ad5909c996b4edaa725772c0116b7dea 24-Oct-2013 Faisal Vali <faisalv@yahoo.com> Fix a test file option from -emit-llvm -o to -emit-llvm-only.

As requested by Rafael Espindola here: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20131021/091556.html


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193296 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
605f91ffd18f35ffcb5fcdd38379bd09b67a6cb8 24-Oct-2013 Faisal Vali <faisalv@yahoo.com> Fix an instantiation bug with nested generic lambdas and conversion to fptrs.

This patch fixes the typelocs of the conversion-operator and the conversion-operator-name and adds the parameters of the call operator to the FunctionProtoTypeLoc of the respective entities. Thus, when the template declarations (conversion operators) undergo deduction and instantiation/transformation/substitution - they add themselves to the local instantiation scope if needed.

This patch supports the following:

auto L = [](auto b) {
return [](auto a) ->decltype(a) { return a; };
};
int (*fp)(int) = L(8);

Richard LGTM'd this patch: http://llvm-reviews.chandlerc.com/D1831

Thanks!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193294 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
a3d311e468bce37defb97ed75105f8d36942b651 23-Oct-2013 Faisal Vali <faisalv@yahoo.com> And Again: Teach TreeTransform how to transform nested generic lambdas.


A previous attempt http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130930/090049.html resulted in PR 17476, and was reverted,

The original TransformLambdaExpr (pre generic-lambdas) transformed the TypeSourceInfo of the Call operator in its own instantiation scope via TransformType. This resulted in the parameters of the call operator being mapped to their transformed counterparts in an instantiation scope that would get popped off.
Then a call to TransformFunctionParameters would add the parameters and their transformed mappings (but newly created ones!) to the current instantiation scope. This would result in a disconnect between the new call operator's TSI parameters and those used to construct the call operator declaration. This was ok in the non-generic lambda world - but would cause issues with nested transformations (when non-generic and generics were interleaved) in the generic lambda world - that I somewhat kludged around initially - but this resulted in PR17476.

The new approach seems cleaner. We only do the transformation of the TypeSourceInfo - but we make sure to do it in the current instantiation scope so we don't lose the untransformed to transformed mappings of the ParmVarDecls when they get created.

Another attempt caused a test to fail (http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20131021/091533.html) and also had to be reverted - my apologies - in my haste, i did not run all the tests - argh!

Now all the tests seem to pass - but a Fixme has been added - since I suspect Richard will find the fix a little inelegant ;) I shall try and work on a more elegant fix once I have had a chance to discuss with Richard or Doug at a later date.

Hopefully the third time;s a charm *fingers crossed*

This does not yet include capturing.

Please see test file for examples.

This patch was LGTM'd by Doug:
http://llvm-reviews.chandlerc.com/D1784



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193230 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
80f2b2e693422f84ec3735f16a08614a527b0bc5 23-Oct-2013 Rafael Espindola <rafael.espindola@gmail.com> Revert r193223 and r193216.

They were causing CodeGenCXX/mangle-exprs.cpp to fail.

Revert "Remove the circular reference to LambdaExpr in CXXRecordDecl."

Revert "Again: Teach TreeTransform and family how to transform generic lambdas nested within templates and themselves."

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193226 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
b814a2ac581f7aa31aeef1abb8567ea123a13519 23-Oct-2013 Faisal Vali <faisalv@yahoo.com> Again: Teach TreeTransform and family how to transform generic
lambdas nested within templates and themselves.

A previous attempt http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130930/090049.html resulted in PR 17476, and was reverted,


The original TransformLambdaExpr (pre generic-lambdas) transformed the TypeSourceInfo of the Call operator in its own instantiation scope via TransformType. This resulted in the parameters of the call operator being mapped to their transformed counterparts in an instantiation scope that would get popped off.
Then a call to TransformFunctionParameters would add the parameters and their transformed mappings (but newly created ones!) to the current instantiation scope. This would result in a disconnect between the new call operator's TSI parameters and those used to construct the call operator declaration. This was ok in the non-generic lambda world - but would cause issues with nested transformations (when non-generic and generics were interleaved) in the generic lambda world - that I somewhat kludged around initially - but this resulted in PR17476.

The new approach seems cleaner. We only do the transformation of the TypeSourceInfo - but we make sure to do it in the current instantiation scope so we don't lose the untransformed to transformed mappings of the ParmVarDecls when they get created.

This does not yet include capturing.

Please see test file for examples.

This patch was LGTM'd by Doug:
http://llvm-reviews.chandlerc.com/D1784


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193216 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
f003acd8e7bdb994743dc8ea64f90db5360a8b4a 04-Oct-2013 Rafael Espindola <rafael.espindola@gmail.com> Revert "Teach TreeTransform and family how to transform generic lambdas within templates and nested within themselves."

This reverts commit r191879. It caused llvm.org/pr17476.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191955 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
618c28547a7f7cc785a6c6301f79febf5a584f9e 03-Oct-2013 Faisal Vali <faisalv@yahoo.com> Teach TreeTransform and family how to transform generic lambdas within templates and nested within themselves.

This does not yet include capturing (that is next).

Please see test file for examples.

This patch was LGTM'd by Doug:
http://llvm-reviews.chandlerc.com/D1784
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130930/090048.html

When I first committed this patch - a bunch of buildbots were unable to compile the code that VS2010 seemed to compile. Seems like there was a dependency on Sema/Template.h which VS did not seem to need, but I have now added for the other compilers. It still compiles on Visual Studio 2010 - lets hope the buildbots remain quiet (please!)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191879 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
9683f1de5f8eb3a4dd7c7fcb4ff58033b9cfa46f 03-Oct-2013 Faisal Vali <faisalv@yahoo.com> Revert changes from the nested lambdas commit till i figure out
why the buildbots are failing.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191876 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
aecbb9de3bed4372695756f18af2c1304a81e7c4 03-Oct-2013 Faisal Vali <faisalv@yahoo.com> Teach TreeTransform and family how to transform generic lambdas within templates and nested within themselves.

This does not yet include capturing (that is next).

Please see test file for examples.

This patch was LGTM'd by Doug:
http://llvm-reviews.chandlerc.com/D1784


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191875 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
d6992ab33b7113e1bd7af51c0c52d17c23706c01 29-Sep-2013 Faisal Vali <faisalv@yahoo.com> Implement conversion to function pointer for generic lambdas without captures.

The general strategy is to create template versions of the conversion function and static invoker and then during template argument deduction of the conversion function, create the corresponding call-operator and static invoker specializations, and when the conversion function is marked referenced generate the body of the conversion function using the corresponding static-invoker specialization. Similarly, Codegen does something similar - when asked to emit the IR for a specialized static invoker of a generic lambda, it forwards emission to the corresponding call operator.

This patch has been reviewed in person both by Doug and Richard. Richard gave me the LGTM.

A few minor changes:
- per Richard's request i added a simple check to gracefully inform that captures (init, explicit or default) have not been added to generic lambdas just yet (instead of the assertion violation).
- I removed a few lines of code that added the call operators instantiated parameters to the currentinstantiationscope. Not only did it not handle parameter packs, but it is more relevant in the patch for nested lambdas which will follow this one, and fix that problem more comprehensively.
- Doug had commented that the original implementation strategy of using the TypeSourceInfo of the call operator to create the static-invoker was flawed and allowed const as a member qualifier to creep into the type of the static-invoker. I currently kludge around it - but after my initial discussion with Doug, with a follow up session with Richard, I have added a FIXME so that a more elegant solution that involves the use of TrivialTypeSourceInfo call followed by the correct wiring of the template parameters to the functionprototypeloc is forthcoming.

Thanks!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191634 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp