From f84df3c41d6a5308d9fedd4ba902dd74f7b3364d Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 23 Mar 2026 07:19:41 +0000 Subject: [PATCH] Add comment to clarify the creation of the root "Carbon" namespace --- toolchain/check/cpp/generate_ast.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/toolchain/check/cpp/generate_ast.cpp b/toolchain/check/cpp/generate_ast.cpp index 1502345e23e8..0a0e721823a3 100644 --- a/toolchain/check/cpp/generate_ast.cpp +++ b/toolchain/check/cpp/generate_ast.cpp @@ -399,6 +399,10 @@ auto CarbonExternalASTSource::FindExternalVisibleDeclsByName( scope_mapping.Lookup(const_cast(decl_context)); if (!decl_context_inst_id) { + // If the context doesn't already have a mapping between C++ and Carbon, + // check if this is the root mapping (for the "Carbon" namespace in the + // translation unit scope) and if so, create that mapping. + if (decl_context->getDeclKind() != clang::Decl::Kind::TranslationUnit) { return false; }