Introduce a Clang diagnostic instruction and use it to point to C++ source locations on Clang errors and warnings (#5262)

Introduce `ImportIRId::Cpp` and refer to clang source location in its
`ImportIRInst`.

Part of #5245.
This commit is contained in:
Boaz Brickner
2025-04-25 13:05:45 +00:00
committed by GitHub
parent 1e2d4c3405
commit 609ccefd18
29 changed files with 487 additions and 267 deletions
+6 -5
View File
@@ -15,7 +15,8 @@ static auto FollowImportRef(
const File*& cursor_ir, InstId& cursor_inst_id,
ImportIRInstId import_ir_inst_id) -> void {
auto import_ir_inst = cursor_ir->import_ir_insts().Get(import_ir_inst_id);
const auto& import_ir = cursor_ir->import_irs().Get(import_ir_inst.ir_id);
CARBON_CHECK(import_ir_inst.ir_id() != ImportIRId::Cpp);
const auto& import_ir = cursor_ir->import_irs().Get(import_ir_inst.ir_id());
CARBON_CHECK(import_ir.decl_id.has_value(),
"If we get `None` locations here, we may need to more "
"thoroughly track ImportDecls.");
@@ -31,9 +32,9 @@ static auto FollowImportRef(
auto implicit_import_ir_inst =
cursor_ir->import_ir_insts().Get(import_loc_id.import_ir_inst_id());
const auto& implicit_ir =
cursor_ir->import_irs().Get(implicit_import_ir_inst.ir_id);
auto implicit_loc_id =
implicit_ir.sem_ir->insts().GetLocId(implicit_import_ir_inst.inst_id);
cursor_ir->import_irs().Get(implicit_import_ir_inst.ir_id());
auto implicit_loc_id = implicit_ir.sem_ir->insts().GetLocId(
implicit_import_ir_inst.inst_id());
CARBON_CHECK(implicit_loc_id.kind() == SemIR::LocId::Kind::NodeId,
"Should only be one layer of implicit imports");
absolute_node_ids.push_back(
@@ -54,7 +55,7 @@ static auto FollowImportRef(
}
cursor_ir = import_ir.sem_ir;
cursor_inst_id = import_ir_inst.inst_id;
cursor_inst_id = import_ir_inst.inst_id();
}
// Returns true if this is the final parse node location. If the location is is