mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Store Clang Decls in a CanonicalValueStore (#5638)
Saves space since in most cases, we only need a `None` 32 bits index instead of a null 64 bits pointer. Based on discussions in [Carbon C++ Interop weekly](https://docs.google.com/document/d/1YlxEOJ0r-o19o19TCJbFl4Ln1U88yn_Vj23y1Hr5vTk/edit?tab=t.0#heading=h.23l56bt5xwlu) and Discord ([1](https://discord.com/channels/655572317891461132/768530752592805919/1375121180306047106), [2](https://discord.com/channels/655572317891461132/768530752592805919/1380575881050718469)). Note: Any `clang::DeclContext` is also a `clang::Decl`. Part of #4666.
This commit is contained in:
@@ -670,10 +670,12 @@ auto FileContext::BuildFunctionDecl(SemIR::FunctionId function_id,
|
||||
}
|
||||
|
||||
// If this is a C++ function, tell Clang that we referenced it.
|
||||
if (auto* cpp_decl = sem_ir().functions().Get(function_id).cpp_decl) {
|
||||
if (auto clang_decl_id = sem_ir().functions().Get(function_id).clang_decl_id;
|
||||
clang_decl_id.has_value()) {
|
||||
CARBON_CHECK(!specific_id.has_value(),
|
||||
"Specific functions cannot have C++ definitions");
|
||||
HandleReferencedCppFunction(cpp_decl);
|
||||
HandleReferencedCppFunction(clang::dyn_cast<clang::FunctionDecl>(
|
||||
sem_ir().clang_decls().Get(clang_decl_id)));
|
||||
// TODO: Check that the signature and mangling generated by Clang and the
|
||||
// one we generated are the same.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user