Page MenuHomePhabricator

[cxx1z-constexpr-lambda] Make conversion function constexpr, and teach the expression-evaluator to evaluate the static-invoker.
ClosedPublic

Authored by faisalv on Jul 30 2016, 7:04 PM.

Details

Summary

This patch enables the following code:

auto L = [](int i) { return i; };
constexpr int (*fpi)(int) = L;
static_assert(fpi(3) == 3);

Diff Detail

Event Timeline

faisalv updated this revision to Diff 66235.Jul 30 2016, 7:04 PM
faisalv retitled this revision from to [cxx1z-constexpr-lambda] Make conversion function constexpr, and teach the expression-evaluator to evaluate the static-invoker..
faisalv updated this object.
faisalv set the repository for this revision to rL LLVM.
faisalv added a project: Restricted Project.
faisalv added a subscriber: cfe-commits.
aaron.ballman edited edge metadata.Aug 4 2016, 6:59 AM

Some small nits.

lib/AST/ExprConstant.cpp
4409

Nit: remove new line.

4415

Nit: Capitalize Number.

4416–4417

Asserts should come with explanatory text &&'ed in.

4425

Same here as above (and elsewhere).

faisalv updated this revision to Diff 77767.Nov 13 2016, 7:45 PM
faisalv edited edge metadata.
faisalv removed rL LLVM as the repository for this revision.
faisalv marked 4 inline comments as done.

Addressed Aaron's requests regarding improving formatting and assert messages.

Thanks!

EricWF added a subscriber: EricWF.Nov 14 2016, 2:30 AM
ahatanak added inline comments.
lib/AST/ExprConstant.cpp
4427

Can you just compare iterators here?

ClosureClass->captures_begin() == ClosureClass->captures_end()
faisalv updated this revision to Diff 77926.Nov 14 2016, 5:27 PM
faisalv marked an inline comment as done.

Simplify the check for zero captures in a lambda expression (within the assert) by comparing the begin and end pointers directly (as opposed to using distance) - thanks to Akira!

This revision is now accepted and ready to land.Jan 8 2017, 11:10 AM