@@ -300,17 +300,26 @@ const DISubprogram *CodeViewDebug::collectParentScopeNames(
300300}
301301
302302static std::string formatNestedName (ArrayRef<StringRef> QualifiedNameComponents,
303- StringRef TypeName) {
303+ StringRef TypeName,
304+ const std::string &Separator) {
304305 std::string FullyQualifiedName;
305306 for (StringRef QualifiedNameComponent :
306307 llvm::reverse (QualifiedNameComponents)) {
307308 FullyQualifiedName.append (std::string (QualifiedNameComponent));
308- FullyQualifiedName.append (" :: " );
309+ FullyQualifiedName.append (Separator );
309310 }
310311 FullyQualifiedName.append (std::string (TypeName));
311312 return FullyQualifiedName;
312313}
313314
315+ // Added for LDC: use `.` as scope separator for compile units with D language
316+ // tag.
317+ const char *CodeViewDebug::getScopeSeparator () const {
318+ NamedMDNode *CUs = MMI->getModule ()->getNamedMetadata (" llvm.dbg.cu" );
319+ const DICompileUnit *CU = cast<DICompileUnit>(*CUs->operands ().begin ());
320+ return CU->getSourceLanguage () == dwarf::DW_LANG_D ? " ." : " ::" ;
321+ }
322+
314323struct CodeViewDebug ::TypeLoweringScope {
315324 TypeLoweringScope (CodeViewDebug &CVD) : CVD(CVD) { ++CVD.TypeEmissionLevel ; }
316325 ~TypeLoweringScope () {
@@ -331,7 +340,7 @@ std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope,
331340 TypeLoweringScope S (*this );
332341 SmallVector<StringRef, 5 > QualifiedNameComponents;
333342 collectParentScopeNames (Scope, QualifiedNameComponents);
334- return formatNestedName (QualifiedNameComponents, Name);
343+ return formatNestedName (QualifiedNameComponents, Name, getScopeSeparator () );
335344}
336345
337346std::string CodeViewDebug::getFullyQualifiedName (const DIScope *Ty) {
@@ -1487,8 +1496,8 @@ void CodeViewDebug::addToUDTs(const DIType *Ty) {
14871496 const DISubprogram *ClosestSubprogram =
14881497 collectParentScopeNames (Ty->getScope (), ParentScopeNames);
14891498
1490- std::string FullyQualifiedName =
1491- formatNestedName ( ParentScopeNames, getPrettyScopeName (Ty));
1499+ std::string FullyQualifiedName = formatNestedName (
1500+ ParentScopeNames, getPrettyScopeName (Ty), getScopeSeparator ( ));
14921501
14931502 if (ClosestSubprogram == nullptr ) {
14941503 GlobalUDTs.emplace_back (std::move (FullyQualifiedName), Ty);
0 commit comments