cpp_initializer_list.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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_CPP_INITIALIZER_LIST_H_
  5. #define CARBON_TOOLCHAIN_SEM_IR_CPP_INITIALIZER_LIST_H_
  6. #include "toolchain/sem_ir/ids.h"
  7. namespace Carbon::SemIR {
  8. class File;
  9. // The layout of `std::initializer_list` that we are dealing with.
  10. struct StdInitializerListLayout {
  11. enum Kind : int8_t {
  12. // Not a recognized layout.
  13. None,
  14. // `struct { T* begin; T* end; }`
  15. PointerPointer,
  16. // `struct { T* begin; size_t size; }`
  17. PointerInt,
  18. };
  19. Kind kind = Kind::None;
  20. // If the kind is PointerInt, the type of the size.
  21. TypeId size_type_id = TypeId::None;
  22. };
  23. // Returns the kind of `std::initializer_list` that `type_id` represents, or
  24. // `None` if it is not a `std::initializer_list`. This does not verify that
  25. // `type_id` is actually a type named `std::initializer_list`, only that it has
  26. // a recognized set of fields that allows us to treat it as one.
  27. auto GetStdInitializerListLayout(const File& sem_ir, TypeId type_id)
  28. -> StdInitializerListLayout;
  29. } // namespace Carbon::SemIR
  30. #endif // CARBON_TOOLCHAIN_SEM_IR_CPP_INITIALIZER_LIST_H_