mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 10:21:04 +01:00
Implement Iterate for types that implement CppRangeForIterate (#7294)
This change adds rudimentary support for C++ ranges in Carbon range-for loops. Since C++ ranges are exposed through `Core.Iterate`, C++ ranges have the same limitations as Carbon ranges (e.g. can't return references). `Iterate.CursorType` now requires `Destroy`, since types that implement `CppRangeForIterate` can't be used in range-for loops unless their cursor type can be verifiably destructible.
This commit is contained in:
@@ -70,6 +70,13 @@ auto GetCppLocation(Context& context, SemIR::LocId loc_id)
|
||||
final_node.clang_source_loc_id());
|
||||
}
|
||||
|
||||
if (!final_node.node_id().has_value()) {
|
||||
// A non-existent NodeID implies our C++ is compiler-synthesised. Synthetic
|
||||
// code doesn't have a physical source location to retrieve, so the Clang
|
||||
// mapping is empty.
|
||||
return clang::SourceLocation();
|
||||
}
|
||||
|
||||
// This is a location in Carbon code; get or create a corresponding file in
|
||||
// Clang and build a corresponding location.
|
||||
auto [ir, start_loc] = GetFileInfo(context, final_node.check_ir_id());
|
||||
|
||||
Reference in New Issue
Block a user