diff --git a/toolchain/check/cpp/export.cpp b/toolchain/check/cpp/export.cpp index c44e8d8a3a44..8ac814b8d4f7 100644 --- a/toolchain/check/cpp/export.cpp +++ b/toolchain/check/cpp/export.cpp @@ -13,6 +13,7 @@ #include "clang/Sema/Sema.h" #include "llvm/Support/Casting.h" #include "toolchain/check/cpp/access.h" +#include "toolchain/check/cpp/context.h" #include "toolchain/check/cpp/import.h" #include "toolchain/check/cpp/location.h" #include "toolchain/check/cpp/type_mapping.h" @@ -90,13 +91,35 @@ static auto ExportClassToCppInDeclContext(Context& context, return record_decl; } +auto ExportPackageNamespaceToCpp(Context& context, + clang::DeclContext* carbon_namespace, + clang::IdentifierInfo* package_identifier) + -> clang::NamespaceDecl* { + auto& package_namespaces = + context.cpp_context()->domain().package_namespaces(); + auto [it, inserted] = + package_namespaces.try_emplace(package_identifier->getName(), nullptr); + if (inserted) { + // TODO: Provide a source location. + auto* namespace_decl = clang::NamespaceDecl::Create( + context.ast_context(), carbon_namespace, /*Inline=*/false, + clang::SourceLocation(), clang::SourceLocation(), package_identifier, + /*PrevDecl=*/nullptr, /*Nested=*/false); + carbon_namespace->addHiddenDecl(namespace_decl); + it->second = namespace_decl; + } + it->second->getPrimaryContext()->setHasExternalVisibleStorage(); + return it->second; +} + auto ExportNameScopeToCpp(Context& context, SemIR::LocId loc_id, SemIR::NameScopeId name_scope_id) -> clang::DeclContext* { llvm::SmallVector name_scope_ids_to_create; // Walk through the parent scopes, looking for one that's already mapped into - // C++. We already mapped the package scope to ::Carbon, so we must find one. + // C++. We already mapped the package scope to ::Carbon::, so we + // must find one. clang::DeclContext* decl_context = nullptr; while (true) { // If this name scope was produced by importing a C++ declaration or has @@ -109,7 +132,16 @@ auto ExportNameScopeToCpp(Context& context, SemIR::LocId loc_id, // Otherwise, continue to the parent and create a scope for it first. name_scope_ids_to_create.push_back(name_scope_id); - name_scope_id = context.name_scopes().Get(name_scope_id).parent_scope_id(); + const auto& name_scope = context.name_scopes().Get(name_scope_id); + if (name_scope.is_imported_package()) { + // Imported packages are exported as sub-namespaces of `::Carbon`, not of + // the current package's sub-namespace. + decl_context = + GetClangDeclContextForScope(context, SemIR::NameScopeId::Package) + ->getParent(); + break; + } + name_scope_id = name_scope.parent_scope_id(); // TODO: What should happen if there's an intervening function scope? CARBON_CHECK( @@ -135,12 +167,17 @@ auto ExportNameScopeToCpp(Context& context, SemIR::LocId loc_id, return nullptr; } - // TODO: Provide a source location. - auto* namespace_decl = clang::NamespaceDecl::Create( - context.ast_context(), decl_context, false, clang::SourceLocation(), - clang::SourceLocation(), identifier_info, nullptr, false); - decl_context->addHiddenDecl(namespace_decl); - decl_context = namespace_decl; + if (name_scope.is_imported_package()) { + decl_context = + ExportPackageNamespaceToCpp(context, decl_context, identifier_info); + } else { + // TODO: Provide a source location. + auto* namespace_decl = clang::NamespaceDecl::Create( + context.ast_context(), decl_context, false, clang::SourceLocation(), + clang::SourceLocation(), identifier_info, nullptr, false); + decl_context->addHiddenDecl(namespace_decl); + decl_context = namespace_decl; + } } else if (auto class_type = context.insts().TryGetAs(const_inst_id)) { const auto& class_info = context.classes().Get(class_type->class_id); diff --git a/toolchain/check/cpp/export.h b/toolchain/check/cpp/export.h index df860e7b6fc3..f97fe51e0524 100644 --- a/toolchain/check/cpp/export.h +++ b/toolchain/check/cpp/export.h @@ -17,6 +17,13 @@ class CXXRecordDecl; namespace Carbon::Check { +// Exports a Carbon package into C++ as a sub-namespace of `carbon_namespace`, +// or returns the existing namespace if already exported in this C++ domain. +auto ExportPackageNamespaceToCpp(Context& context, + clang::DeclContext* carbon_namespace, + clang::IdentifierInfo* package_identifier) + -> clang::NamespaceDecl*; + // Exports a Carbon name scope into C++ as a namespace or class, or returns the // C++ namespace or class declaration that it was imported from. // diff --git a/toolchain/check/cpp/generate_ast.cpp b/toolchain/check/cpp/generate_ast.cpp index a2720d7a87ca..5ae7d2a70932 100644 --- a/toolchain/check/cpp/generate_ast.cpp +++ b/toolchain/check/cpp/generate_ast.cpp @@ -277,15 +277,31 @@ auto CarbonExternalASTSource::BuildCarbonNamespace() -> void { // We provide custom lookup results within this namespace. carbon_cpp_namespace->getPrimaryContext()->setHasExternalVisibleStorage(); - // Register this file's package scope as corresponding to the `Carbon` - // namespace in C++. - // TODO: For mangling purposes, include the package as a sub-namespace. - auto key = SemIR::ClangDeclKey::ForNonFunctionDecl(carbon_cpp_namespace); - auto clang_decl_id = context_->clang_decls().Add( - {.key = key, .inst_id = SemIR::Namespace::PackageInstId}); - context_->name_scopes() - .Get(SemIR::NameScopeId::Package) - .set_clang_decl_context_id(clang_decl_id, /*is_cpp_scope=*/false); + // Create or find the sub-namespace for this file's package, which is used as + // the parent `DeclContext` for package-scope entities so that the package + // name is included in C++ mangled names. + auto& package_scope = + context_->name_scopes().Get(SemIR::NameScopeId::Package); + auto package_name = context_->names().GetIRBaseName(package_scope.name_id()); + auto* package_identifier = &ast_context.Idents.get(package_name); + auto* package_cpp_namespace = ExportPackageNamespaceToCpp( + *context_, carbon_cpp_namespace, package_identifier); + + // Register this file's package scope as corresponding to the package + // sub-namespace in C++, and also map the `Carbon` namespace itself to the + // package scope so that C++ lookups in `Carbon` find package-scope entities + // directly (and do not find the current package name). + auto package_key = + SemIR::ClangDeclKey::ForNonFunctionDecl(package_cpp_namespace); + auto package_clang_decl_id = context_->clang_decls().Add( + {.key = package_key, .inst_id = SemIR::Namespace::PackageInstId}); + package_scope.set_clang_decl_context_id(package_clang_decl_id, + /*is_cpp_scope=*/false); + + auto carbon_key = + SemIR::ClangDeclKey::ForNonFunctionDecl(carbon_cpp_namespace); + context_->clang_decls().Add( + {.key = carbon_key, .inst_id = SemIR::Namespace::PackageInstId}); } auto CarbonExternalASTSource::FindExternalVisibleDeclsByName( diff --git a/toolchain/check/testdata/basics/raw_sem_ir/cpp_interop.carbon b/toolchain/check/testdata/basics/raw_sem_ir/cpp_interop.carbon index 0ea113c5e996..3d579ff6d40e 100644 --- a/toolchain/check/testdata/basics/raw_sem_ir/cpp_interop.carbon +++ b/toolchain/check/testdata/basics/raw_sem_ir/cpp_interop.carbon @@ -55,15 +55,16 @@ fn G(x: Cpp.X) { // CHECK:STDOUT: import_ir_inst5: {ir_id: import_ir(Cpp), clang_source_loc_id: clang_source_loc50000005} // CHECK:STDOUT: import_ir_inst6: {ir_id: import_ir(Cpp), clang_source_loc_id: clang_source_loc50000006} // CHECK:STDOUT: clang_decls: -// CHECK:STDOUT: clang_decl50000000: {key: {decl: "namespace Carbon {\n}"}, inst_id: inst(Package), is_imported: false} -// CHECK:STDOUT: clang_decl50000001: {key: {decl: ""}, inst_id: inst50000011, is_imported: true} -// CHECK:STDOUT: clang_decl50000002: {key: {decl: "struct X {}"}, inst_id: inst50000013, is_imported: true} -// CHECK:STDOUT: clang_decl50000003: {key: {decl: "X * _Nonnull p"}, inst_id: inst50000024, is_imported: true} -// CHECK:STDOUT: clang_decl50000004: {key: {decl: "void f(X x = {})", clang_decl_signature_id: clang_decl_signature50000000}, inst_id: inst5000002F, is_imported: true} -// CHECK:STDOUT: clang_decl50000005: {key: {decl: "inline void f__carbon_thunk()", clang_decl_signature_id: clang_decl_signature50000000}, inst_id: inst50000032, is_imported: true} -// CHECK:STDOUT: clang_decl50000006: {key: {decl: "void f(X x = {})", clang_decl_signature_id: clang_decl_signature50000001}, inst_id: inst5000003D, is_imported: true} -// CHECK:STDOUT: clang_decl50000007: {key: {decl: "inline void f__carbon_thunk(X * _Nonnull x)", clang_decl_signature_id: clang_decl_signature50000001}, inst_id: inst50000047, is_imported: true} -// CHECK:STDOUT: clang_decl50000008: {key: {decl: "X * _Nonnull global"}, inst_id: inst50000052, var_storage_inst_id: inst50000054, is_imported: true} +// CHECK:STDOUT: clang_decl50000000: {key: {decl: "namespace Main {\n}"}, inst_id: inst(Package), is_imported: false} +// CHECK:STDOUT: clang_decl50000001: {key: {decl: "namespace Carbon {\n}"}, inst_id: inst(Package), is_imported: false} +// CHECK:STDOUT: clang_decl50000002: {key: {decl: ""}, inst_id: inst50000011, is_imported: true} +// CHECK:STDOUT: clang_decl50000003: {key: {decl: "struct X {}"}, inst_id: inst50000013, is_imported: true} +// CHECK:STDOUT: clang_decl50000004: {key: {decl: "X * _Nonnull p"}, inst_id: inst50000024, is_imported: true} +// CHECK:STDOUT: clang_decl50000005: {key: {decl: "void f(X x = {})", clang_decl_signature_id: clang_decl_signature50000000}, inst_id: inst5000002F, is_imported: true} +// CHECK:STDOUT: clang_decl50000006: {key: {decl: "inline void f__carbon_thunk()", clang_decl_signature_id: clang_decl_signature50000000}, inst_id: inst50000032, is_imported: true} +// CHECK:STDOUT: clang_decl50000007: {key: {decl: "void f(X x = {})", clang_decl_signature_id: clang_decl_signature50000001}, inst_id: inst5000003D, is_imported: true} +// CHECK:STDOUT: clang_decl50000008: {key: {decl: "inline void f__carbon_thunk(X * _Nonnull x)", clang_decl_signature_id: clang_decl_signature50000001}, inst_id: inst50000047, is_imported: true} +// CHECK:STDOUT: clang_decl50000009: {key: {decl: "X * _Nonnull global"}, inst_id: inst50000052, var_storage_inst_id: inst50000054, is_imported: true} // CHECK:STDOUT: clang_decl_signatures: // CHECK:STDOUT: clang_decl_signature50000000: {kind: normal, num_params: 0} // CHECK:STDOUT: clang_decl_signature50000001: {kind: normal, num_params: 1, modes: [value]} diff --git a/toolchain/check/testdata/interop/cpp/basics/share_ast.carbon b/toolchain/check/testdata/interop/cpp/basics/share_ast.carbon index 8cf7bb60d703..4a280c0e4eed 100644 --- a/toolchain/check/testdata/interop/cpp/basics/share_ast.carbon +++ b/toolchain/check/testdata/interop/cpp/basics/share_ast.carbon @@ -63,3 +63,38 @@ fn CallAIndirect() -> i32 { fn CallB() -> i32 { return Cpp.GetB(); } + +// --- pkg_a.carbon +package PkgA; +import Cpp inline ''' +template void Accept(T) {} +'''; + +class SameName {} + +fn TestPkgA(s: SameName) { + Cpp.Accept(s); +} + +// --- pkg_b.carbon +package PkgB; +import Cpp inline ''' +template void Accept(T) {} +'''; + +class SameName {} + +fn TestPkgB(s: SameName) { + Cpp.Accept(s); +} + +// --- use_both_packages.carbon +library "[[@TEST_NAME]]"; +import PkgA; +import PkgB; +import Cpp inline ''' +// SameName in PkgA and PkgB have distinct C++ DeclContexts (Carbon::PkgA vs +// Carbon::PkgB), so overloading on them in C++ succeeds. +void OverloadByPackage(Carbon::PkgA::SameName*) {} +void OverloadByPackage(Carbon::PkgB::SameName*) {} +'''; diff --git a/toolchain/check/testdata/interop/cpp/class/export/base.carbon b/toolchain/check/testdata/interop/cpp/class/export/base.carbon index 88be42d22e43..0b0540736d77 100644 --- a/toolchain/check/testdata/interop/cpp/class/export/base.carbon +++ b/toolchain/check/testdata/interop/cpp/class/export/base.carbon @@ -87,7 +87,7 @@ abstract class AbstractWithVdtor { } inline Cpp ''' -// CHECK:STDERR: fail_abstract.carbon:[[@LINE+3]]:27: error: variable type 'Carbon::AbstractWithVdtor' is an abstract class [CppInteropParseError] +// CHECK:STDERR: fail_abstract.carbon:[[@LINE+3]]:27: error: variable type 'Carbon::AbstractWithVdtor' (aka 'Carbon::Main::AbstractWithVdtor') is an abstract class [CppInteropParseError] // CHECK:STDERR: fail_abstract.carbon:[[@LINE-6]]:34: note: unimplemented pure virtual method '~AbstractWithVdtor' in 'AbstractWithVdtor' [CppInteropParseNote] // CHECK:STDERR: Carbon::AbstractWithVdtor x; @@ -144,7 +144,7 @@ abstract class AbstractWithMethod { } inline Cpp ''' -// CHECK:STDERR: fail_variable_with_abstract_method.carbon:[[@LINE+3]]:28: error: variable type 'Carbon::AbstractWithMethod' is an abstract class [CppInteropParseError] +// CHECK:STDERR: fail_variable_with_abstract_method.carbon:[[@LINE+3]]:28: error: variable type 'Carbon::AbstractWithMethod' (aka 'Carbon::Main::AbstractWithMethod') is an abstract class [CppInteropParseError] // CHECK:STDERR: fail_variable_with_abstract_method.carbon:[[@LINE-5]]:22: note: unimplemented pure virtual method 'F' in 'AbstractWithMethod' [CppInteropParseNote] // CHECK:STDERR: Carbon::AbstractWithMethod x_abstract; diff --git a/toolchain/check/testdata/interop/cpp/class/export/class.carbon b/toolchain/check/testdata/interop/cpp/class/export/class.carbon index 3fe7e21602e4..7ff6931d6cf1 100644 --- a/toolchain/check/testdata/interop/cpp/class/export/class.carbon +++ b/toolchain/check/testdata/interop/cpp/class/export/class.carbon @@ -64,8 +64,8 @@ import Cpp; class IncompleteConcreteA; inline Cpp ''' -// CHECK:STDERR: fail_incomplete_concrete.carbon:[[@LINE+3]]:29: error: variable has incomplete type 'Carbon::IncompleteConcreteA' [CppInteropParseError] -// CHECK:STDERR: fail_incomplete_concrete.carbon:[[@LINE-4]]:26: note: forward declaration of 'Carbon::IncompleteConcreteA' [CppInteropParseNote] +// CHECK:STDERR: fail_incomplete_concrete.carbon:[[@LINE+3]]:29: error: variable has incomplete type 'Carbon::IncompleteConcreteA' (aka 'Carbon::Main::IncompleteConcreteA') [CppInteropParseError] +// CHECK:STDERR: fail_incomplete_concrete.carbon:[[@LINE-4]]:26: note: forward declaration of 'Carbon::Main::IncompleteConcreteA' [CppInteropParseNote] // CHECK:STDERR: Carbon::IncompleteConcreteA incomplete_concrete_a; '''; diff --git a/toolchain/check/testdata/interop/cpp/class/export/field.carbon b/toolchain/check/testdata/interop/cpp/class/export/field.carbon index c9e1dd5770a6..ff3564bd285f 100644 --- a/toolchain/check/testdata/interop/cpp/class/export/field.carbon +++ b/toolchain/check/testdata/interop/cpp/class/export/field.carbon @@ -75,10 +75,10 @@ class EmptyClass {} inline Cpp ''' void AccessNonexistentField() { Carbon::EmptyClass a; - // CHECK:STDERR: fail_nonexistent_field.carbon:[[@LINE+2]]:5: error: no member named 'x' in 'Carbon::EmptyClass' [CppInteropParseError] + // CHECK:STDERR: fail_nonexistent_field.carbon:[[@LINE+2]]:5: error: no member named 'x' in 'Carbon::Main::EmptyClass' [CppInteropParseError] // CHECK:STDERR: a.x = 12; - // CHECK:STDERR: fail_nonexistent_field.carbon:[[@LINE+2]]:5: error: no member named 'y' in 'Carbon::EmptyClass' [CppInteropParseError] + // CHECK:STDERR: fail_nonexistent_field.carbon:[[@LINE+2]]:5: error: no member named 'y' in 'Carbon::Main::EmptyClass' [CppInteropParseError] // CHECK:STDERR: a.y = 34; } @@ -100,10 +100,10 @@ class UnsupportedFieldType { inline Cpp ''' void AccessUnsupportedField() { Carbon::UnsupportedFieldType a; - // CHECK:STDERR: fail_unsupported_field_type.carbon:[[@LINE+2]]:5: error: no member named 'x' in 'Carbon::UnsupportedFieldType' [CppInteropParseError] + // CHECK:STDERR: fail_unsupported_field_type.carbon:[[@LINE+2]]:5: error: no member named 'x' in 'Carbon::Main::UnsupportedFieldType' [CppInteropParseError] // CHECK:STDERR: a.x; - // CHECK:STDERR: fail_unsupported_field_type.carbon:[[@LINE+2]]:5: error: no member named 'y' in 'Carbon::UnsupportedFieldType' [CppInteropParseError] + // CHECK:STDERR: fail_unsupported_field_type.carbon:[[@LINE+2]]:5: error: no member named 'y' in 'Carbon::Main::UnsupportedFieldType' [CppInteropParseError] // CHECK:STDERR: a.y; } @@ -120,7 +120,7 @@ class AdaptedClass { inline Cpp ''' void AccessAdaptedField() { Carbon::AdaptedClass a; - // CHECK:STDERR: fail_adapter.carbon:[[@LINE+2]]:5: error: no member named 'x' in 'Carbon::AdaptedClass' [CppInteropParseError] + // CHECK:STDERR: fail_adapter.carbon:[[@LINE+2]]:5: error: no member named 'x' in 'Carbon::Main::AdaptedClass' [CppInteropParseError] // CHECK:STDERR: a.x = 12; } @@ -156,7 +156,7 @@ class ClassWithPrivateField { inline Cpp ''' int AccessPrivateField() { auto c = Carbon::ClassWithPrivateField::Make(); - // CHECK:STDERR: fail_private_field.carbon:[[@LINE+3]]:12: error: 'x' is a private member of 'Carbon::ClassWithPrivateField' [CppInteropParseError] + // CHECK:STDERR: fail_private_field.carbon:[[@LINE+3]]:12: error: 'x' is a private member of 'Carbon::Main::ClassWithPrivateField' [CppInteropParseError] // CHECK:STDERR: fail_private_field.carbon:[[@LINE-7]]:16: note: implicitly declared private here [CppInteropParseNote] // CHECK:STDERR: return c.x; diff --git a/toolchain/check/testdata/interop/cpp/class/export/generic.carbon b/toolchain/check/testdata/interop/cpp/class/export/generic.carbon index c8e0d839ef93..971bca983450 100644 --- a/toolchain/check/testdata/interop/cpp/class/export/generic.carbon +++ b/toolchain/check/testdata/interop/cpp/class/export/generic.carbon @@ -76,7 +76,7 @@ class ClassWithMethod(T: type) { inline Cpp ''' void FMethodCall() { Carbon::ClassWithMethod c; - // CHECK:STDERR: fail_todo_generic_class_method_call.carbon:[[@LINE+2]]:5: error: no member named 'M' in 'Carbon::ClassWithMethod' [CppInteropParseError] + // CHECK:STDERR: fail_todo_generic_class_method_call.carbon:[[@LINE+2]]:5: error: no member named 'M' in 'Carbon::Main::ClassWithMethod' [CppInteropParseError] // CHECK:STDERR: c.M(); } diff --git a/toolchain/check/testdata/interop/cpp/class/export/method.carbon b/toolchain/check/testdata/interop/cpp/class/export/method.carbon index a6f0df556e6c..d99fda1a4884 100644 --- a/toolchain/check/testdata/interop/cpp/class/export/method.carbon +++ b/toolchain/check/testdata/interop/cpp/class/export/method.carbon @@ -109,7 +109,7 @@ class RefMethodConstLValueClass { inline Cpp ''' void RefMethodConstLValue(const Carbon::RefMethodConstLValueClass& c) { - // CHECK:STDERR: fail_ref_method_const_lvalue.carbon:[[@LINE+3]]:3: error: 'this' argument to member function 'M' has type 'const Carbon::RefMethodConstLValueClass', but function is not marked const [CppInteropParseError] + // CHECK:STDERR: fail_ref_method_const_lvalue.carbon:[[@LINE+3]]:3: error: 'this' argument to member function 'M' has type 'const Carbon::RefMethodConstLValueClass' (aka 'const Carbon::Main::RefMethodConstLValueClass'), but function is not marked const [CppInteropParseError] // CHECK:STDERR: fail_ref_method_const_lvalue.carbon:[[@LINE-6]]:17: note: 'M' declared here [CppInteropParseNote] // CHECK:STDERR: c.M(); diff --git a/toolchain/check/testdata/interop/cpp/class/export/static.carbon b/toolchain/check/testdata/interop/cpp/class/export/static.carbon index ed4bd455941e..1d246210dd62 100644 --- a/toolchain/check/testdata/interop/cpp/class/export/static.carbon +++ b/toolchain/check/testdata/interop/cpp/class/export/static.carbon @@ -34,7 +34,7 @@ class PrivateClass { inline Cpp ''' int PrivateStatic() { - // CHECK:STDERR: fail_static_private.carbon:[[@LINE+3]]:32: error: 'x' is a private member of 'Carbon::PrivateClass' [CppInteropParseError] + // CHECK:STDERR: fail_static_private.carbon:[[@LINE+3]]:32: error: 'x' is a private member of 'Carbon::Main::PrivateClass' [CppInteropParseError] // CHECK:STDERR: fail_static_private.carbon:[[@LINE-6]]:23: note: implicitly declared private here [CppInteropParseNote] // CHECK:STDERR: return Carbon::PrivateClass::x; diff --git a/toolchain/check/testdata/interop/cpp/class/import/access.carbon b/toolchain/check/testdata/interop/cpp/class/import/access.carbon index 0362d28a481d..8c488d66b5ce 100644 --- a/toolchain/check/testdata/interop/cpp/class/import/access.carbon +++ b/toolchain/check/testdata/interop/cpp/class/import/access.carbon @@ -268,7 +268,7 @@ class Derived { // CHECK:STDERR: fail_todo_import_function_member_protected_extend_call_instance_in_member.carbon:[[@LINE+5]]:5-20: error: no matching function for call to 'instance_fn' [CppInteropParseError] // CHECK:STDERR: included from: fail_todo_import_function_member_protected_extend_call_instance_in_member.carbon:[[@LINE-8]]:10 [InCppInclude] // CHECK:STDERR: ./function_member_protected.h:4:8: note: candidate function not viable [CppInteropParseNote] - // CHECK:STDERR: ./function_member_protected.h:4:19-20: note: cannot convert argument of incomplete type 'const Carbon::Derived' to 'FunctionMemberProtected' for object argument [CppInteropParseNoteReason] + // CHECK:STDERR: ./function_member_protected.h:4:19-20: note: cannot convert argument of incomplete type 'const Carbon::Main::Derived' to 'FunctionMemberProtected' for object argument [CppInteropParseNoteReason] // CHECK:STDERR: self.instance_fn(); //@dump-sem-ir-end diff --git a/toolchain/check/testdata/interop/cpp/function/export/constructor.carbon b/toolchain/check/testdata/interop/cpp/function/export/constructor.carbon index 1c48e92089eb..e60fbd000695 100644 --- a/toolchain/check/testdata/interop/cpp/function/export/constructor.carbon +++ b/toolchain/check/testdata/interop/cpp/function/export/constructor.carbon @@ -36,7 +36,7 @@ class FactoryIsMethod { inline Cpp ''' void CallFactoryIsMethod() { - // CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE+5]]:27: error: no matching constructor for initialization of 'Carbon::FactoryIsMethod' [CppInteropParseError] + // CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE+5]]:27: error: no matching constructor for initialization of 'Carbon::FactoryIsMethod' (aka 'Carbon::Main::FactoryIsMethod') [CppInteropParseError] // CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE-7]]:23: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const FactoryIsMethod' for 1st argument [CppInteropParseNote] // CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE-8]]:23: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'FactoryIsMethod' for 1st argument [CppInteropParseNote] // CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE-9]]:23: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided [CppInteropParseNote] @@ -56,7 +56,7 @@ class FactoryDoesntReturnSelf { inline Cpp ''' void CallFactoryDoesntReturnSelf() { - // CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE+5]]:35: error: no matching constructor for initialization of 'Carbon::FactoryDoesntReturnSelf' [CppInteropParseError] + // CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE+5]]:35: error: no matching constructor for initialization of 'Carbon::FactoryDoesntReturnSelf' (aka 'Carbon::Main::FactoryDoesntReturnSelf') [CppInteropParseError] // CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE-7]]:31: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const FactoryDoesntReturnSelf' for 1st argument [CppInteropParseNote] // CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE-8]]:31: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'FactoryDoesntReturnSelf' for 1st argument [CppInteropParseNote] // CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE-9]]:31: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided [CppInteropParseNote] @@ -76,7 +76,7 @@ class FactoryReturnsByRef { inline Cpp ''' void CallFactoryReturnsByRef() { - // CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE+5]]:31: error: no matching constructor for initialization of 'Carbon::FactoryReturnsByRef' [CppInteropParseError] + // CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE+5]]:31: error: no matching constructor for initialization of 'Carbon::FactoryReturnsByRef' (aka 'Carbon::Main::FactoryReturnsByRef') [CppInteropParseError] // CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE-7]]:27: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const FactoryReturnsByRef' for 1st argument [CppInteropParseNote] // CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE-8]]:27: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'FactoryReturnsByRef' for 1st argument [CppInteropParseNote] // CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE-9]]:27: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided [CppInteropParseNote] @@ -100,7 +100,7 @@ class GenericConstructor { inline Cpp ''' void CallGenericConstructor() { - // CHECK:STDERR: fail_todo_call_generic_constructor.carbon:[[@LINE+5]]:30: error: no matching constructor for initialization of 'Carbon::GenericConstructor' [CppInteropParseError] + // CHECK:STDERR: fail_todo_call_generic_constructor.carbon:[[@LINE+5]]:30: error: no matching constructor for initialization of 'Carbon::GenericConstructor' (aka 'Carbon::Main::GenericConstructor') [CppInteropParseError] // CHECK:STDERR: fail_todo_call_generic_constructor.carbon:[[@LINE-11]]:26: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const GenericConstructor' for 1st argument [CppInteropParseNote] // CHECK:STDERR: fail_todo_call_generic_constructor.carbon:[[@LINE-12]]:26: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'GenericConstructor' for 1st argument [CppInteropParseNote] // CHECK:STDERR: fail_todo_call_generic_constructor.carbon:[[@LINE-13]]:26: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided [CppInteropParseNote] diff --git a/toolchain/check/testdata/interop/cpp/function/export/generic.carbon b/toolchain/check/testdata/interop/cpp/function/export/generic.carbon index b78fc58bd59c..6f03669ee1b6 100644 --- a/toolchain/check/testdata/interop/cpp/function/export/generic.carbon +++ b/toolchain/check/testdata/interop/cpp/function/export/generic.carbon @@ -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' [CppInteropParseError] + // CHECK:STDERR: fail_todo_enclosing_generic.carbon:[[@LINE+2]]:5: error: no member named 'MemberF' in 'Carbon::Main::EnclosingA' [CppInteropParseError] // CHECK:STDERR: b.MemberF(1, 2); } diff --git a/toolchain/check/testdata/interop/cpp/function/export/thunk_ast.carbon b/toolchain/check/testdata/interop/cpp/function/export/thunk_ast.carbon index 9ed7ad38d3ff..99cf80942958 100644 --- a/toolchain/check/testdata/interop/cpp/function/export/thunk_ast.carbon +++ b/toolchain/check/testdata/interop/cpp/function/export/thunk_ast.carbon @@ -14,6 +14,7 @@ // CHECK:STDOUT: TranslationUnitDecl {{0x[a-f0-9]+}} <> // CHECK:STDOUT: |-EmptyDecl {{0x[a-f0-9]+}} <:1:1> col:1 // CHECK:STDOUT: |-NamespaceDecl {{0x[a-f0-9]+}} <> referenced Carbon external-linkage +// CHECK:STDOUT: | `-NamespaceDecl {{0x[a-f0-9]+}} <> Main external-linkage // --- thunk_with_args_and_return.carbon @@ -22,23 +23,23 @@ library "[[@TEST_NAME]]"; import Cpp; fn F(i: i32) -> i32 { -// CHECK:STDOUT: | `-FunctionDecl {{0x[a-f0-9]+}} col:21 used F 'int (int)' inline internal-linkage -// CHECK:STDOUT: | |-ParmVarDecl {{0x[a-f0-9]+}} col:21 used 'int' -// CHECK:STDOUT: | |-CompoundStmt {{0x[a-f0-9]+}} -// CHECK:STDOUT: | | |-DeclStmt {{0x[a-f0-9]+}} -// CHECK:STDOUT: | | | `-VarDecl {{0x[a-f0-9]+}} col:21 used return_storage 'int' nrvo -// CHECK:STDOUT: | | |-CallExpr {{0x[a-f0-9]+}} 'void' -// CHECK:STDOUT: | | | |-ImplicitCastExpr {{0x[a-f0-9]+}} 'void (*)(const int &, const int &)' -// CHECK:STDOUT: | | | | `-DeclRefExpr {{0x[a-f0-9]+}} 'void (const int &, const int &)' Function {{0x[a-f0-9]+}} 'F__carbon_thunk' 'void (const int &, const int &)' -// CHECK:STDOUT: | | | |-ImplicitCastExpr {{0x[a-f0-9]+}} 'const int' lvalue -// CHECK:STDOUT: | | | | `-DeclRefExpr {{0x[a-f0-9]+}} 'int' lvalue ParmVar {{0x[a-f0-9]+}} depth 0 index 0 'int' -// CHECK:STDOUT: | | | `-ImplicitCastExpr {{0x[a-f0-9]+}} 'const int' lvalue -// CHECK:STDOUT: | | | `-DeclRefExpr {{0x[a-f0-9]+}} 'int' lvalue Var {{0x[a-f0-9]+}} 'return_storage' 'int' -// CHECK:STDOUT: | | `-ReturnStmt {{0x[a-f0-9]+}} nrvo_candidate(Var {{0x[a-f0-9]+}} 'return_storage' 'int') -// CHECK:STDOUT: | | `-ImplicitCastExpr {{0x[a-f0-9]+}} 'int' -// CHECK:STDOUT: | | `-DeclRefExpr {{0x[a-f0-9]+}} 'int' lvalue Var {{0x[a-f0-9]+}} 'return_storage' 'int' -// CHECK:STDOUT: | |-AlwaysInlineAttr {{0x[a-f0-9]+}} <> Implicit always_inline -// CHECK:STDOUT: | `-InternalLinkageAttr {{0x[a-f0-9]+}} <> Implicit +// CHECK:STDOUT: | `-FunctionDecl {{0x[a-f0-9]+}} col:21 used F 'int (int)' inline internal-linkage +// CHECK:STDOUT: | |-ParmVarDecl {{0x[a-f0-9]+}} col:21 used 'int' +// CHECK:STDOUT: | |-CompoundStmt {{0x[a-f0-9]+}} +// CHECK:STDOUT: | | |-DeclStmt {{0x[a-f0-9]+}} +// CHECK:STDOUT: | | | `-VarDecl {{0x[a-f0-9]+}} col:21 used return_storage 'int' nrvo +// CHECK:STDOUT: | | |-CallExpr {{0x[a-f0-9]+}} 'void' +// CHECK:STDOUT: | | | |-ImplicitCastExpr {{0x[a-f0-9]+}} 'void (*)(const int &, const int &)' +// CHECK:STDOUT: | | | | `-DeclRefExpr {{0x[a-f0-9]+}} 'void (const int &, const int &)' Function {{0x[a-f0-9]+}} 'F__carbon_thunk' 'void (const int &, const int &)' +// CHECK:STDOUT: | | | |-ImplicitCastExpr {{0x[a-f0-9]+}} 'const int' lvalue +// CHECK:STDOUT: | | | | `-DeclRefExpr {{0x[a-f0-9]+}} 'int' lvalue ParmVar {{0x[a-f0-9]+}} depth 0 index 0 'int' +// CHECK:STDOUT: | | | `-ImplicitCastExpr {{0x[a-f0-9]+}} 'const int' lvalue +// CHECK:STDOUT: | | | `-DeclRefExpr {{0x[a-f0-9]+}} 'int' lvalue Var {{0x[a-f0-9]+}} 'return_storage' 'int' +// CHECK:STDOUT: | | `-ReturnStmt {{0x[a-f0-9]+}} nrvo_candidate(Var {{0x[a-f0-9]+}} 'return_storage' 'int') +// CHECK:STDOUT: | | `-ImplicitCastExpr {{0x[a-f0-9]+}} 'int' +// CHECK:STDOUT: | | `-DeclRefExpr {{0x[a-f0-9]+}} 'int' lvalue Var {{0x[a-f0-9]+}} 'return_storage' 'int' +// CHECK:STDOUT: | |-AlwaysInlineAttr {{0x[a-f0-9]+}} <> Implicit always_inline +// CHECK:STDOUT: | `-InternalLinkageAttr {{0x[a-f0-9]+}} <> Implicit // CHECK:STDOUT: |-FunctionDecl {{0x[a-f0-9]+}} line:39:5 in thunk_with_args_and_return.carbon hidden G 'int (int)' external-linkage // CHECK:STDOUT: | |-ParmVarDecl {{0x[a-f0-9]+}} col:11 in thunk_with_args_and_return.carbon hidden used i 'int' // CHECK:STDOUT: | `-CompoundStmt {{0x[a-f0-9]+}} diff --git a/toolchain/check/testdata/interop/cpp/function/import/method_ptr.carbon b/toolchain/check/testdata/interop/cpp/function/import/method_ptr.carbon index 162a6796b570..23497f73e312 100644 --- a/toolchain/check/testdata/interop/cpp/function/import/method_ptr.carbon +++ b/toolchain/check/testdata/interop/cpp/function/import/method_ptr.carbon @@ -113,7 +113,7 @@ class C { fn F() { // CHECK:STDERR: fail_wrong_parent_type.carbon:[[@LINE+3]]:39-46: error: can't convert exported member function pointer to `void (C::*)(void) const` [ExportedFunctionPtrTypeMismatch] - // CHECK:STDERR: fail_wrong_parent_type.carbon:[[@LINE-5]]:3-18: note: function exported with pointer type `void (Carbon::C::*)(void) const` [ExportedFromFunction] + // CHECK:STDERR: fail_wrong_parent_type.carbon:[[@LINE-5]]:3-18: note: function exported with pointer type `void (Carbon::Main::C::*)(void) const` [ExportedFromFunction] // CHECK:STDERR: var unused ptr: Cpp.MethodPtrType = C.Method; } @@ -133,8 +133,8 @@ using MethodPtrType = void(Carbon::C::*)(float) const; fn G() { //@dump-sem-ir-begin - // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:39-46: error: can't convert exported member function pointer to `void (Carbon::C::*)(float) const` [ExportedFunctionPtrTypeMismatch] - // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE-10]]:3-26: note: function exported with pointer type `void (Carbon::C::*)(int) const` [ExportedFromFunction] + // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:39-46: error: can't convert exported member function pointer to `void (Carbon::Main::C::*)(float) const` [ExportedFunctionPtrTypeMismatch] + // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE-10]]:3-26: note: function exported with pointer type `void (Carbon::Main::C::*)(int) const` [ExportedFromFunction] // CHECK:STDERR: var unused ptr: Cpp.MethodPtrType = C.Method; //@dump-sem-ir-end diff --git a/toolchain/check/testdata/interop/cpp/function/import/thunk_ast.carbon b/toolchain/check/testdata/interop/cpp/function/import/thunk_ast.carbon index 10369b269618..d54f3d9b2b83 100644 --- a/toolchain/check/testdata/interop/cpp/function/import/thunk_ast.carbon +++ b/toolchain/check/testdata/interop/cpp/function/import/thunk_ast.carbon @@ -14,6 +14,7 @@ // CHECK:STDOUT: TranslationUnitDecl {{0x[a-f0-9]+}} <> // CHECK:STDOUT: |-EmptyDecl {{0x[a-f0-9]+}} <:1:1> col:1 // CHECK:STDOUT: |-NamespaceDecl {{0x[a-f0-9]+}} <> Carbon external-linkage +// CHECK:STDOUT: | `-NamespaceDecl {{0x[a-f0-9]+}} <> Main external-linkage // --- thunk_required.h @@ -45,10 +46,11 @@ fn F() { Cpp.foo(1 as i16); } -// CHECK:STDOUT: `-ImportDecl {{0x[a-f0-9]+}} col:104 in import_thunk_required.carbon implicit import_thunk_required.carbon +// CHECK:STDOUT: `-ImportDecl {{0x[a-f0-9]+}} col:104 in import_thunk_required.carbon implicit import_thunk_required.carbon // CHECK:STDOUT: TranslationUnitDecl {{0x[a-f0-9]+}} <> // CHECK:STDOUT: |-EmptyDecl {{0x[a-f0-9]+}} <:1:1> col:1 // CHECK:STDOUT: |-NamespaceDecl {{0x[a-f0-9]+}} <> Carbon external-linkage +// CHECK:STDOUT: | `-NamespaceDecl {{0x[a-f0-9]+}} <> Main external-linkage // --- return_thunk_required.h auto foo() -> short; diff --git a/toolchain/check/testdata/interop/cpp/namespace/export.carbon b/toolchain/check/testdata/interop/cpp/namespace/export.carbon index 4ead808fc749..2b7fcf11c904 100644 --- a/toolchain/check/testdata/interop/cpp/namespace/export.carbon +++ b/toolchain/check/testdata/interop/cpp/namespace/export.carbon @@ -55,3 +55,29 @@ namespace A = Carbon::N; Carbon::M::C *pmc; Carbon::N::C *pnc = pmc; '''; + +// --- fail_current_package_not_in_carbon.carbon +package SelfPkg; +import Cpp; + +class C {} + +inline Cpp ''' +Carbon::C* p; +// CHECK:STDERR: fail_current_package_not_in_carbon.carbon:[[@LINE+2]]:25: error: expected namespace name [CppInteropParseError] +// CHECK:STDERR: +namespace Bad = Carbon::SelfPkg; +'''; + +// --- fail_main_package_not_in_carbon.carbon +library "[[@TEST_NAME]]"; +import Cpp; + +class C {} + +inline Cpp ''' +Carbon::C* p; +// CHECK:STDERR: fail_main_package_not_in_carbon.carbon:[[@LINE+2]]:25: error: expected namespace name [CppInteropParseError] +// CHECK:STDERR: +namespace Bad = Carbon::Main; +'''; diff --git a/toolchain/check/testdata/interop/cpp/namespace/lookup_after_failure.carbon b/toolchain/check/testdata/interop/cpp/namespace/lookup_after_failure.carbon index 70d71239dea8..dc5b5d69eb08 100644 --- a/toolchain/check/testdata/interop/cpp/namespace/lookup_after_failure.carbon +++ b/toolchain/check/testdata/interop/cpp/namespace/lookup_after_failure.carbon @@ -106,7 +106,7 @@ fn Nested.EarlyFn() {} inline Cpp ''' void TestTypoInNested() { - // CHECK:STDERR: fail_typo_in_nested_namespace.carbon:[[@LINE+3]]:19-31: error: no member named 'LaterInNested' in namespace 'Carbon::Nested' [CppInteropParseError] + // CHECK:STDERR: fail_typo_in_nested_namespace.carbon:[[@LINE+3]]:19-31: error: no member named 'LaterInNested' in namespace 'Carbon::Main::Nested' [CppInteropParseError] // CHECK:STDERR: // CHECK:STDERR: fail_typo_in_nested_namespace.carbon:[[@LINE+1]]:19: error: name `LaterInNested` used before it was declared [NameUseBeforeDecl] Carbon::Nested::LaterInNested(); @@ -139,7 +139,7 @@ class MyClass { inline Cpp ''' void TestTypoInClass() { Carbon::MyClass::StaticMethod1(); - // CHECK:STDERR: fail_typo_in_carbon_class.carbon:[[@LINE+2]]:20-31: error: no member named 'NoSuchMember' in 'Carbon::MyClass' [CppInteropParseError] + // CHECK:STDERR: fail_typo_in_carbon_class.carbon:[[@LINE+2]]:20-31: error: no member named 'NoSuchMember' in 'Carbon::Main::MyClass' [CppInteropParseError] // CHECK:STDERR: Carbon::MyClass::NoSuchMember(); Carbon::MyClass::StaticMethod1(); diff --git a/toolchain/check/testdata/interop/cpp/primitive_types/array.carbon b/toolchain/check/testdata/interop/cpp/primitive_types/array.carbon index 8d2a8656e57a..f5057e6e3495 100644 --- a/toolchain/check/testdata/interop/cpp/primitive_types/array.carbon +++ b/toolchain/check/testdata/interop/cpp/primitive_types/array.carbon @@ -71,8 +71,8 @@ fn F() -> array(C, 5)*; inline Cpp ''' void G() { - // CHECK:STDERR: fail_incomplete.carbon:[[@LINE+3]]:33: error: subscript of pointer to incomplete type 'Carbon::C' [CppInteropParseError] - // CHECK:STDERR: fail_incomplete.carbon:[[@LINE-7]]:8: note: forward declaration of 'Carbon::C' [CppInteropParseNote] + // CHECK:STDERR: fail_incomplete.carbon:[[@LINE+3]]:33: error: subscript of pointer to incomplete type 'Carbon::Main::C' [CppInteropParseError] + // CHECK:STDERR: fail_incomplete.carbon:[[@LINE-7]]:8: note: forward declaration of 'Carbon::Main::C' [CppInteropParseNote] // CHECK:STDERR: Carbon::C *p = &(*Carbon::F())[0]; } diff --git a/toolchain/lower/testdata/interop/cpp/array.carbon b/toolchain/lower/testdata/interop/cpp/array.carbon index 87f9b40f2ca7..7c170ca40e6b 100644 --- a/toolchain/lower/testdata/interop/cpp/array.carbon +++ b/toolchain/lower/testdata/interop/cpp/array.carbon @@ -41,7 +41,7 @@ int H() { // CHECK:STDOUT: entry: // CHECK:STDOUT: %arr = alloca [5 x i32], align 16 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %arr) #3 -// CHECK:STDOUT: %call = call noundef i32 @_ZN6CarbonL1FERA5_Ki(ptr noundef nonnull align 4 dereferenceable(20) %arr) +// CHECK:STDOUT: %call = call noundef i32 @_ZN6Carbon4MainL1FERA5_Ki(ptr noundef nonnull align 4 dereferenceable(20) %arr) // CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %arr) #3 // CHECK:STDOUT: ret i32 %call // CHECK:STDOUT: } @@ -50,7 +50,7 @@ int H() { // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal noundef i32 @_ZN6CarbonL1FERA5_Ki(ptr noundef nonnull align 4 dereferenceable(20) %0) #2 { +// CHECK:STDOUT: define internal noundef i32 @_ZN6Carbon4MainL1FERA5_Ki(ptr noundef nonnull align 4 dereferenceable(20) %0) #2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %retval = alloca i32, align 4 // CHECK:STDOUT: %.addr = alloca ptr, align 8 @@ -70,7 +70,7 @@ int H() { // CHECK:STDOUT: %ref.tmp = alloca [5 x i32], align 4 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %ref.tmp) #3 // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %ref.tmp, ptr align 4 @constinit, i64 20, i1 false), !tbaa.struct !3 -// CHECK:STDOUT: %call = call noundef i32 @_ZN6CarbonL1FERA5_Ki(ptr noundef nonnull align 4 dereferenceable(20) %ref.tmp) +// CHECK:STDOUT: %call = call noundef i32 @_ZN6Carbon4MainL1FERA5_Ki(ptr noundef nonnull align 4 dereferenceable(20) %ref.tmp) // CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %ref.tmp) #3 // CHECK:STDOUT: ret i32 %call // CHECK:STDOUT: } diff --git a/toolchain/lower/testdata/interop/cpp/class/export/class.carbon b/toolchain/lower/testdata/interop/cpp/class/export/class.carbon index 8bffe03e6af5..6f9f0021d615 100644 --- a/toolchain/lower/testdata/interop/cpp/class/export/class.carbon +++ b/toolchain/lower/testdata/interop/cpp/class/export/class.carbon @@ -101,7 +101,7 @@ fn G() { // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu" // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable -// CHECK:STDOUT: define dso_local noundef ptr @_Z4passPN6Carbon1AE(ptr noundef %p) #0 { +// CHECK:STDOUT: define dso_local noundef ptr @_Z4passPN6Carbon4Main1AE(ptr noundef %p) #0 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %p.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %p, ptr %p.addr, align 8, !tbaa !4 @@ -112,7 +112,7 @@ fn G() { // CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable // CHECK:STDOUT: define dso_local void @_Z4callv() #0 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: %call = call noundef ptr @_Z4passPN6Carbon1AE(ptr noundef null) +// CHECK:STDOUT: %call = call noundef ptr @_Z4passPN6Carbon4Main1AE(ptr noundef null) // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: @@ -133,7 +133,7 @@ fn G() { // CHECK:STDOUT: !0 = !{!"Simple C++ TBAA"} // CHECK:STDOUT: !1 = !{!"omnipotent char", !0, i64 0} // CHECK:STDOUT: !2 = !{!"any pointer", !1, i64 0} -// CHECK:STDOUT: !3 = !{!"p1 _ZTSN6Carbon1AE", !2, i64 0} +// CHECK:STDOUT: !3 = !{!"p1 _ZTSN6Carbon4Main1AE", !2, i64 0} // CHECK:STDOUT: !4 = !{!3, !3, i64 0} // CHECK:STDOUT: !5 = !{!"int", !1, i64 0} // CHECK:STDOUT: !19 = !{i32 7, !"Dwarf Version", i32 5} @@ -157,23 +157,23 @@ fn G() { // CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu" // CHECK:STDOUT: -// CHECK:STDOUT: %"class.Carbon::LayoutA" = type <{ ptr, i32 }> -// CHECK:STDOUT: %"class.Carbon::LayoutB" = type { %"class.Carbon::LayoutA", i32 } -// CHECK:STDOUT: %"class.Carbon::LayoutC" = type { %"class.Carbon::LayoutA", i32 } +// CHECK:STDOUT: %"class.Carbon::Main::LayoutA" = type <{ ptr, i32 }> +// CHECK:STDOUT: %"class.Carbon::Main::LayoutB" = type { %"class.Carbon::Main::LayoutA", i32 } +// CHECK:STDOUT: %"class.Carbon::Main::LayoutC" = type { %"class.Carbon::Main::LayoutA", i32 } // CHECK:STDOUT: -// CHECK:STDOUT: $_ZN6Carbon7LayoutAD2Ev = comdat any +// CHECK:STDOUT: $_ZN6Carbon4Main7LayoutAD2Ev = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZN6Carbon7LayoutBD2Ev = comdat any +// CHECK:STDOUT: $_ZN6Carbon4Main7LayoutBD2Ev = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZN6Carbon7LayoutCD2Ev = comdat any +// CHECK:STDOUT: $_ZN6Carbon4Main7LayoutCD2Ev = comdat any // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable // CHECK:STDOUT: define dso_local void @_Z1fv() #0 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: %a = alloca %"class.Carbon::LayoutA", align 8 +// CHECK:STDOUT: %a = alloca %"class.Carbon::Main::LayoutA", align 8 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %a) #5 -// CHECK:STDOUT: call void @_ZN6CarbonL11CallLayoutAEPNS_7LayoutAE(ptr noundef %a) -// CHECK:STDOUT: call void @_ZN6Carbon7LayoutAD2Ev(ptr noundef nonnull align 8 dead_on_return(12) dereferenceable(12) %a) #5 +// CHECK:STDOUT: call void @_ZN6Carbon4MainL11CallLayoutAEPNS0_7LayoutAE(ptr noundef %a) +// CHECK:STDOUT: call void @_ZN6Carbon4Main7LayoutAD2Ev(ptr noundef nonnull align 8 dead_on_return(12) dereferenceable(12) %a) #5 // CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %a) #5 // CHECK:STDOUT: ret void // CHECK:STDOUT: } @@ -182,7 +182,7 @@ fn G() { // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal void @_ZN6CarbonL11CallLayoutAEPNS_7LayoutAE(ptr noundef %0) #2 { +// CHECK:STDOUT: define internal void @_ZN6Carbon4MainL11CallLayoutAEPNS0_7LayoutAE(ptr noundef %0) #2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !136 @@ -191,7 +191,7 @@ fn G() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable -// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon7LayoutAD2Ev(ptr noundef nonnull align 8 dead_on_return(12) dereferenceable(12) %this) unnamed_addr #3 comdat align 2 { +// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4Main7LayoutAD2Ev(ptr noundef nonnull align 8 dead_on_return(12) dereferenceable(12) %this) unnamed_addr #3 comdat align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !136 @@ -206,16 +206,16 @@ fn G() { // CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable // CHECK:STDOUT: define dso_local void @_Z1gv() #0 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: %b = alloca %"class.Carbon::LayoutB", align 8 +// CHECK:STDOUT: %b = alloca %"class.Carbon::Main::LayoutB", align 8 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %b) #5 -// CHECK:STDOUT: call void @_ZN6CarbonL11CallLayoutBEPNS_7LayoutBE(ptr noundef %b) -// CHECK:STDOUT: call void @_ZN6Carbon7LayoutBD2Ev(ptr noundef nonnull align 8 dead_on_return(16) dereferenceable(16) %b) #5 +// CHECK:STDOUT: call void @_ZN6Carbon4MainL11CallLayoutBEPNS0_7LayoutBE(ptr noundef %b) +// CHECK:STDOUT: call void @_ZN6Carbon4Main7LayoutBD2Ev(ptr noundef nonnull align 8 dead_on_return(16) dereferenceable(16) %b) #5 // CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %b) #5 // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal void @_ZN6CarbonL11CallLayoutBEPNS_7LayoutBE(ptr noundef %0) #2 { +// CHECK:STDOUT: define internal void @_ZN6Carbon4MainL11CallLayoutBEPNS0_7LayoutBE(ptr noundef %0) #2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !138 @@ -224,31 +224,31 @@ fn G() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable -// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon7LayoutBD2Ev(ptr noundef nonnull align 8 dead_on_return(16) dereferenceable(16) %this) unnamed_addr #3 comdat align 2 { +// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4Main7LayoutBD2Ev(ptr noundef nonnull align 8 dead_on_return(16) dereferenceable(16) %this) unnamed_addr #3 comdat align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !138 // CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8 // CHECK:STDOUT: call void @"_C__destroy_thunk:thunk.LayoutB.Main"(ptr noundef nonnull align 8 dereferenceable(16) %this1) -// CHECK:STDOUT: %a = getelementptr inbounds nuw %"class.Carbon::LayoutB", ptr %this1, i32 0, i32 0 -// CHECK:STDOUT: call void @_ZN6Carbon7LayoutAD2Ev(ptr noundef nonnull align 8 dead_on_return(12) dereferenceable(12) %a) #5 +// CHECK:STDOUT: %a = getelementptr inbounds nuw %"class.Carbon::Main::LayoutB", ptr %this1, i32 0, i32 0 +// CHECK:STDOUT: call void @_ZN6Carbon4Main7LayoutAD2Ev(ptr noundef nonnull align 8 dead_on_return(12) dereferenceable(12) %a) #5 // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable // CHECK:STDOUT: define dso_local void @_Z1hv() #0 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: %c = alloca %"class.Carbon::LayoutC", align 8 +// CHECK:STDOUT: %c = alloca %"class.Carbon::Main::LayoutC", align 8 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c) #5 -// CHECK:STDOUT: call void @_ZN6CarbonL11CallLayoutCEPNS_7LayoutCE(ptr noundef %c) -// CHECK:STDOUT: call void @_ZN6CarbonL11CallLayoutAEPNS_7LayoutAE(ptr noundef %c) -// CHECK:STDOUT: call void @_ZN6Carbon7LayoutCD2Ev(ptr noundef nonnull align 8 dead_on_return(16) dereferenceable(16) %c) #5 +// CHECK:STDOUT: call void @_ZN6Carbon4MainL11CallLayoutCEPNS0_7LayoutCE(ptr noundef %c) +// CHECK:STDOUT: call void @_ZN6Carbon4MainL11CallLayoutAEPNS0_7LayoutAE(ptr noundef %c) +// CHECK:STDOUT: call void @_ZN6Carbon4Main7LayoutCD2Ev(ptr noundef nonnull align 8 dead_on_return(16) dereferenceable(16) %c) #5 // CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %c) #5 // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal void @_ZN6CarbonL11CallLayoutCEPNS_7LayoutCE(ptr noundef %0) #2 { +// CHECK:STDOUT: define internal void @_ZN6Carbon4MainL11CallLayoutCEPNS0_7LayoutCE(ptr noundef %0) #2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !140 @@ -257,13 +257,13 @@ fn G() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable -// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon7LayoutCD2Ev(ptr noundef nonnull align 8 dead_on_return(16) dereferenceable(16) %this) unnamed_addr #3 comdat align 2 { +// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4Main7LayoutCD2Ev(ptr noundef nonnull align 8 dead_on_return(16) dereferenceable(16) %this) unnamed_addr #3 comdat align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !140 // CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8 // CHECK:STDOUT: call void @"_C__destroy_thunk:thunk.LayoutC.Main"(ptr noundef nonnull align 8 dereferenceable(16) %this1) -// CHECK:STDOUT: call void @_ZN6Carbon7LayoutAD2Ev(ptr noundef nonnull align 8 dead_on_return(12) dereferenceable(12) %this1) #5 +// CHECK:STDOUT: call void @_ZN6Carbon4Main7LayoutAD2Ev(ptr noundef nonnull align 8 dead_on_return(12) dereferenceable(12) %this1) #5 // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: @@ -433,7 +433,7 @@ fn G() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; uselistorder directives -// CHECK:STDOUT: uselistorder ptr @_ZN6Carbon7LayoutAD2Ev, { 2, 1, 0 } +// CHECK:STDOUT: uselistorder ptr @_ZN6Carbon4Main7LayoutAD2Ev, { 2, 1, 0 } // CHECK:STDOUT: // CHECK:STDOUT: attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) } @@ -545,11 +545,11 @@ fn G() { // CHECK:STDOUT: !132 = !DILocalVariable(arg: 1, scope: !131, type: !50) // CHECK:STDOUT: !133 = !DILocation(line: 23, column: 1, scope: !131) // CHECK:STDOUT: !134 = !{!132} -// CHECK:STDOUT: !135 = !{!"p1 _ZTSN6Carbon7LayoutAE", !2, i64 0} +// CHECK:STDOUT: !135 = !{!"p1 _ZTSN6Carbon4Main7LayoutAE", !2, i64 0} // CHECK:STDOUT: !136 = !{!135, !135, i64 0} -// CHECK:STDOUT: !137 = !{!"p1 _ZTSN6Carbon7LayoutBE", !2, i64 0} +// CHECK:STDOUT: !137 = !{!"p1 _ZTSN6Carbon4Main7LayoutBE", !2, i64 0} // CHECK:STDOUT: !138 = !{!137, !137, i64 0} -// CHECK:STDOUT: !139 = !{!"p1 _ZTSN6Carbon7LayoutCE", !2, i64 0} +// CHECK:STDOUT: !139 = !{!"p1 _ZTSN6Carbon4Main7LayoutCE", !2, i64 0} // CHECK:STDOUT: !140 = !{!139, !139, i64 0} // CHECK:STDOUT: // CHECK:STDOUT: ; --- @@ -558,20 +558,20 @@ fn G() { // CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu" // CHECK:STDOUT: -// CHECK:STDOUT: %"class.Carbon::FieldC" = type { i32, i32 } +// CHECK:STDOUT: %"class.Carbon::Main::FieldC" = type { i32, i32 } // CHECK:STDOUT: // CHECK:STDOUT: @FieldC.val.loc19_3 = internal constant { i32, i32 } zeroinitializer // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable -// CHECK:STDOUT: define dso_local void @_Z1FRN6Carbon6FieldCE(ptr noundef nonnull align 4 dereferenceable(8) %c) #0 { +// CHECK:STDOUT: define dso_local void @_Z1FRN6Carbon4Main6FieldCE(ptr noundef nonnull align 4 dereferenceable(8) %c) #0 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %c.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %c, ptr %c.addr, align 8, !tbaa !11 // CHECK:STDOUT: %0 = load ptr, ptr %c.addr, align 8, !tbaa !11, !nonnull !13, !align !14 -// CHECK:STDOUT: %a = getelementptr inbounds nuw %"class.Carbon::FieldC", ptr %0, i32 0, i32 0 +// CHECK:STDOUT: %a = getelementptr inbounds nuw %"class.Carbon::Main::FieldC", ptr %0, i32 0, i32 0 // CHECK:STDOUT: store i32 12, ptr %a, align 4, !tbaa !15 // CHECK:STDOUT: %1 = load ptr, ptr %c.addr, align 8, !tbaa !11, !nonnull !13, !align !14 -// CHECK:STDOUT: %b = getelementptr inbounds nuw %"class.Carbon::FieldC", ptr %1, i32 0, i32 1 +// CHECK:STDOUT: %b = getelementptr inbounds nuw %"class.Carbon::Main::FieldC", ptr %1, i32 0, i32 1 // CHECK:STDOUT: store i32 34, ptr %b, align 4, !tbaa !16 // CHECK:STDOUT: ret void // CHECK:STDOUT: } @@ -631,7 +631,7 @@ fn G() { // CHECK:STDOUT: %.loc19_34.3.a = getelementptr inbounds nuw { i32, i32 }, ptr %c.var, i32 0, i32 0, !dbg !169 // CHECK:STDOUT: %.loc19_34.6.b = getelementptr inbounds nuw { i32, i32 }, ptr %c.var, i32 0, i32 1, !dbg !169 // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %c.var, ptr align 4 @FieldC.val.loc19_3, i64 8, i1 false), !dbg !168 -// CHECK:STDOUT: call void @_Z1FRN6Carbon6FieldCE(ptr %c.var), !dbg !173 +// CHECK:STDOUT: call void @_Z1FRN6Carbon4Main6FieldCE(ptr %c.var), !dbg !173 // CHECK:STDOUT: call void @"_CSelfDestruct.718874c3c75b803e:core.Destroy.Core"(ptr %c.var), !dbg !168 // CHECK:STDOUT: ret void, !dbg !174 // CHECK:STDOUT: } @@ -655,9 +655,9 @@ fn G() { // CHECK:STDOUT: !1 = !{!"omnipotent char", !0, i64 0} // CHECK:STDOUT: !2 = !{!"any pointer", !1, i64 0} // CHECK:STDOUT: !5 = !{!"int", !1, i64 0} -// CHECK:STDOUT: !10 = !{!"p1 _ZTSN6Carbon6FieldCE", !2, i64 0} +// CHECK:STDOUT: !10 = !{!"p1 _ZTSN6Carbon4Main6FieldCE", !2, i64 0} // CHECK:STDOUT: !11 = !{!10, !10, i64 0} -// CHECK:STDOUT: !12 = !{!"_ZTSN6Carbon6FieldCE", !5, i64 0, !5, i64 4} +// CHECK:STDOUT: !12 = !{!"_ZTSN6Carbon4Main6FieldCE", !5, i64 0, !5, i64 4} // CHECK:STDOUT: !13 = !{} // CHECK:STDOUT: !14 = !{i64 4} // CHECK:STDOUT: !15 = !{!12, !5, i64 0} diff --git a/toolchain/lower/testdata/interop/cpp/class/export/destroy_from_thunk.carbon b/toolchain/lower/testdata/interop/cpp/class/export/destroy_from_thunk.carbon index 61895ae6cae2..9428f51c6e28 100644 --- a/toolchain/lower/testdata/interop/cpp/class/export/destroy_from_thunk.carbon +++ b/toolchain/lower/testdata/interop/cpp/class/export/destroy_from_thunk.carbon @@ -33,24 +33,24 @@ fn Run() { // CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu" // CHECK:STDOUT: -// CHECK:STDOUT: %"class.Carbon::C" = type {} +// CHECK:STDOUT: %"class.Carbon::Main::C" = type {} // CHECK:STDOUT: -// CHECK:STDOUT: $_Z11make_uniqueIN6Carbon1CEEvv = comdat any +// CHECK:STDOUT: $_Z11make_uniqueIN6Carbon4Main1CEEvv = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZN6Carbon1CD2Ev = comdat any +// CHECK:STDOUT: $_ZN6Carbon4Main1CD2Ev = comdat any // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define i32 @main() #0 !dbg !14 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: call void @_Z11make_uniqueIN6Carbon1CEEvv(), !dbg !15 +// CHECK:STDOUT: call void @_Z11make_uniqueIN6Carbon4Main1CEEvv(), !dbg !15 // CHECK:STDOUT: ret i32 0, !dbg !16 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable -// CHECK:STDOUT: define linkonce_odr dso_local void @_Z11make_uniqueIN6Carbon1CEEvv() #1 comdat { +// CHECK:STDOUT: define linkonce_odr dso_local void @_Z11make_uniqueIN6Carbon4Main1CEEvv() #1 comdat { // CHECK:STDOUT: entry: -// CHECK:STDOUT: %agg.tmp.ensured = alloca %"class.Carbon::C", align 1 -// CHECK:STDOUT: call void @_ZN6Carbon1CD2Ev(ptr noundef nonnull align 1 %agg.tmp.ensured) #0 +// CHECK:STDOUT: %agg.tmp.ensured = alloca %"class.Carbon::Main::C", align 1 +// CHECK:STDOUT: call void @_ZN6Carbon4Main1CD2Ev(ptr noundef nonnull align 1 %agg.tmp.ensured) #0 // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: @@ -74,7 +74,7 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable -// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon1CD2Ev(ptr noundef nonnull align 1 %this) unnamed_addr #3 comdat align 2 { +// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4Main1CD2Ev(ptr noundef nonnull align 1 %this) unnamed_addr #3 comdat align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !33 @@ -120,7 +120,7 @@ fn Run() { // CHECK:STDOUT: !29 = !{!"Simple C++ TBAA"} // CHECK:STDOUT: !30 = !{!"omnipotent char", !29, i64 0} // CHECK:STDOUT: !31 = !{!"any pointer", !30, i64 0} -// CHECK:STDOUT: !32 = !{!"p1 _ZTSN6Carbon1CE", !31, i64 0} +// CHECK:STDOUT: !32 = !{!"p1 _ZTSN6Carbon4Main1CE", !31, i64 0} // CHECK:STDOUT: !33 = !{!32, !32, i64 0} // CHECK:STDOUT: !35 = !{i32 8, !"PIC Level", i32 2} // CHECK:STDOUT: !36 = !{i32 7, !"PIE Level", i32 2} diff --git a/toolchain/lower/testdata/interop/cpp/class/export/generic.carbon b/toolchain/lower/testdata/interop/cpp/class/export/generic.carbon index 7d96bd9f90f4..f019ff2c56a0 100644 --- a/toolchain/lower/testdata/interop/cpp/class/export/generic.carbon +++ b/toolchain/lower/testdata/interop/cpp/class/export/generic.carbon @@ -40,17 +40,17 @@ fn Run() { // CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu" // CHECK:STDOUT: -// CHECK:STDOUT: %"class.Carbon::C" = type {} +// CHECK:STDOUT: %"class.Carbon::Main::C" = type {} // CHECK:STDOUT: %class.A = type { i8 } -// CHECK:STDOUT: %"class.Carbon::C.0" = type {} +// CHECK:STDOUT: %"class.Carbon::Main::C.0" = type {} // CHECK:STDOUT: %class.B = type { i8 } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable // CHECK:STDOUT: define dso_local void @_Z1Fv() #0 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: %c1 = alloca %"class.Carbon::C", align 1 +// CHECK:STDOUT: %c1 = alloca %"class.Carbon::Main::C", align 1 // CHECK:STDOUT: %ref.tmp = alloca %class.A, align 1 -// CHECK:STDOUT: %c2 = alloca %"class.Carbon::C.0", align 1 +// CHECK:STDOUT: %c2 = alloca %"class.Carbon::Main::C.0", align 1 // CHECK:STDOUT: %ref.tmp1 = alloca %class.B, align 1 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c1) #2 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %ref.tmp) #2 diff --git a/toolchain/lower/testdata/interop/cpp/class/export/mangle.carbon b/toolchain/lower/testdata/interop/cpp/class/export/mangle.carbon index fcaaed995599..6c8bcd0ae0ec 100644 --- a/toolchain/lower/testdata/interop/cpp/class/export/mangle.carbon +++ b/toolchain/lower/testdata/interop/cpp/class/export/mangle.carbon @@ -12,31 +12,69 @@ // --- other.carbon package Other; +import Cpp; class Class1; + +inline Cpp ''' +void f0(Carbon::Class1*) { +} +'''; + // --- namespace.carbon library "[[@TEST_NAME]]"; import Other; -import Cpp inline ''' +import Cpp; + +class Class2; + +inline Cpp ''' void f1(Carbon::Other::Class1*) { } +void f2(Carbon::Class2*) { +} + '''; // CHECK:STDOUT: ; --- // CHECK:STDOUT: ; ModuleID = 'other.carbon' // CHECK:STDOUT: source_filename = "other.carbon" +// CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" +// CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu" // CHECK:STDOUT: -// CHECK:STDOUT: !llvm.dbg.cu = !{!10} -// CHECK:STDOUT: !llvm.module.flags = !{!7, !8} +// CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable +// CHECK:STDOUT: define dso_local void @_Z2f0PN6Carbon5Other6Class1E(ptr noundef %0) #0 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: %.addr = alloca ptr, align 8 +// CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !4 +// CHECK:STDOUT: ret void +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: !7 = !{i32 7, !"Dwarf Version", i32 5} -// CHECK:STDOUT: !8 = !{i32 2, !"Debug Info Version", i32 3} -// CHECK:STDOUT: !9 = !DIFile(filename: "other.carbon", directory: "") -// CHECK:STDOUT: !10 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !9, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) +// CHECK:STDOUT: attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +// CHECK:STDOUT: +// CHECK:STDOUT: !llvm.dbg.cu = !{!12} +// CHECK:STDOUT: !llvm.module.flags = !{!13, !14, !15, !9, !10} +// CHECK:STDOUT: !llvm.errno.tbaa = !{!18} +// CHECK:STDOUT: +// CHECK:STDOUT: !0 = !{!"Simple C++ TBAA"} +// CHECK:STDOUT: !1 = !{!"omnipotent char", !0, i64 0} +// CHECK:STDOUT: !2 = !{!"any pointer", !1, i64 0} +// CHECK:STDOUT: !3 = !{!"p1 _ZTSN6Carbon5Other6Class1E", !2, i64 0} +// CHECK:STDOUT: !4 = !{!3, !3, i64 0} +// CHECK:STDOUT: !9 = !{i32 7, !"Dwarf Version", i32 5} +// CHECK:STDOUT: !10 = !{i32 2, !"Debug Info Version", i32 3} +// CHECK:STDOUT: !11 = !DIFile(filename: "other.carbon", directory: "") +// CHECK:STDOUT: !12 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !11, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) +// CHECK:STDOUT: !13 = !{i32 8, !"PIC Level", i32 2} +// CHECK:STDOUT: !14 = !{i32 7, !"PIE Level", i32 2} +// CHECK:STDOUT: !15 = !{i32 7, !"uwtable", i32 2} +// CHECK:STDOUT: !16 = !{!"int", !1, i64 0} +// CHECK:STDOUT: !17 = !{!"__libc_errno", !16, i64 0} +// CHECK:STDOUT: !18 = !{!17, !16, i64 0} // CHECK:STDOUT: // CHECK:STDOUT: ; --- // CHECK:STDOUT: ; ModuleID = 'namespace.carbon' @@ -52,10 +90,18 @@ void f1(Carbon::Other::Class1*) { // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable +// CHECK:STDOUT: define dso_local void @_Z2f2PN6Carbon4Main6Class2E(ptr noundef %0) #0 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: %.addr = alloca ptr, align 8 +// CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !6 +// CHECK:STDOUT: ret void +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } // CHECK:STDOUT: -// CHECK:STDOUT: !llvm.dbg.cu = !{!12} -// CHECK:STDOUT: !llvm.module.flags = !{!13, !14, !15, !7, !8} +// CHECK:STDOUT: !llvm.dbg.cu = !{!20} +// CHECK:STDOUT: !llvm.module.flags = !{!13, !14, !15, !9, !10} // CHECK:STDOUT: !llvm.errno.tbaa = !{!18} // CHECK:STDOUT: // CHECK:STDOUT: !0 = !{!"Simple C++ TBAA"} @@ -63,14 +109,16 @@ void f1(Carbon::Other::Class1*) { // CHECK:STDOUT: !2 = !{!"any pointer", !1, i64 0} // CHECK:STDOUT: !3 = !{!"p1 _ZTSN6Carbon5Other6Class1E", !2, i64 0} // CHECK:STDOUT: !4 = !{!3, !3, i64 0} -// CHECK:STDOUT: !7 = !{i32 7, !"Dwarf Version", i32 5} -// CHECK:STDOUT: !8 = !{i32 2, !"Debug Info Version", i32 3} -// CHECK:STDOUT: !11 = !DIFile(filename: "namespace.carbon", directory: "") -// CHECK:STDOUT: !12 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !11, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) +// CHECK:STDOUT: !5 = !{!"p1 _ZTSN6Carbon4Main6Class2E", !2, i64 0} +// CHECK:STDOUT: !6 = !{!5, !5, i64 0} +// CHECK:STDOUT: !9 = !{i32 7, !"Dwarf Version", i32 5} +// CHECK:STDOUT: !10 = !{i32 2, !"Debug Info Version", i32 3} // CHECK:STDOUT: !13 = !{i32 8, !"PIC Level", i32 2} // CHECK:STDOUT: !14 = !{i32 7, !"PIE Level", i32 2} // CHECK:STDOUT: !15 = !{i32 7, !"uwtable", i32 2} // CHECK:STDOUT: !16 = !{!"int", !1, i64 0} // CHECK:STDOUT: !17 = !{!"__libc_errno", !16, i64 0} // CHECK:STDOUT: !18 = !{!17, !16, i64 0} +// CHECK:STDOUT: !19 = !DIFile(filename: "namespace.carbon", directory: "") +// CHECK:STDOUT: !20 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !19, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) // CHECK:STDOUT: diff --git a/toolchain/lower/testdata/interop/cpp/class/export/method.carbon b/toolchain/lower/testdata/interop/cpp/class/export/method.carbon index c2c6b567fc00..98c3b265dda0 100644 --- a/toolchain/lower/testdata/interop/cpp/class/export/method.carbon +++ b/toolchain/lower/testdata/interop/cpp/class/export/method.carbon @@ -69,17 +69,17 @@ fn CallCallF() { Cpp.CallStaticF(); } // CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu" // CHECK:STDOUT: -// CHECK:STDOUT: %"class.Carbon::A" = type {} +// CHECK:STDOUT: %"class.Carbon::Main::A" = type {} // CHECK:STDOUT: -// CHECK:STDOUT: $_ZN6Carbon1AD2Ev = comdat any +// CHECK:STDOUT: $_ZN6Carbon4Main1AD2Ev = comdat any // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable // CHECK:STDOUT: define dso_local void @_Z5CallFv() #0 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: %ref.tmp = alloca %"class.Carbon::A", align 1 +// CHECK:STDOUT: %ref.tmp = alloca %"class.Carbon::Main::A", align 1 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %ref.tmp) #4 -// CHECK:STDOUT: call void @_ZNK6Carbon1A1FEv(ptr noundef nonnull align 1 %ref.tmp) -// CHECK:STDOUT: call void @_ZN6Carbon1AD2Ev(ptr noundef nonnull align 1 %ref.tmp) #4 +// CHECK:STDOUT: call void @_ZNK6Carbon4Main1A1FEv(ptr noundef nonnull align 1 %ref.tmp) +// CHECK:STDOUT: call void @_ZN6Carbon4Main1AD2Ev(ptr noundef nonnull align 1 %ref.tmp) #4 // CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %ref.tmp) #4 // CHECK:STDOUT: ret void // CHECK:STDOUT: } @@ -88,7 +88,7 @@ fn CallCallF() { Cpp.CallStaticF(); } // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal void @_ZNK6Carbon1A1FEv(ptr noundef nonnull align 1 %this) #2 align 2 { +// CHECK:STDOUT: define internal void @_ZNK6Carbon4Main1A1FEv(ptr noundef nonnull align 1 %this) #2 align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !51 @@ -98,7 +98,7 @@ fn CallCallF() { Cpp.CallStaticF(); } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable -// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon1AD2Ev(ptr noundef nonnull align 1 %this) unnamed_addr #3 comdat align 2 { +// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4Main1AD2Ev(ptr noundef nonnull align 1 %this) unnamed_addr #3 comdat align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !51 @@ -183,7 +183,7 @@ fn CallCallF() { Cpp.CallStaticF(); } // CHECK:STDOUT: !47 = !{!"Simple C++ TBAA"} // CHECK:STDOUT: !48 = !{!"omnipotent char", !47, i64 0} // CHECK:STDOUT: !49 = !{!"any pointer", !48, i64 0} -// CHECK:STDOUT: !50 = !{!"p1 _ZTSN6Carbon1AE", !49, i64 0} +// CHECK:STDOUT: !50 = !{!"p1 _ZTSN6Carbon4Main1AE", !49, i64 0} // CHECK:STDOUT: !51 = !{!50, !50, i64 0} // CHECK:STDOUT: !52 = !{i32 8, !"PIC Level", i32 2} // CHECK:STDOUT: !53 = !{i32 7, !"PIE Level", i32 2} @@ -198,17 +198,17 @@ fn CallCallF() { Cpp.CallStaticF(); } // CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu" // CHECK:STDOUT: -// CHECK:STDOUT: %"class.Carbon::ArgsA" = type {} +// CHECK:STDOUT: %"class.Carbon::Main::ArgsA" = type {} // CHECK:STDOUT: -// CHECK:STDOUT: $_ZN6Carbon5ArgsAD2Ev = comdat any +// CHECK:STDOUT: $_ZN6Carbon4Main5ArgsAD2Ev = comdat any // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable // CHECK:STDOUT: define dso_local noundef i32 @_Z9CallArgsFv() #0 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: %ref.tmp = alloca %"class.Carbon::ArgsA", align 1 +// CHECK:STDOUT: %ref.tmp = alloca %"class.Carbon::Main::ArgsA", align 1 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %ref.tmp) #4 -// CHECK:STDOUT: %call = call noundef i32 @_ZNK6Carbon5ArgsA1FEi(ptr noundef nonnull align 1 %ref.tmp, i32 noundef 123) -// CHECK:STDOUT: call void @_ZN6Carbon5ArgsAD2Ev(ptr noundef nonnull align 1 %ref.tmp) #4 +// CHECK:STDOUT: %call = call noundef i32 @_ZNK6Carbon4Main5ArgsA1FEi(ptr noundef nonnull align 1 %ref.tmp, i32 noundef 123) +// CHECK:STDOUT: call void @_ZN6Carbon4Main5ArgsAD2Ev(ptr noundef nonnull align 1 %ref.tmp) #4 // CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %ref.tmp) #4 // CHECK:STDOUT: ret i32 %call // CHECK:STDOUT: } @@ -217,7 +217,7 @@ fn CallCallF() { Cpp.CallStaticF(); } // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal noundef i32 @_ZNK6Carbon5ArgsA1FEi(ptr noundef nonnull align 1 %this, i32 noundef %0) #2 align 2 { +// CHECK:STDOUT: define internal noundef i32 @_ZNK6Carbon4Main5ArgsA1FEi(ptr noundef nonnull align 1 %this, i32 noundef %0) #2 align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %retval = alloca i32, align 4 // CHECK:STDOUT: %this.addr = alloca ptr, align 8 @@ -231,7 +231,7 @@ fn CallCallF() { Cpp.CallStaticF(); } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable -// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon5ArgsAD2Ev(ptr noundef nonnull align 1 %this) unnamed_addr #3 comdat align 2 { +// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4Main5ArgsAD2Ev(ptr noundef nonnull align 1 %this) unnamed_addr #3 comdat align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !102 @@ -344,7 +344,7 @@ fn CallCallF() { Cpp.CallStaticF(); } // CHECK:STDOUT: !96 = distinct !DISubprogram(name: "CallCallF", linkageName: "_CCallCallF.Main", scope: null, file: !58, line: 18, type: !66, spFlags: DISPFlagDefinition, unit: !59) // CHECK:STDOUT: !99 = !DILocation(line: 18, column: 32, scope: !96) // CHECK:STDOUT: !100 = !DILocation(line: 18, column: 25, scope: !96) -// CHECK:STDOUT: !101 = !{!"p1 _ZTSN6Carbon5ArgsAE", !49, i64 0} +// CHECK:STDOUT: !101 = !{!"p1 _ZTSN6Carbon4Main5ArgsAE", !49, i64 0} // CHECK:STDOUT: !102 = !{!101, !101, i64 0} // CHECK:STDOUT: !103 = !{!55, !55, i64 0} // CHECK:STDOUT: @@ -357,12 +357,12 @@ fn CallCallF() { Cpp.CallStaticF(); } // CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable // CHECK:STDOUT: define dso_local void @_Z11CallStaticFv() #0 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: call void @_ZN6Carbon7StaticA1FEv() +// CHECK:STDOUT: call void @_ZN6Carbon4Main7StaticA1FEv() // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal void @_ZN6Carbon7StaticA1FEv() #1 align 2 { +// CHECK:STDOUT: define internal void @_ZN6Carbon4Main7StaticA1FEv() #1 align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @_CF__carbon_thunk.StaticA.Main() // CHECK:STDOUT: ret void diff --git a/toolchain/lower/testdata/interop/cpp/class/import/dynamic.carbon b/toolchain/lower/testdata/interop/cpp/class/import/dynamic.carbon index 0e9e86760e89..4186f83a0282 100644 --- a/toolchain/lower/testdata/interop/cpp/class/import/dynamic.carbon +++ b/toolchain/lower/testdata/interop/cpp/class/import/dynamic.carbon @@ -55,20 +55,20 @@ fn DoThing() { // CHECK:STDOUT: // CHECK:STDOUT: $_ZN11FurtherBaseC2Ev = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZTVN6Carbon7DerivedE = comdat any +// CHECK:STDOUT: $_ZTVN6Carbon4Main7DerivedE = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZTIN6Carbon7DerivedE = comdat any +// CHECK:STDOUT: $_ZTIN6Carbon4Main7DerivedE = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZTSN6Carbon7DerivedE = comdat any +// CHECK:STDOUT: $_ZTSN6Carbon4Main7DerivedE = comdat any // CHECK:STDOUT: // CHECK:STDOUT: @_ZTV4Base = available_externally constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr @_ZTI4Base, ptr @_ZN11FurtherBase17further_base_funcEv, ptr @_ZNR4Base4funcEv] }, align 8 // CHECK:STDOUT: @_ZTV11FurtherBase = available_externally constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI11FurtherBase, ptr @_ZN11FurtherBase17further_base_funcEv] }, align 8 -// CHECK:STDOUT: @_ZTVN6Carbon7DerivedE = linkonce_odr dso_local constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTIN6Carbon7DerivedE, ptr @_ZN11FurtherBase17further_base_funcEv, ptr @_ZNR6Carbon7Derived4funcEv, ptr @_ZNK6Carbon7Derived10other_funcEv] }, comdat, align 8 +// CHECK:STDOUT: @_ZTVN6Carbon4Main7DerivedE = linkonce_odr dso_local constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTIN6Carbon4Main7DerivedE, ptr @_ZN11FurtherBase17further_base_funcEv, ptr @_ZNR6Carbon4Main7Derived4funcEv, ptr @_ZNK6Carbon4Main7Derived10other_funcEv] }, comdat, align 8 // CHECK:STDOUT: @_ZTI4Base = external constant ptr // CHECK:STDOUT: @_ZTI11FurtherBase = external constant ptr -// CHECK:STDOUT: @_ZTIN6Carbon7DerivedE = linkonce_odr dso_local constant { ptr, ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 16), ptr @_ZTSN6Carbon7DerivedE, ptr @_ZTI4Base }, comdat, align 8 +// CHECK:STDOUT: @_ZTIN6Carbon4Main7DerivedE = linkonce_odr dso_local constant { ptr, ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 16), ptr @_ZTSN6Carbon4Main7DerivedE, ptr @_ZTI4Base }, comdat, align 8 // CHECK:STDOUT: @_ZTVN10__cxxabiv120__si_class_type_infoE = external global [0 x ptr] -// CHECK:STDOUT: @_ZTSN6Carbon7DerivedE = linkonce_odr dso_local constant [18 x i8] c"N6Carbon7DerivedE\00", comdat, align 1 +// CHECK:STDOUT: @_ZTSN6Carbon4Main7DerivedE = linkonce_odr dso_local constant [23 x i8] c"N6Carbon4Main7DerivedE\00", comdat, align 1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: mustprogress noinline nounwind optnone uwtable // CHECK:STDOUT: define dso_local void @_Z3UseR4Base(ptr noundef nonnull align 8 dereferenceable(12) %b) #0 { @@ -170,7 +170,7 @@ fn DoThing() { // CHECK:STDOUT: %.loc31_44.7.base = getelementptr inbounds nuw { [16 x i8] }, ptr %d.var, i32 0, i32 0, !dbg !96 // CHECK:STDOUT: %.loc31_44.8.base = getelementptr inbounds nuw [16 x i8], ptr %.loc31_44.7.base, i32 0, i32 0, !dbg !96 // CHECK:STDOUT: %.loc31_44.9.vptr = getelementptr inbounds nuw [8 x i8], ptr %.loc31_44.8.base, i32 0, i32 0, !dbg !96 -// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTVN6Carbon7DerivedE, i64 16), ptr %.loc31_44.9.vptr, align 8, !dbg !96 +// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTVN6Carbon4Main7DerivedE, i64 16), ptr %.loc31_44.9.vptr, align 8, !dbg !96 // CHECK:STDOUT: %.loc32_11.2.base = getelementptr inbounds nuw { [16 x i8] }, ptr %d.var, i32 0, i32 0, !dbg !100 // CHECK:STDOUT: call void @_Z3UseR4Base(ptr %.loc32_11.2.base), !dbg !101 // CHECK:STDOUT: call void @"_CSelfDestruct.b25525d21a9bd472:core.Destroy.Core"(ptr %d.var), !dbg !95 @@ -194,7 +194,7 @@ fn DoThing() { // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #6 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal void @_ZNR6Carbon7Derived4funcEv(ptr noundef nonnull align 8 dereferenceable(12) %this) unnamed_addr #4 align 2 { +// CHECK:STDOUT: define internal void @_ZNR6Carbon4Main7Derived4funcEv(ptr noundef nonnull align 8 dereferenceable(12) %this) unnamed_addr #4 align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !108 @@ -204,7 +204,7 @@ fn DoThing() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal void @_ZNK6Carbon7Derived10other_funcEv(ptr noundef nonnull align 8 dereferenceable(12) %this) unnamed_addr #4 align 2 { +// CHECK:STDOUT: define internal void @_ZNK6Carbon4Main7Derived10other_funcEv(ptr noundef nonnull align 8 dereferenceable(12) %this) unnamed_addr #4 align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !108 @@ -319,7 +319,7 @@ fn DoThing() { // CHECK:STDOUT: !104 = !{!103, !103, i64 0} // CHECK:STDOUT: !105 = !{!"p1 _ZTS11FurtherBase", !2, i64 0} // CHECK:STDOUT: !106 = !{!105, !105, i64 0} -// CHECK:STDOUT: !107 = !{!"p1 _ZTSN6Carbon7DerivedE", !2, i64 0} +// CHECK:STDOUT: !107 = !{!"p1 _ZTSN6Carbon4Main7DerivedE", !2, i64 0} // CHECK:STDOUT: !108 = !{!107, !107, i64 0} // CHECK:STDOUT: !110 = !{!"int", !1, i64 0} // CHECK:STDOUT: !113 = !{i32 8, !"PIC Level", i32 2} diff --git a/toolchain/lower/testdata/interop/cpp/class/virtual_fn.carbon b/toolchain/lower/testdata/interop/cpp/class/virtual_fn.carbon index 6635eecb05ff..bf60b566e80e 100644 --- a/toolchain/lower/testdata/interop/cpp/class/virtual_fn.carbon +++ b/toolchain/lower/testdata/interop/cpp/class/virtual_fn.carbon @@ -55,41 +55,41 @@ void delete_new_Base() { // CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu" // CHECK:STDOUT: -// CHECK:STDOUT: $_ZN6Carbon5FinalC2Ev = comdat any +// CHECK:STDOUT: $_ZN6Carbon4Main5FinalC2Ev = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZN6Carbon5FinalD2Ev = comdat any +// CHECK:STDOUT: $_ZN6Carbon4Main5FinalD2Ev = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZN6Carbon4BaseC2Ev = comdat any +// CHECK:STDOUT: $_ZN6Carbon4Main4BaseC2Ev = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZN6Carbon5FinalD0Ev = comdat any +// CHECK:STDOUT: $_ZN6Carbon4Main5FinalD0Ev = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZN6Carbon4BaseD2Ev = comdat any +// CHECK:STDOUT: $_ZN6Carbon4Main4BaseD2Ev = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZN6Carbon4BaseD0Ev = comdat any +// CHECK:STDOUT: $_ZN6Carbon4Main4BaseD0Ev = comdat any // CHECK:STDOUT: // CHECK:STDOUT: $_ZN1AC2Ev = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZTVN6Carbon5FinalE = comdat any +// CHECK:STDOUT: $_ZTVN6Carbon4Main5FinalE = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZTVN6Carbon4BaseE = comdat any +// CHECK:STDOUT: $_ZTVN6Carbon4Main4BaseE = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZTIN6Carbon5FinalE = comdat any +// CHECK:STDOUT: $_ZTIN6Carbon4Main5FinalE = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZTSN6Carbon5FinalE = comdat any +// CHECK:STDOUT: $_ZTSN6Carbon4Main5FinalE = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZTIN6Carbon4BaseE = comdat any +// CHECK:STDOUT: $_ZTIN6Carbon4Main4BaseE = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZTSN6Carbon4BaseE = comdat any +// CHECK:STDOUT: $_ZTSN6Carbon4Main4BaseE = comdat any // CHECK:STDOUT: // CHECK:STDOUT: @_ZTV1A = available_externally constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTI1A, ptr @__cxa_pure_virtual, ptr @__cxa_pure_virtual, ptr @_ZNK1A1FEv] }, align 8 -// CHECK:STDOUT: @_ZTVN6Carbon5FinalE = linkonce_odr dso_local constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTIN6Carbon5FinalE, ptr @_ZN6Carbon5FinalD2Ev, ptr @_ZN6Carbon5FinalD0Ev, ptr @_ZNK6Carbon5Final1FEv] }, comdat, align 8 -// CHECK:STDOUT: @_ZTVN6Carbon4BaseE = linkonce_odr dso_local constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTIN6Carbon4BaseE, ptr @_ZN6Carbon4BaseD2Ev, ptr @_ZN6Carbon4BaseD0Ev, ptr @_ZNK6Carbon4Base1FEv] }, comdat, align 8 +// CHECK:STDOUT: @_ZTVN6Carbon4Main5FinalE = linkonce_odr dso_local constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTIN6Carbon4Main5FinalE, ptr @_ZN6Carbon4Main5FinalD2Ev, ptr @_ZN6Carbon4Main5FinalD0Ev, ptr @_ZNK6Carbon4Main5Final1FEv] }, comdat, align 8 +// CHECK:STDOUT: @_ZTVN6Carbon4Main4BaseE = linkonce_odr dso_local constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTIN6Carbon4Main4BaseE, ptr @_ZN6Carbon4Main4BaseD2Ev, ptr @_ZN6Carbon4Main4BaseD0Ev, ptr @_ZNK6Carbon4Main4Base1FEv] }, comdat, align 8 // CHECK:STDOUT: @_ZTI1A = external constant ptr -// CHECK:STDOUT: @_ZTIN6Carbon5FinalE = linkonce_odr dso_local constant { ptr, ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 16), ptr @_ZTSN6Carbon5FinalE, ptr @_ZTI1A }, comdat, align 8 +// CHECK:STDOUT: @_ZTIN6Carbon4Main5FinalE = linkonce_odr dso_local constant { ptr, ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 16), ptr @_ZTSN6Carbon4Main5FinalE, ptr @_ZTI1A }, comdat, align 8 // CHECK:STDOUT: @_ZTVN10__cxxabiv120__si_class_type_infoE = external global [0 x ptr] -// CHECK:STDOUT: @_ZTSN6Carbon5FinalE = linkonce_odr dso_local constant [16 x i8] c"N6Carbon5FinalE\00", comdat, align 1 -// CHECK:STDOUT: @_ZTIN6Carbon4BaseE = linkonce_odr dso_local constant { ptr, ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 16), ptr @_ZTSN6Carbon4BaseE, ptr @_ZTI1A }, comdat, align 8 -// CHECK:STDOUT: @_ZTSN6Carbon4BaseE = linkonce_odr dso_local constant [15 x i8] c"N6Carbon4BaseE\00", comdat, align 1 +// CHECK:STDOUT: @_ZTSN6Carbon4Main5FinalE = linkonce_odr dso_local constant [21 x i8] c"N6Carbon4Main5FinalE\00", comdat, align 1 +// CHECK:STDOUT: @_ZTIN6Carbon4Main4BaseE = linkonce_odr dso_local constant { ptr, ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 16), ptr @_ZTSN6Carbon4Main4BaseE, ptr @_ZTI1A }, comdat, align 8 +// CHECK:STDOUT: @_ZTSN6Carbon4Main4BaseE = linkonce_odr dso_local constant [20 x i8] c"N6Carbon4Main4BaseE\00", comdat, align 1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable // CHECK:STDOUT: define dso_local void @_Z16delete_new_Finalv() #0 { @@ -97,14 +97,14 @@ void delete_new_Base() { // CHECK:STDOUT: %p = alloca ptr, align 8 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %p) #8 // CHECK:STDOUT: %call = call noalias noundef nonnull ptr @_Znwm(i64 noundef 8) #10 -// CHECK:STDOUT: call void @_ZN6Carbon5FinalC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %call) #8 +// CHECK:STDOUT: call void @_ZN6Carbon4Main5FinalC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %call) #8 // CHECK:STDOUT: store ptr %call, ptr %p, align 8, !tbaa !4 // CHECK:STDOUT: %0 = load ptr, ptr %p, align 8, !tbaa !4 // CHECK:STDOUT: %isnull = icmp eq ptr %0, null // CHECK:STDOUT: br i1 %isnull, label %delete.end, label %delete.notnull // CHECK:STDOUT: // CHECK:STDOUT: delete.notnull: ; preds = %entry -// CHECK:STDOUT: call void @_ZN6Carbon5FinalD2Ev(ptr noundef nonnull align 8 dead_on_return(8) dereferenceable(8) %0) #8 +// CHECK:STDOUT: call void @_ZN6Carbon4Main5FinalD2Ev(ptr noundef nonnull align 8 dead_on_return(8) dereferenceable(8) %0) #8 // CHECK:STDOUT: call void @_ZdlPvm(ptr noundef %0, i64 noundef 8) #11 // CHECK:STDOUT: br label %delete.end // CHECK:STDOUT: @@ -120,18 +120,18 @@ void delete_new_Base() { // CHECK:STDOUT: declare noundef nonnull ptr @_Znwm(i64 noundef) #2 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable -// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon5FinalC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #3 comdat align 2 { +// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4Main5FinalC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #3 comdat align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !4 // CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8 // CHECK:STDOUT: call void @_ZN1AC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %this1) #8 -// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTVN6Carbon5FinalE, i64 16), ptr %this1, align 8, !tbaa !8 +// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTVN6Carbon4Main5FinalE, i64 16), ptr %this1, align 8, !tbaa !8 // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable -// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon5FinalD2Ev(ptr noundef nonnull align 8 dead_on_return(8) dereferenceable(8) %this) unnamed_addr #3 comdat align 2 { +// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4Main5FinalD2Ev(ptr noundef nonnull align 8 dead_on_return(8) dereferenceable(8) %this) unnamed_addr #3 comdat align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !4 @@ -153,7 +153,7 @@ void delete_new_Base() { // CHECK:STDOUT: %p = alloca ptr, align 8 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %p) #8 // CHECK:STDOUT: %call = call noalias noundef nonnull ptr @_Znwm(i64 noundef 8) #10 -// CHECK:STDOUT: call void @_ZN6Carbon4BaseC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %call) #8 +// CHECK:STDOUT: call void @_ZN6Carbon4Main4BaseC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %call) #8 // CHECK:STDOUT: store ptr %call, ptr %p, align 8, !tbaa !6 // CHECK:STDOUT: %0 = load ptr, ptr %p, align 8, !tbaa !6 // CHECK:STDOUT: %isnull = icmp eq ptr %0, null @@ -172,13 +172,13 @@ void delete_new_Base() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable -// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4BaseC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #3 comdat align 2 { +// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4Main4BaseC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #3 comdat align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !6 // CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8 // CHECK:STDOUT: call void @_ZN1AC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %this1) #8 -// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTVN6Carbon4BaseE, i64 16), ptr %this1, align 8, !tbaa !8 +// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTVN6Carbon4Main4BaseE, i64 16), ptr %this1, align 8, !tbaa !8 // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: @@ -304,18 +304,18 @@ void delete_new_Base() { // CHECK:STDOUT: declare void @_ZNK1A1FEv(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #9 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable -// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon5FinalD0Ev(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #3 comdat align 2 { +// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4Main5FinalD0Ev(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #3 comdat align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !4 // CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8 -// CHECK:STDOUT: call void @_ZN6Carbon5FinalD2Ev(ptr noundef nonnull align 8 dead_on_return(8) dereferenceable(8) %this1) #8 +// CHECK:STDOUT: call void @_ZN6Carbon4Main5FinalD2Ev(ptr noundef nonnull align 8 dead_on_return(8) dereferenceable(8) %this1) #8 // CHECK:STDOUT: call void @_ZdlPvm(ptr noundef %this1, i64 noundef 8) #11 // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal void @_ZNK6Carbon5Final1FEv(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #5 align 2 { +// CHECK:STDOUT: define internal void @_ZNK6Carbon4Main5Final1FEv(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #5 align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !4 @@ -325,30 +325,30 @@ void delete_new_Base() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable -// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4BaseD2Ev(ptr noundef nonnull align 8 dead_on_return(8) dereferenceable(8) %this) unnamed_addr #3 comdat align 2 { +// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4Main4BaseD2Ev(ptr noundef nonnull align 8 dead_on_return(8) dereferenceable(8) %this) unnamed_addr #3 comdat align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !6 // CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8 -// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTVN6Carbon4BaseE, i64 16), ptr %this1, align 8, !tbaa !8 +// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTVN6Carbon4Main4BaseE, i64 16), ptr %this1, align 8, !tbaa !8 // CHECK:STDOUT: call void @"_C__destroy_thunk:thunk.Base.Main"(ptr noundef nonnull align 8 dereferenceable(8) %this1) // CHECK:STDOUT: call void @_ZN1AD2Ev(ptr noundef nonnull align 8 dead_on_return(8) dereferenceable(8) %this1) #8 // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable -// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4BaseD0Ev(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #3 comdat align 2 { +// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4Main4BaseD0Ev(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #3 comdat align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !6 // CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8 -// CHECK:STDOUT: call void @_ZN6Carbon4BaseD2Ev(ptr noundef nonnull align 8 dead_on_return(8) dereferenceable(8) %this1) #8 +// CHECK:STDOUT: call void @_ZN6Carbon4Main4BaseD2Ev(ptr noundef nonnull align 8 dead_on_return(8) dereferenceable(8) %this1) #8 // CHECK:STDOUT: call void @_ZdlPvm(ptr noundef %this1, i64 noundef 8) #11 // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal void @_ZNK6Carbon4Base1FEv(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #5 align 2 { +// CHECK:STDOUT: define internal void @_ZNK6Carbon4Main4Base1FEv(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #5 align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !6 @@ -371,9 +371,9 @@ void delete_new_Base() { // CHECK:STDOUT: declare void @_ZN1AD2Ev(ptr noundef nonnull align 8 dead_on_return(8) dereferenceable(8)) unnamed_addr #7 // CHECK:STDOUT: // CHECK:STDOUT: ; uselistorder directives -// CHECK:STDOUT: uselistorder ptr @_ZN6Carbon5FinalD2Ev, { 2, 1, 0 } +// CHECK:STDOUT: uselistorder ptr @_ZN6Carbon4Main5FinalD2Ev, { 2, 1, 0 } // CHECK:STDOUT: uselistorder ptr @__cxa_pure_virtual, { 1, 0 } -// CHECK:STDOUT: uselistorder ptr @_ZN6Carbon4BaseD2Ev, { 1, 0 } +// CHECK:STDOUT: uselistorder ptr @_ZN6Carbon4Main4BaseD2Ev, { 1, 0 } // CHECK:STDOUT: uselistorder ptr @_ZN1AC2Ev, { 1, 0 } // CHECK:STDOUT: uselistorder ptr @_ZN1AD2Ev, { 1, 0 } // CHECK:STDOUT: @@ -397,9 +397,9 @@ void delete_new_Base() { // CHECK:STDOUT: !0 = !{!"Simple C++ TBAA"} // CHECK:STDOUT: !1 = !{!"omnipotent char", !0, i64 0} // CHECK:STDOUT: !2 = !{!"any pointer", !1, i64 0} -// CHECK:STDOUT: !3 = !{!"p1 _ZTSN6Carbon5FinalE", !2, i64 0} +// CHECK:STDOUT: !3 = !{!"p1 _ZTSN6Carbon4Main5FinalE", !2, i64 0} // CHECK:STDOUT: !4 = !{!3, !3, i64 0} -// CHECK:STDOUT: !5 = !{!"p1 _ZTSN6Carbon4BaseE", !2, i64 0} +// CHECK:STDOUT: !5 = !{!"p1 _ZTSN6Carbon4Main4BaseE", !2, i64 0} // CHECK:STDOUT: !6 = !{!5, !5, i64 0} // CHECK:STDOUT: !7 = !{!"vtable pointer", !0, i64 0} // CHECK:STDOUT: !8 = !{!7, !7, i64 0} diff --git a/toolchain/lower/testdata/interop/cpp/class/virtual_fn_carbon_only.carbon b/toolchain/lower/testdata/interop/cpp/class/virtual_fn_carbon_only.carbon index 1f40236560d3..1b06ffb4fb76 100644 --- a/toolchain/lower/testdata/interop/cpp/class/virtual_fn_carbon_only.carbon +++ b/toolchain/lower/testdata/interop/cpp/class/virtual_fn_carbon_only.carbon @@ -36,24 +36,24 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: $_ZTV1X = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZTVN6Carbon1ZE = comdat any +// CHECK:STDOUT: $_ZTVN6Carbon4Main1ZE = comdat any // CHECK:STDOUT: // CHECK:STDOUT: $_ZTI1X = comdat any // CHECK:STDOUT: // CHECK:STDOUT: $_ZTS1X = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZTIN6Carbon1ZE = comdat any +// CHECK:STDOUT: $_ZTIN6Carbon4Main1ZE = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZTSN6Carbon1ZE = comdat any +// CHECK:STDOUT: $_ZTSN6Carbon4Main1ZE = comdat any // CHECK:STDOUT: // CHECK:STDOUT: @_ZTV1X = linkonce_odr dso_local constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI1X, ptr @_ZN1X1fEv] }, comdat, align 8 -// CHECK:STDOUT: @_ZTVN6Carbon1ZE = linkonce_odr dso_local constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTIN6Carbon1ZE, ptr @_ZN6Carbon1Z1fEv] }, comdat, align 8 +// CHECK:STDOUT: @_ZTVN6Carbon4Main1ZE = linkonce_odr dso_local constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTIN6Carbon4Main1ZE, ptr @_ZN6Carbon4Main1Z1fEv] }, comdat, align 8 // CHECK:STDOUT: @_ZTI1X = linkonce_odr dso_local constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 16), ptr @_ZTS1X }, comdat, align 8 // CHECK:STDOUT: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr] // CHECK:STDOUT: @_ZTS1X = linkonce_odr dso_local constant [3 x i8] c"1X\00", comdat, align 1 -// CHECK:STDOUT: @_ZTIN6Carbon1ZE = linkonce_odr dso_local constant { ptr, ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 16), ptr @_ZTSN6Carbon1ZE, ptr @_ZTI1X }, comdat, align 8 +// CHECK:STDOUT: @_ZTIN6Carbon4Main1ZE = linkonce_odr dso_local constant { ptr, ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 16), ptr @_ZTSN6Carbon4Main1ZE, ptr @_ZTI1X }, comdat, align 8 // CHECK:STDOUT: @_ZTVN10__cxxabiv120__si_class_type_infoE = external global [0 x ptr] -// CHECK:STDOUT: @_ZTSN6Carbon1ZE = linkonce_odr dso_local constant [12 x i8] c"N6Carbon1ZE\00", comdat, align 1 +// CHECK:STDOUT: @_ZTSN6Carbon4Main1ZE = linkonce_odr dso_local constant [17 x i8] c"N6Carbon4Main1ZE\00", comdat, align 1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable // CHECK:STDOUT: define linkonce_odr dso_local void @_ZN1X1fEv(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #0 comdat align 2 { @@ -136,7 +136,7 @@ fn F() { // CHECK:STDOUT: call void @_ZN1XC1Ev.carbon_thunk.(ptr %.loc24_32.1.base), !dbg !54 // CHECK:STDOUT: %.loc24_32.7.base = getelementptr inbounds nuw { [8 x i8] }, ptr %_.var, i32 0, i32 0, !dbg !53 // CHECK:STDOUT: %.loc24_32.8.vptr = getelementptr inbounds nuw [8 x i8], ptr %.loc24_32.7.base, i32 0, i32 0, !dbg !53 -// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 8) (i8, ptr @_ZTVN6Carbon1ZE, i64 16), ptr %.loc24_32.8.vptr, align 8, !dbg !53 +// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 8) (i8, ptr @_ZTVN6Carbon4Main1ZE, i64 16), ptr %.loc24_32.8.vptr, align 8, !dbg !53 // CHECK:STDOUT: call void @"_CSelfDestruct.680f7fa3ef86df7a:core.Destroy.Core"(ptr %_.var), !dbg !52 // CHECK:STDOUT: ret void, !dbg !56 // CHECK:STDOUT: } @@ -155,7 +155,7 @@ fn F() { // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #4 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal void @_ZN6Carbon1Z1fEv(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #3 align 2 { +// CHECK:STDOUT: define internal void @_ZN6Carbon4Main1Z1fEv(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #3 align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !65 @@ -242,7 +242,7 @@ fn F() { // CHECK:STDOUT: !61 = !{!60, !60, i64 0} // CHECK:STDOUT: !62 = !{!"vtable pointer", !57, i64 0} // CHECK:STDOUT: !63 = !{!62, !62, i64 0} -// CHECK:STDOUT: !64 = !{!"p1 _ZTSN6Carbon1ZE", !59, i64 0} +// CHECK:STDOUT: !64 = !{!"p1 _ZTSN6Carbon4Main1ZE", !59, i64 0} // CHECK:STDOUT: !65 = !{!64, !64, i64 0} // CHECK:STDOUT: !68 = !{i32 8, !"PIC Level", i32 2} // CHECK:STDOUT: !69 = !{i32 7, !"PIE Level", i32 2} diff --git a/toolchain/lower/testdata/interop/cpp/function/export/constructor.carbon b/toolchain/lower/testdata/interop/cpp/function/export/constructor.carbon index 619579fc0a0f..69100777b268 100644 --- a/toolchain/lower/testdata/interop/cpp/function/export/constructor.carbon +++ b/toolchain/lower/testdata/interop/cpp/function/export/constructor.carbon @@ -31,17 +31,17 @@ void f() { // CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu" // CHECK:STDOUT: -// CHECK:STDOUT: %"class.Carbon::OneArg" = type {} +// CHECK:STDOUT: %"class.Carbon::Main::OneArg" = type {} // CHECK:STDOUT: -// CHECK:STDOUT: $_ZN6Carbon6OneArgD2Ev = comdat any +// CHECK:STDOUT: $_ZN6Carbon4Main6OneArgD2Ev = comdat any // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: mustprogress uwtable // CHECK:STDOUT: define dso_local void @_Z1fv() #0 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: %a = alloca %"class.Carbon::OneArg", align 1 +// CHECK:STDOUT: %a = alloca %"class.Carbon::Main::OneArg", align 1 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %a) #5 -// CHECK:STDOUT: call void @_ZN6Carbon6OneArgC2Ei(ptr noundef nonnull align 1 %a, i32 noundef 42) -// CHECK:STDOUT: call void @_ZN6Carbon6OneArgD2Ev(ptr noundef nonnull align 1 %a) #5 +// CHECK:STDOUT: call void @_ZN6Carbon4Main6OneArgC2Ei(ptr noundef nonnull align 1 %a, i32 noundef 42) +// CHECK:STDOUT: call void @_ZN6Carbon4Main6OneArgD2Ev(ptr noundef nonnull align 1 %a) #5 // CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %a) #5 // CHECK:STDOUT: ret void // CHECK:STDOUT: } @@ -50,7 +50,7 @@ void f() { // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal void @_ZN6Carbon6OneArgC2Ei(ptr noundef nonnull align 1 %this, i32 noundef %0) unnamed_addr #2 align 2 { +// CHECK:STDOUT: define internal void @_ZN6Carbon4Main6OneArgC2Ei(ptr noundef nonnull align 1 %this, i32 noundef %0) unnamed_addr #2 align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: %.addr = alloca i32, align 4 @@ -62,7 +62,7 @@ void f() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable -// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon6OneArgD2Ev(ptr noundef nonnull align 1 %this) unnamed_addr #3 comdat align 2 { +// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4Main6OneArgD2Ev(ptr noundef nonnull align 1 %this) unnamed_addr #3 comdat align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !36 @@ -144,7 +144,7 @@ void f() { // CHECK:STDOUT: !32 = !{!"Simple C++ TBAA"} // CHECK:STDOUT: !33 = !{!"omnipotent char", !32, i64 0} // CHECK:STDOUT: !34 = !{!"any pointer", !33, i64 0} -// CHECK:STDOUT: !35 = !{!"p1 _ZTSN6Carbon6OneArgE", !34, i64 0} +// CHECK:STDOUT: !35 = !{!"p1 _ZTSN6Carbon4Main6OneArgE", !34, i64 0} // CHECK:STDOUT: !36 = !{!35, !35, i64 0} // CHECK:STDOUT: !37 = !{!"int", !33, i64 0} // CHECK:STDOUT: !38 = !{!37, !37, i64 0} diff --git a/toolchain/lower/testdata/interop/cpp/function/export/function.carbon b/toolchain/lower/testdata/interop/cpp/function/export/function.carbon index f1717ee39864..009bb60ae6cb 100644 --- a/toolchain/lower/testdata/interop/cpp/function/export/function.carbon +++ b/toolchain/lower/testdata/interop/cpp/function/export/function.carbon @@ -352,12 +352,12 @@ fn CallCallBase() { Cpp.CallBase(); } // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress uwtable // CHECK:STDOUT: define linkonce_odr dso_local void @_Z2G1v() #1 comdat { // CHECK:STDOUT: entry: -// CHECK:STDOUT: call void @_ZN6CarbonL1FEv() +// CHECK:STDOUT: call void @_ZN6Carbon4MainL1FEv() // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal void @_ZN6CarbonL1FEv() #2 { +// CHECK:STDOUT: define internal void @_ZN6Carbon4MainL1FEv() #2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @_CF__carbon_thunk.Main() // CHECK:STDOUT: ret void @@ -424,12 +424,12 @@ fn CallCallBase() { Cpp.CallBase(); } // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress uwtable // CHECK:STDOUT: define linkonce_odr dso_local void @_Z8CallBasev() #1 comdat { // CHECK:STDOUT: entry: -// CHECK:STDOUT: call void @_ZN6CarbonL4baseEv() +// CHECK:STDOUT: call void @_ZN6Carbon4MainL4baseEv() // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal void @_ZN6CarbonL4baseEv() #2 { +// CHECK:STDOUT: define internal void @_ZN6Carbon4MainL4baseEv() #2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @_Cbase__carbon_thunk.Main() // CHECK:STDOUT: ret void diff --git a/toolchain/lower/testdata/interop/cpp/function/export/generic.carbon b/toolchain/lower/testdata/interop/cpp/function/export/generic.carbon index ea3da8b56cc8..de2b55c89925 100644 --- a/toolchain/lower/testdata/interop/cpp/function/export/generic.carbon +++ b/toolchain/lower/testdata/interop/cpp/function/export/generic.carbon @@ -52,37 +52,37 @@ fn Run() { // CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu" // CHECK:STDOUT: -// CHECK:STDOUT: %"class.Carbon::A" = type {} -// CHECK:STDOUT: %"class.Carbon::B" = type {} +// CHECK:STDOUT: %"class.Carbon::Main::A" = type {} +// CHECK:STDOUT: %"class.Carbon::Main::B" = type {} // CHECK:STDOUT: -// CHECK:STDOUT: $_ZN6Carbon1AD2Ev = comdat any +// CHECK:STDOUT: $_ZN6Carbon4Main1AD2Ev = comdat any // CHECK:STDOUT: -// CHECK:STDOUT: $_ZN6Carbon1BD2Ev = comdat any +// CHECK:STDOUT: $_ZN6Carbon4Main1BD2Ev = comdat any // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: mustprogress uwtable // CHECK:STDOUT: define dso_local void @_Z1Gv() #0 personality ptr @__gxx_personality_v0 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: %a = alloca %"class.Carbon::A", align 1 -// CHECK:STDOUT: %b = alloca %"class.Carbon::B", align 1 -// CHECK:STDOUT: %agg.tmp = alloca %"class.Carbon::A", align 1 +// CHECK:STDOUT: %a = alloca %"class.Carbon::Main::A", align 1 +// CHECK:STDOUT: %b = alloca %"class.Carbon::Main::B", align 1 +// CHECK:STDOUT: %agg.tmp = alloca %"class.Carbon::Main::A", align 1 // CHECK:STDOUT: %exn.slot = alloca ptr, align 8 // CHECK:STDOUT: %ehselector.slot = alloca i32, align 4 -// CHECK:STDOUT: %agg.tmp1 = alloca %"class.Carbon::B", align 1 +// CHECK:STDOUT: %agg.tmp1 = alloca %"class.Carbon::Main::B", align 1 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %a) #4 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %b) #4 -// CHECK:STDOUT: invoke void @_ZN6CarbonL1FENS_1AE() +// CHECK:STDOUT: invoke void @_ZN6Carbon4MainL1FENS0_1AE() // CHECK:STDOUT: to label %invoke.cont unwind label %lpad // CHECK:STDOUT: // CHECK:STDOUT: invoke.cont: ; preds = %entry -// CHECK:STDOUT: call void @_ZN6Carbon1AD2Ev(ptr noundef nonnull align 1 %agg.tmp) #4 -// CHECK:STDOUT: invoke void @_ZN6CarbonL1FENS_1BE() +// CHECK:STDOUT: call void @_ZN6Carbon4Main1AD2Ev(ptr noundef nonnull align 1 %agg.tmp) #4 +// CHECK:STDOUT: invoke void @_ZN6Carbon4MainL1FENS0_1BE() // CHECK:STDOUT: to label %invoke.cont3 unwind label %lpad2 // CHECK:STDOUT: // CHECK:STDOUT: invoke.cont3: ; preds = %invoke.cont -// CHECK:STDOUT: call void @_ZN6Carbon1BD2Ev(ptr noundef nonnull align 1 %agg.tmp1) #4 -// CHECK:STDOUT: call void @_ZN6Carbon1BD2Ev(ptr noundef nonnull align 1 %b) #4 +// CHECK:STDOUT: call void @_ZN6Carbon4Main1BD2Ev(ptr noundef nonnull align 1 %agg.tmp1) #4 +// CHECK:STDOUT: call void @_ZN6Carbon4Main1BD2Ev(ptr noundef nonnull align 1 %b) #4 // CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %b) #4 -// CHECK:STDOUT: call void @_ZN6Carbon1AD2Ev(ptr noundef nonnull align 1 %a) #4 +// CHECK:STDOUT: call void @_ZN6Carbon4Main1AD2Ev(ptr noundef nonnull align 1 %a) #4 // CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %a) #4 // CHECK:STDOUT: ret void // CHECK:STDOUT: @@ -93,7 +93,7 @@ fn Run() { // CHECK:STDOUT: store ptr %1, ptr %exn.slot, align 8 // CHECK:STDOUT: %2 = extractvalue { ptr, i32 } %0, 1 // CHECK:STDOUT: store i32 %2, ptr %ehselector.slot, align 4 -// CHECK:STDOUT: call void @_ZN6Carbon1AD2Ev(ptr noundef nonnull align 1 %agg.tmp) #4 +// CHECK:STDOUT: call void @_ZN6Carbon4Main1AD2Ev(ptr noundef nonnull align 1 %agg.tmp) #4 // CHECK:STDOUT: br label %ehcleanup // CHECK:STDOUT: // CHECK:STDOUT: lpad2: ; preds = %invoke.cont @@ -103,13 +103,13 @@ fn Run() { // CHECK:STDOUT: store ptr %4, ptr %exn.slot, align 8 // CHECK:STDOUT: %5 = extractvalue { ptr, i32 } %3, 1 // CHECK:STDOUT: store i32 %5, ptr %ehselector.slot, align 4 -// CHECK:STDOUT: call void @_ZN6Carbon1BD2Ev(ptr noundef nonnull align 1 %agg.tmp1) #4 +// CHECK:STDOUT: call void @_ZN6Carbon4Main1BD2Ev(ptr noundef nonnull align 1 %agg.tmp1) #4 // CHECK:STDOUT: br label %ehcleanup // CHECK:STDOUT: // CHECK:STDOUT: ehcleanup: ; preds = %lpad2, %lpad -// CHECK:STDOUT: call void @_ZN6Carbon1BD2Ev(ptr noundef nonnull align 1 %b) #4 +// CHECK:STDOUT: call void @_ZN6Carbon4Main1BD2Ev(ptr noundef nonnull align 1 %b) #4 // CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %b) #4 -// CHECK:STDOUT: call void @_ZN6Carbon1AD2Ev(ptr noundef nonnull align 1 %a) #4 +// CHECK:STDOUT: call void @_ZN6Carbon4Main1AD2Ev(ptr noundef nonnull align 1 %a) #4 // CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %a) #4 // CHECK:STDOUT: br label %eh.resume // CHECK:STDOUT: @@ -129,9 +129,9 @@ fn Run() { // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal void @_ZN6CarbonL1FENS_1AE() #2 { +// CHECK:STDOUT: define internal void @_ZN6Carbon4MainL1FENS0_1AE() #2 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: %0 = alloca %"class.Carbon::A", align 1 +// CHECK:STDOUT: %0 = alloca %"class.Carbon::Main::A", align 1 // CHECK:STDOUT: call void @_CF__carbon_thunk.26f2099a79512a5d.Main(ptr noundef nonnull align 1 %0) // CHECK:STDOUT: ret void // CHECK:STDOUT: } @@ -139,7 +139,7 @@ fn Run() { // CHECK:STDOUT: declare i32 @__gxx_personality_v0(...) // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable -// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon1AD2Ev(ptr noundef nonnull align 1 %this) unnamed_addr #3 comdat align 2 { +// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4Main1AD2Ev(ptr noundef nonnull align 1 %this) unnamed_addr #3 comdat align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !75 @@ -149,15 +149,15 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal void @_ZN6CarbonL1FENS_1BE() #2 { +// CHECK:STDOUT: define internal void @_ZN6Carbon4MainL1FENS0_1BE() #2 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: %0 = alloca %"class.Carbon::B", align 1 +// CHECK:STDOUT: %0 = alloca %"class.Carbon::Main::B", align 1 // CHECK:STDOUT: call void @_CF__carbon_thunk.7a3b9f04ddf4269e.Main(ptr noundef nonnull align 1 %0) // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable -// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon1BD2Ev(ptr noundef nonnull align 1 %this) unnamed_addr #3 comdat align 2 { +// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon4Main1BD2Ev(ptr noundef nonnull align 1 %this) unnamed_addr #3 comdat align 2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %this.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !77 @@ -250,8 +250,8 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: ; uselistorder directives // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 1, 0 } -// CHECK:STDOUT: uselistorder ptr @_ZN6Carbon1AD2Ev, { 0, 2, 1, 3 } -// CHECK:STDOUT: uselistorder ptr @_ZN6Carbon1BD2Ev, { 0, 2, 1, 3 } +// CHECK:STDOUT: uselistorder ptr @_ZN6Carbon4Main1AD2Ev, { 0, 2, 1, 3 } +// CHECK:STDOUT: uselistorder ptr @_ZN6Carbon4Main1BD2Ev, { 0, 2, 1, 3 } // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.end.p0, { 3, 1, 2, 0 } // CHECK:STDOUT: // CHECK:STDOUT: attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } @@ -327,9 +327,9 @@ fn Run() { // CHECK:STDOUT: !71 = !{!"Simple C++ TBAA"} // CHECK:STDOUT: !72 = !{!"omnipotent char", !71, i64 0} // CHECK:STDOUT: !73 = !{!"any pointer", !72, i64 0} -// CHECK:STDOUT: !74 = !{!"p1 _ZTSN6Carbon1AE", !73, i64 0} +// CHECK:STDOUT: !74 = !{!"p1 _ZTSN6Carbon4Main1AE", !73, i64 0} // CHECK:STDOUT: !75 = !{!74, !74, i64 0} -// CHECK:STDOUT: !76 = !{!"p1 _ZTSN6Carbon1BE", !73, i64 0} +// CHECK:STDOUT: !76 = !{!"p1 _ZTSN6Carbon4Main1BE", !73, i64 0} // CHECK:STDOUT: !77 = !{!76, !76, i64 0} // CHECK:STDOUT: !78 = !{i32 8, !"PIC Level", i32 2} // CHECK:STDOUT: !79 = !{i32 7, !"PIE Level", i32 2} diff --git a/toolchain/lower/testdata/interop/cpp/function/import/method_ptr.carbon b/toolchain/lower/testdata/interop/cpp/function/import/method_ptr.carbon index c4a0ad44c44c..f7a118c9ed31 100644 --- a/toolchain/lower/testdata/interop/cpp/function/import/method_ptr.carbon +++ b/toolchain/lower/testdata/interop/cpp/function/import/method_ptr.carbon @@ -285,7 +285,7 @@ fn F() { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.loc10_29.3.temp = alloca ptr, align 8, !dbg !60 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc10_29.3.temp), !dbg !60 -// CHECK:STDOUT: call void @_Z20TakeGenericMethodPtrIN6Carbon1CEEvMT_KFvvE.carbon_thunk._(ptr @.b35), !dbg !61 +// CHECK:STDOUT: call void @_Z20TakeGenericMethodPtrIN6Carbon4Main1CEEvMT_KFvvE.carbon_thunk._(ptr @.b35), !dbg !61 // CHECK:STDOUT: call void @"_CSelfDestruct.659d177172b60c17:core.Destroy.Core"(ptr @.b35), !dbg !60 // CHECK:STDOUT: ret void, !dbg !62 // CHECK:STDOUT: } @@ -317,7 +317,7 @@ fn F() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable -// CHECK:STDOUT: define internal void @_Z20TakeGenericMethodPtrIN6Carbon1CEEvMT_KFvvE.carbon_thunk._(ptr noundef %ptr) #2 { +// CHECK:STDOUT: define internal void @_Z20TakeGenericMethodPtrIN6Carbon4Main1CEEvMT_KFvvE.carbon_thunk._(ptr noundef %ptr) #2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %ptr.addr = alloca ptr, align 8 // CHECK:STDOUT: %coerce = alloca { i64, i64 }, align 8 @@ -329,7 +329,7 @@ fn F() { // CHECK:STDOUT: %3 = load i64, ptr %2, align 8 // CHECK:STDOUT: %4 = getelementptr inbounds nuw { i64, i64 }, ptr %coerce, i32 0, i32 1 // CHECK:STDOUT: %5 = load i64, ptr %4, align 8 -// CHECK:STDOUT: call void @_Z20TakeGenericMethodPtrIN6Carbon1CEEvMT_KFvvE(i64 %3, i64 %5) +// CHECK:STDOUT: call void @_Z20TakeGenericMethodPtrIN6Carbon4Main1CEEvMT_KFvvE(i64 %3, i64 %5) // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: @@ -342,7 +342,7 @@ fn F() { // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #3 // CHECK:STDOUT: -// CHECK:STDOUT: declare void @_Z20TakeGenericMethodPtrIN6Carbon1CEEvMT_KFvvE(i64, i64) #4 +// CHECK:STDOUT: declare void @_Z20TakeGenericMethodPtrIN6Carbon4Main1CEEvMT_KFvvE(i64, i64) #4 // CHECK:STDOUT: // CHECK:STDOUT: attributes #0 = { nounwind } // CHECK:STDOUT: attributes #1 = { alwaysinline nounwind } diff --git a/toolchain/lower/testdata/interop/cpp/issue7142.carbon b/toolchain/lower/testdata/interop/cpp/issue7142.carbon index 11df092a9793..877f219df8ff 100644 --- a/toolchain/lower/testdata/interop/cpp/issue7142.carbon +++ b/toolchain/lower/testdata/interop/cpp/issue7142.carbon @@ -33,7 +33,7 @@ void f() { // CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu" // CHECK:STDOUT: -// CHECK:STDOUT: %"class.Carbon::A" = type { i32 } +// CHECK:STDOUT: %"class.Carbon::Main::A" = type { i32 } // CHECK:STDOUT: // CHECK:STDOUT: $_ZN1S4VendEv = comdat any // CHECK:STDOUT: @@ -47,8 +47,8 @@ void f() { // CHECK:STDOUT: ; Function Attrs: mustprogress uwtable // CHECK:STDOUT: define linkonce_odr dso_local noundef i32 @_ZN1S4VendEv() #0 comdat align 2 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: %call = call noundef ptr @_ZN6CarbonL3GetEv() -// CHECK:STDOUT: %price = getelementptr inbounds nuw %"class.Carbon::A", ptr %call, i32 0, i32 0 +// CHECK:STDOUT: %call = call noundef ptr @_ZN6Carbon4MainL3GetEv() +// CHECK:STDOUT: %price = getelementptr inbounds nuw %"class.Carbon::Main::A", ptr %call, i32 0, i32 0 // CHECK:STDOUT: %0 = load i32, ptr %price, align 4, !tbaa !46 // CHECK:STDOUT: ret i32 %0 // CHECK:STDOUT: } @@ -107,7 +107,7 @@ void f() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable -// CHECK:STDOUT: define internal noundef ptr @_ZN6CarbonL3GetEv() #3 { +// CHECK:STDOUT: define internal noundef ptr @_ZN6Carbon4MainL3GetEv() #3 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %retval = alloca ptr, align 8 // CHECK:STDOUT: call void @_CGet__carbon_thunk.Main(ptr noundef nonnull align 8 dereferenceable(8) %retval) @@ -165,7 +165,7 @@ void f() { // CHECK:STDOUT: !42 = !{!"Simple C++ TBAA"} // CHECK:STDOUT: !43 = !{!"omnipotent char", !42, i64 0} // CHECK:STDOUT: !44 = !{!"int", !43, i64 0} -// CHECK:STDOUT: !45 = !{!"_ZTSN6Carbon1AE", !44, i64 0} +// CHECK:STDOUT: !45 = !{!"_ZTSN6Carbon4Main1AE", !44, i64 0} // CHECK:STDOUT: !46 = !{!45, !44, i64 0} // CHECK:STDOUT: !49 = !{i32 8, !"PIC Level", i32 2} // CHECK:STDOUT: !50 = !{i32 7, !"PIE Level", i32 2} diff --git a/toolchain/sem_ir/cpp_domain.h b/toolchain/sem_ir/cpp_domain.h index 45bf8fdadc52..808444dfd91b 100644 --- a/toolchain/sem_ir/cpp_domain.h +++ b/toolchain/sem_ir/cpp_domain.h @@ -17,6 +17,7 @@ namespace clang { class CodeGenerator; class CompilerInstance; class Module; +class NamespaceDecl; class Parser; } // namespace clang @@ -67,6 +68,9 @@ class CppDomain { auto header_modules() -> llvm::StringMap& { return header_modules_; } + auto package_namespaces() -> llvm::StringMap& { + return package_namespaces_; + } private: std::shared_ptr clang_instance_; @@ -74,6 +78,7 @@ class CppDomain { Map code_generators_; Map modules_; llvm::StringMap header_modules_; + llvm::StringMap package_namespaces_; llvm::LLVMContext* llvm_context_ = nullptr; };