Index: lib/CodeGen/CGDebugInfo.cpp =================================================================== --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -3375,6 +3375,10 @@ llvm::DINameSpace NS = DBuilder.createNameSpace(Context, NSDecl->getName(), FileD, LineNo); NameSpaceCache[NSDecl].reset(NS); + if (CGM.getTarget().getTriple().isPS4CPU() && NSDecl->isAnonymousNamespace()) { + DBuilder.createImportedModule( + getContextDescriptor(dyn_cast(NSDecl->getDeclContext())), NS, 0); + } return NS; } Index: test/CodeGenCXX/debug-info-anon-namespace.cpp =================================================================== --- test/CodeGenCXX/debug-info-anon-namespace.cpp +++ test/CodeGenCXX/debug-info-anon-namespace.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-scei-ps4 -O0 %s -o - | FileCheck --check-prefix=PS4 %s +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-unknown-linux-gnu -O0 %s -o - | FileCheck --check-prefix=NON-PS4 %s + +namespace +{ + int a = 5; +} +int *b = &a; + +// PS4: [[NS:![0-9]+]] = !MDNamespace +// PS4: !MDImportedEntity(tag: DW_TAG_imported_module, scope: !0, entity: [[NS]]) +// NON-PS4-NOT: !MDImportedEntity +