Include the Carbon package name in the exported C++ namespace. (#7935)

When exporting `X` from Carbon package `Foo`, expose it to C++ with
fully-qualified name `Carbon::Foo::X`, not simply `Carbon::X`. This
ensures that C++ mangled names properly distinguish between same-named
Carbon entities in different packages.

Name *lookup* into `Carbon::` still uses the same rules as before: it
finds what a `package.` lookup would find in Carbon. So `X` is named
from C++ as `Carbon::X` still, and a lookup for `Carbon::Foo` fails,
even though `X`'s "true name" is now `Carbon::Foo::X`.

Assisted-by: Gemini via Antigravity
This commit is contained in:
Richard Smith authored and GitHub committed 2026-10-15 20:26:05 +00:00
1 parent d87891f3a6
commit 09b79784dc
35 files changed
+440 -262

No files matched your search

@@ -97,7 +97,7 @@ void CallEnclosingF() {
// is to test a generic function within an enclosing generic scope.
//
Carbon::EnclosingB b;
// CHECK:STDERR: fail_todo_enclosing_generic.carbon:[[@LINE+2]]:5: error: no member named 'MemberF' in 'Carbon::EnclosingA<int>' [CppInteropParseError]
// CHECK:STDERR: fail_todo_enclosing_generic.carbon:[[@LINE+2]]:5: error: no member named 'MemberF' in 'Carbon::Main::EnclosingA<int>' [CppInteropParseError]
// CHECK:STDERR:
b.MemberF(1, 2);
}