Add support for C++14 generic lambdas
Generic lambdas are a C++14 language feature: https://isocpp.org/wiki/faq/cpp14-language#generic-lambdas
This patch proposes an implementation for feature request frama-c#2561 (closed) . It's a major overhaul of the lambda processing infrastructure in the plugin. That's necessary because C++14 generic lambdas extend the C++11 lambda concept fundamentally: Not only can function parameter types now be declared as auto
and deduced at compile time, they can also be deduced to different types for different invocations. Conceptually this means that the compiler-generated entity that represents a lambda can now have multiple overloaded call operators. This has wide-ranging implications:
-
Lambda
nodes in the intermediate AST convey a list signatures of now -
LambdaExpr
nodes define a list of overloads now and each of them has a unique identifier (IDs) -
Lambda_call
nodes store the IDs for their respective overload - Mangling for
Lambda
types accounts for all overloaded signatures now - All function names emitted during code generation encode the IDs in order to prevent collisions
- Code generation for initialization tasks is split into:
- inits that happen once: instantiate a local helper variable and initialize captures in the struct
- inits that happen for each overload: generate the body and assign the matching function pointer in the struct
Edited by Stefan Gränitz