stringify.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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_STRINGIFY_H_
  5. #define CARBON_TOOLCHAIN_SEM_IR_STRINGIFY_H_
  6. #include "toolchain/sem_ir/file.h"
  7. #include "toolchain/sem_ir/ids.h"
  8. namespace Carbon::SemIR {
  9. // Produces a string version of an instruction with a constant value. Generally,
  10. // this should not be called directly. To format a constant value into a
  11. // diagnostic, use a diagnostic parameter of type `InstIdAsConstant`. When the
  12. // constant value is a type, use `InstIdAsType`, `InstIdAsRawType`, or
  13. // `TypeOfInstId` where possible, or of type `TypeId` or `TypeIdAsRawType` if
  14. // you don't have an expression describing the type.
  15. auto StringifyConstantInst(const File& sem_ir, InstId outer_inst_id)
  16. -> std::string;
  17. // Produces a string version of the name of a specific. Generally, this should
  18. // not be called directly. To format a string into a diagnostic, use a
  19. // diagnostic parameter of type `SpecificId`.
  20. auto StringifySpecific(const File& sem_ir, SpecificId specific_id)
  21. -> std::string;
  22. // Produces a string version of the name of a specific interface. If the
  23. // interface is not generic, this is just the name of the interface. Otherwise,
  24. // it is the interface name and its generic arguments. Generally, this should
  25. // not be called directly. To format a string into a diagnostic, use a
  26. // diagnostic parameter of type `SpecificInterface`.
  27. auto StringifySpecificInterface(const File& sem_ir,
  28. SpecificInterface specific_interface)
  29. -> std::string;
  30. // Produces a string version of the facet type. This contains the name of the
  31. // interfaces or named constraints that the facet type names, and any
  32. // requirements such as rewrites.
  33. auto StringifyFacetType(const File& sem_ir, FacetTypeId facet_type_id)
  34. -> std::string;
  35. } // namespace Carbon::SemIR
  36. #endif // CARBON_TOOLCHAIN_SEM_IR_STRINGIFY_H_