Skip to content

[Carbon/C++ interop] Add support for C++ type short #5393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions toolchain/check/import_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,15 @@ static auto MakeIntType(Context& context, IntId size_id) -> TypeExpr {
return ExprAsType(context, Parse::NodeId::None, type_inst_id);
}

// Maps a C++ type to a Carbon type. Currently only 32-bit `int` and 16-bit
// `short` are supported.
// Maps a C++ type to a Carbon type.
// TODO: Support more types.
static auto MapType(Context& context, clang::QualType type) -> TypeExpr {
const auto* builtin_type = dyn_cast<clang::BuiltinType>(type);
if (!builtin_type) {
return {.inst_id = SemIR::ErrorInst::TypeInstId,
.type_id = SemIR::ErrorInst::TypeId};
}
// TODO: Refactor to avoid duplication.
switch (builtin_type->getKind()) {
case clang::BuiltinType::Short:
if (context.ast_context().getTypeSize(type) == 16) {
Expand Down Expand Up @@ -481,8 +481,8 @@ static auto ImportFunctionDecl(Context& context, SemIR::LocId loc_id,
return decl_id;
}

// Imports a namespace declaration from Clang to Carbon. If successful,
// returns the new Carbon namespace declaration `InstId`.
// Imports a namespace declaration from Clang to Carbon. If successful, returns
// the new Carbon namespace declaration `InstId`.
static auto ImportNamespaceDecl(Context& context,
SemIR::NameScopeId parent_scope_id,
SemIR::NameId name_id,
Expand Down
Loading