Commit Graph
5 Commits
Author SHA1 Message Date
Richard SmithandChandler Carruth 1013d1773c Model function calls as initializing expressions (#3089)
Start treating function calls as initializing expressions instead of as
value expressions.

This required adding support for expression categories. Value bindings
and temporary materialization conversions are created where necessary to
transition between expression categories. For a function call with a
return slot, we speculatively create a materialized temporary before the
call and either commit to it or replace it with something else later,
once we see how the function call expression is actually used.

This change follows the direction suggested in #3133 for initializing
expressions: depending on the return type of a function, the return
value will either be initialized in-place or returned directly. This is
visible in the semantics IR, which is a little unfortunate but is
probably necessary as this is part of the semantics of the program.

---------

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2023-08-24 19:35:07 +00:00
Richard Smith 0ff5e42b12 Put the IR for the return type in the same block as the IR for the parameters. (#3145)
Previously, IR generated for the computation of the return type ended up
in the package's node block. Put it with the IR for the parameters for
consistency and cleanliness.
2023-08-23 23:38:17 +00:00
Jon Ross-Perkins 2425e28e3a Collapse names into VarStorage (#3116)
This removes BindName, putting name information directly on VarStorage.
As a side-effect of updating semantics_ir_test for this change, I also
noted that function bodies were being generated as invalid YAML so am
fixing that (just `{}` to `[]` bracketing, otherwise the test wouldn't
work anymore).

Because names are now available, I've updated lowering to use them for
vars.

In the SemIR formatter, the name is now repeated because it's a
parameter to VarStorage. I believe this is just default behavior, and
we'd have to special-case VarStorage to remove it because it's automatic
argument printing in action. On the balance, it felt like letting it
print was reasonable.

I've noted in places that the name on VarStorage is expected to be
optional, but am not adding support because I'd have no way of testing
it at present.
2023-08-22 18:55:31 +00:00
Richard Smith d74b8f0497 Fix diagnostic messages that don't end in a period. (#3127) 2023-08-21 23:59:18 +00:00
Farzana Ahmed SiddiqueandFarzana Ahmed Siddique 9228487d46 Semantics for array type (#3087)
Co-authored-by: Farzana Ahmed Siddique <fasiddique@google.com>
2023-08-11 23:06:13 +00:00