Reverse Interop: Nested namespace support (#6940)

Start recording the clang::DeclContext* -> InstId mapping for use in
later operations.

The test update includes removing the initial fail_* test because I
hadn't thought about the use of namespace aliases as a way to test for
the presence of a namespace without the failure caused by not finding
the thing inside the namespace.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
David Blaikie
2026-03-24 19:55:25 +00:00
committed by GitHub
co-authored by Jon Ross-Perkins
parent f9e1806c4a
commit 2af5f971da
2 changed files with 59 additions and 35 deletions
+4 -15
View File
@@ -10,23 +10,10 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/reverse/simple.carbon
// --- fail_simple.carbon
library "[[@TEST_NAME]]";
// Demonstrate that the 'Carbon' namespace has been injected into the C++ compilation.
import Cpp inline '''
// CHECK:STDERR: fail_simple.carbon:[[@LINE+4]]:9: error: no type named 'NonExistent' in namespace 'Carbon' [CppInteropParseError]
// CHECK:STDERR: 11 | Carbon::NonExistent v;
// CHECK:STDERR: | ~~~~~~~~^
// CHECK:STDERR:
Carbon::NonExistent v;
''';
// --- other.carbon
package Other;
namespace Nested;
namespace Nested.Again;
// --- namespace.carbon
library "[[@TEST_NAME]]";
@@ -34,4 +21,6 @@ library "[[@TEST_NAME]]";
import Other;
import Cpp inline '''
namespace X = Carbon::Other;
namespace Y = Carbon::Other::Nested;
namespace Z = Carbon::Other::Nested::Again;
''';