This is an archive of the discontinued LLVM Phabricator instance.

[clang][Interp] Add back Run() call
ClosedPublic

Authored by tbaeder on Dec 28 2022, 3:07 AM.

Details

Summary
We need to run the functions we compiled immediately after to check if
they can ever be a constant expression.

I removed this before, thinking it was unneeded. Turns out it is needed to get the "constexpr function never produces a constant expression" diagnostics.

Diff Detail

Event Timeline

tbaeder created this revision.Dec 28 2022, 3:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 28 2022, 3:07 AM
tbaeder requested review of this revision.Dec 28 2022, 3:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 28 2022, 3:07 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
shafik added inline comments.Jan 12 2023, 1:45 PM
clang/lib/AST/Interp/Interp.h
1314

Why did you add these checks calling checkingPotentialConstantExpression for?

tbaeder added inline comments.Jan 12 2023, 9:32 PM
clang/lib/AST/Interp/Interp.h
1314

The RVO pointer needs to be on the stack when calling a function (much like the this pointer). In the context of the Run call after compiling a function, it cannot exist and so we can't return anything here. This is similar to the pre-existing check in This() just above this function.

shafik accepted this revision.Jan 13 2023, 8:11 AM

LGTM

clang/lib/AST/Interp/Interp.h
1314

Ahhh that makes sense. Can you add some comments, not sure where the right place is b/c this feels very opaque and I am not sure how I would figure this out otherwise.

This revision is now accepted and ready to land.Jan 13 2023, 8:11 AM
This revision was landed with ongoing or failed builds.Jan 25 2023, 8:02 AM
This revision was automatically updated to reflect the committed changes.