Repository: carbon-language/carbon-lang
File: toolchain/sem_ir/ids.h (C/C++)

Code before:
  auto Print(llvm::raw_ostream& out) const -> void { out << "float"; }
};

// An X-macro for special names. Uses should look like:
//
//   #define CARBON_SPECIAL_NAME_ID_FOR_XYZ(Name) ...
//   CARBON_SPECIAL_NAME_ID(CARBON_SPECIAL_NAME_ID_FOR_XYZ)
//   #undef CARBON_SPECIAL_NAME_ID_FOR_XYZ
#define CARBON_SPECIAL_NAME_ID(X)                                \
  /* The name of `base`. */                                      \
  X(Base)                                                        \
  /* The name of the discriminant field (if any) in a choice. */ \
  X(ChoiceDiscriminant)                                          \
  /* The name of the package `Core`. */                          \
  X(Core)                                                        \
  /* The name of `package`. */                                   \
  X(PackageNamespace)                                            \
  /* The name of `.Self`. */                                     \
  X(PeriodSelf)                                                  \
  /* The name of the return slot in a function. */               \
  X(ReturnSlot)                                                  \
  /* The name of `Self`. */                                      \
  X(SelfType)                                                    \
  /* The name of `self`. */                                      \
  X(SelfValue)                                                   \
  /* The name of `_` */                                          \
  X(Underscore)                                                  \
  /* The name of `vptr`. */                                      \
  X(Vptr)

// The ID of a name. A name is either a string or a special name such as
// `self`, `Self`, or `base`.
struct NameId : public IdBase<NameId> {
  static constexpr llvm::StringLiteral Label = "name";

  // names().GetFormatted() is used for diagnostics.
  using DiagnosticType = DiagnosticTypeInfo<std::string>;

  // An enum of special names.
  enum class SpecialNameId : uint8_t {
#define CARBON_SPECIAL_NAME_ID_FOR_ENUM(Name) Name,
    CARBON_SPECIAL_NAME_ID(CARBON_SPECIAL_NAME_ID_FOR_ENUM)
#undef CARBON_SPECIAL_NAME_ID_FOR_ENUM
  };

  // For each SpecialNameId, provide a matching `NameId` instance for
  // convenience.
#define CARBON_SPECIAL_NAME_ID_FOR_DECL(Name) static const NameId Name;
  CARBON_SPECIAL_NAME_ID(CARBON_SPECIAL_NAME_ID_FOR_DECL)
#undef CARBON_SPECIAL_NAME_ID_FOR_DECL


Review comment (suggestion):
```suggestion
  /* The name of `_`. */                                         \
```

Code after:
  auto Print(llvm::raw_ostream& out) const -> void { out << "float"; }
};

// An X-macro for special names. Uses should look like:
//
//   #define CARBON_SPECIAL_NAME_ID_FOR_XYZ(Name) ...
//   CARBON_SPECIAL_NAME_ID(CARBON_SPECIAL_NAME_ID_FOR_XYZ)
//   #undef CARBON_SPECIAL_NAME_ID_FOR_XYZ
#define CARBON_SPECIAL_NAME_ID(X)                                \
  /* The name of `base`. */                                      \
  X(Base)                                                        \
  /* The name of the discriminant field (if any) in a choice. */ \
  X(ChoiceDiscriminant)                                          \
  /* The name of the package `Core`. */                          \
  X(Core)                                                        \
  /* The name of `destroy`. */                                   \
  X(Destroy)                                                     \
  /* The name of `package`. */                                   \
  X(PackageNamespace)                                            \
  /* The name of `.Self`. */                                     \
  X(PeriodSelf)                                                  \
  /* The name of the return slot in a function. */               \
  X(ReturnSlot)                                                  \
  /* The name of `Self`. */                                      \
  X(SelfType)                                                    \
  /* The name of `self`. */                                      \
  X(SelfValue)                                                   \
  /* The name of `_`. */                                         \
  X(Underscore)                                                  \
  /* The name of `vptr`. */                                      \
  X(Vptr)

// The ID of a name. A name is either a string or a special name such as
// `self`, `Self`, or `base`.
struct NameId : public IdBase<NameId> {
  static constexpr llvm::StringLiteral Label = "name";

  // names().GetFormatted() is used for diagnostics.
  using DiagnosticType = DiagnosticTypeInfo<std::string>;

  // An enum of special names.
  enum class SpecialNameId : uint8_t {
#define CARBON_SPECIAL_NAME_ID_FOR_ENUM(Name) Name,
    CARBON_SPECIAL_NAME_ID(CARBON_SPECIAL_NAME_ID_FOR_ENUM)
#undef CARBON_SPECIAL_NAME_ID_FOR_ENUM
  };

  // For each SpecialNameId, provide a matching `NameId` instance for
  // convenience.
#define CARBON_SPECIAL_NAME_ID_FOR_DECL(Name) static const NameId Name;
  CARBON_SPECIAL_NAME_ID(CARBON_SPECIAL_NAME_ID_FOR_DECL)