mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-14 09:38:35 +00:00
C++ interop used `GetFormatted` to turn a Carbon name into a C++ name. For an identifier that is a Carbon keyword, such as `base`, `GetFormatted` adds an `r#` prefix, so the C++ name came out as `r#base` instead of `base`. This showed up in three places: - A failed call to the C++ function `base` was reported as "no matching function for call to 'r#base'". - An exported Carbon function was mangled as `_ZN6CarbonL6r#baseEv` instead of `_ZN6CarbonL4baseEv`. - Its thunk was named `r#base__carbon_thunk` instead of `base__carbon_thunk`. All three now use `GetClangIdentifierInfo`, which `export.cpp` already uses for other C++ names. The name is always an identifier in these places: an overload set is only imported by looking up an identifier in C++, and only functions declared in Carbon are exported, which are always named by an identifier. So they check for an identifier, as the export of a class name already does, rather than falling back to `GetFormatted`. This removes a TODO about naming a `NameId::CppOperator` overload set, which can't happen: C++ operators are resolved in `operators.cpp` without an overload set. Assisted-by: Claude Code