|
@@ -453,6 +453,12 @@ static auto BuildClassDefinition(Context& context,
|
|
|
return {class_id, class_inst_id};
|
|
return {class_id, class_inst_id};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// Mark the given `Decl` as failed in `clang_decls`.
|
|
|
|
|
+static auto MarkFailedDecl(Context& context, clang::Decl* clang_decl) {
|
|
|
|
|
+ context.sem_ir().clang_decls().Add(
|
|
|
|
|
+ {.decl = clang_decl, .inst_id = SemIR::ErrorInst::InstId});
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// Imports a record declaration from Clang to Carbon. If successful, returns
|
|
// Imports a record declaration from Clang to Carbon. If successful, returns
|
|
|
// the new Carbon class declaration `InstId`.
|
|
// the new Carbon class declaration `InstId`.
|
|
|
// TODO: Change `clang_decl` to `const &` when lookup is using `clang::DeclID`
|
|
// TODO: Change `clang_decl` to `const &` when lookup is using `clang::DeclID`
|
|
@@ -466,11 +472,13 @@ static auto ImportCXXRecordDecl(Context& context, SemIR::LocId loc_id,
|
|
|
if (!clang_def) {
|
|
if (!clang_def) {
|
|
|
context.TODO(loc_id,
|
|
context.TODO(loc_id,
|
|
|
"Unsupported: Record declarations without a definition");
|
|
"Unsupported: Record declarations without a definition");
|
|
|
|
|
+ MarkFailedDecl(context, clang_decl);
|
|
|
return SemIR::ErrorInst::InstId;
|
|
return SemIR::ErrorInst::InstId;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (clang_def->isDynamicClass()) {
|
|
if (clang_def->isDynamicClass()) {
|
|
|
context.TODO(loc_id, "Unsupported: Dynamic Class");
|
|
context.TODO(loc_id, "Unsupported: Dynamic Class");
|
|
|
|
|
+ MarkFailedDecl(context, clang_decl);
|
|
|
return SemIR::ErrorInst::InstId;
|
|
return SemIR::ErrorInst::InstId;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -717,14 +725,17 @@ static auto ImportFunctionDecl(Context& context, SemIR::LocId loc_id,
|
|
|
-> SemIR::InstId {
|
|
-> SemIR::InstId {
|
|
|
if (clang_decl->isVariadic()) {
|
|
if (clang_decl->isVariadic()) {
|
|
|
context.TODO(loc_id, "Unsupported: Variadic function");
|
|
context.TODO(loc_id, "Unsupported: Variadic function");
|
|
|
|
|
+ MarkFailedDecl(context, clang_decl);
|
|
|
return SemIR::ErrorInst::InstId;
|
|
return SemIR::ErrorInst::InstId;
|
|
|
}
|
|
}
|
|
|
if (!clang_decl->isGlobal()) {
|
|
if (!clang_decl->isGlobal()) {
|
|
|
context.TODO(loc_id, "Unsupported: Non-global function");
|
|
context.TODO(loc_id, "Unsupported: Non-global function");
|
|
|
|
|
+ MarkFailedDecl(context, clang_decl);
|
|
|
return SemIR::ErrorInst::InstId;
|
|
return SemIR::ErrorInst::InstId;
|
|
|
}
|
|
}
|
|
|
if (clang_decl->getTemplatedKind() != clang::FunctionDecl::TK_NonTemplate) {
|
|
if (clang_decl->getTemplatedKind() != clang::FunctionDecl::TK_NonTemplate) {
|
|
|
context.TODO(loc_id, "Unsupported: Template function");
|
|
context.TODO(loc_id, "Unsupported: Template function");
|
|
|
|
|
+ MarkFailedDecl(context, clang_decl);
|
|
|
return SemIR::ErrorInst::InstId;
|
|
return SemIR::ErrorInst::InstId;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -740,6 +751,7 @@ static auto ImportFunctionDecl(Context& context, SemIR::LocId loc_id,
|
|
|
context.scope_stack().Pop();
|
|
context.scope_stack().Pop();
|
|
|
|
|
|
|
|
if (!function_params_insts.has_value()) {
|
|
if (!function_params_insts.has_value()) {
|
|
|
|
|
+ MarkFailedDecl(context, clang_decl);
|
|
|
return SemIR::ErrorInst::InstId;
|
|
return SemIR::ErrorInst::InstId;
|
|
|
}
|
|
}
|
|
|
|
|
|