Page MenuHomePhabricator

[DO NOT SUBMIT] [Sema] Delay evaluation of std::source_location::current() in default arguments
Needs ReviewPublic

Authored by ilya-biryukov on Aug 30 2022, 7:26 AM.

Details

Reviewers
shafik
Summary

They must be evaluated in the context where default argument is actually
used during a call, not in a parameter list where default argument is specified.

Fixes #56379.

Diff Detail

Event Timeline

ilya-biryukov created this revision.Aug 30 2022, 7:26 AM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: martong. · View Herald Transcript
ilya-biryukov requested review of this revision.Aug 30 2022, 7:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2022, 7:26 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

I think this is superseded by https://cplusplus.github.io/CWG/issues/2631.html and its resolution.
Which I'm looking into implementing - I'll let you know if I manage to get it working (I still have a number of failing tests).
The idea is the same though, we keep a rewritten Expr in CXXDefaultArgExpr.

I think this is superseded by https://cplusplus.github.io/CWG/issues/2631.html and its resolution.
Which I'm looking into implementing - I'll let you know if I manage to get it working (I still have a number of failing tests).
The idea is the same though, we keep a rewritten Expr in CXXDefaultArgExpr.

LG, thanks for taking this over.
We chatted with @rsmith about this and one of the seemingly important optimizations that Richard suggested is to try avoiding the extra rewriting of expressions that don't have any immediate function calls.
Not sure how important this ends being for performance of compiling real code, but may be worth exploring.

martong removed a subscriber: martong.Oct 3 2022, 2:20 AM

The PR for the more general approach (note that it does not solve source location, that will need more additional work) https://reviews.llvm.org/D136554