Files
carbon-lang/toolchain/sem_ir/expr_info.h
T
Geoff Romer 4329a83e4c Form-aware textual format for return parameters and arguments (#6588)
The key changes are:
- Function output parameters are now prefixed with `out`, and more
consistently formatted as named parameters.
- Function and inst output arguments are now written as part of the inst
form, rather than as one of the inst arguments.

As a drive-by fix, this also changes `Temporary::storage_id` from
`DestInstId` to `InstId`, because it doesn't represent an output
parameter of the `Temporary` inst itself.

See the review of
[#6532](https://github.com/carbon-language/carbon-lang/pull/6532) and
[this Discord
discussion](https://discord.com/channels/655572317891461132/999638000126394370/1458268977020141589)
for additional background.
2026-01-14 23:27:21 +00:00

35 lines
1.3 KiB
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef CARBON_TOOLCHAIN_SEM_IR_EXPR_INFO_H_
#define CARBON_TOOLCHAIN_SEM_IR_EXPR_INFO_H_
#include <cstdint>
#include "toolchain/sem_ir/file.h"
#include "toolchain/sem_ir/ids.h"
#include "toolchain/sem_ir/inst_kind.h"
namespace Carbon::SemIR {
// Returns the expression category for an instruction.
auto GetExprCategory(const File& file, InstId inst_id) -> ExprCategory;
// Returns whether the given expression category is for a reference expression.
inline auto IsRefCategory(ExprCategory cat) -> bool {
return cat == ExprCategory::DurableRef || cat == ExprCategory::EphemeralRef;
}
// Given a primitive-form initializing expression, find its return slot
// argument. If `allow_transitive` is true, the result may be an argument to
// some other inst whose outcome is forwarded by `init_id`; otherwise the result
// must be an argument to `init_id` itself. Returns `None` if no such return
// slot is found.
auto FindReturnSlotArgForInitializer(const File& sem_ir, InstId init_id,
bool allow_transitive = true) -> InstId;
} // namespace Carbon::SemIR
#endif // CARBON_TOOLCHAIN_SEM_IR_EXPR_INFO_H_