expr_info.h 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TOOLCHAIN_SEM_IR_EXPR_INFO_H_
  5. #define CARBON_TOOLCHAIN_SEM_IR_EXPR_INFO_H_
  6. #include <cstdint>
  7. #include "toolchain/sem_ir/file.h"
  8. #include "toolchain/sem_ir/ids.h"
  9. #include "toolchain/sem_ir/inst_kind.h"
  10. namespace Carbon::SemIR {
  11. // Returns the expression category for an instruction.
  12. auto GetExprCategory(const File& file, InstId inst_id) -> ExprCategory;
  13. // Returns whether the given expression category is for a reference expression.
  14. inline auto IsRefCategory(ExprCategory cat) -> bool {
  15. return cat == ExprCategory::DurableRef || cat == ExprCategory::EphemeralRef;
  16. }
  17. // Given an initializing expression, find its return slot argument. Returns
  18. // `None` if there is no return slot, because the initialization is not
  19. // performed in place.
  20. auto FindReturnSlotArgForInitializer(const File& sem_ir, InstId init_id)
  21. -> InstId;
  22. } // namespace Carbon::SemIR
  23. #endif // CARBON_TOOLCHAIN_SEM_IR_EXPR_INFO_H_