@@ -301,17 +301,26 @@ const DISubprogram *CodeViewDebug::collectParentScopeNames(
301301}
302302
303303static std::string formatNestedName (ArrayRef<StringRef> QualifiedNameComponents,
304- StringRef TypeName) {
304+ StringRef TypeName,
305+ const std::string &Separator) {
305306 std::string FullyQualifiedName;
306307 for (StringRef QualifiedNameComponent :
307308 llvm::reverse (QualifiedNameComponents)) {
308309 FullyQualifiedName.append (std::string (QualifiedNameComponent));
309- FullyQualifiedName.append (" :: " );
310+ FullyQualifiedName.append (Separator );
310311 }
311312 FullyQualifiedName.append (std::string (TypeName));
312313 return FullyQualifiedName;
313314}
314315
316+ // Added for LDC: use `.` as scope separator for compile units with D language
317+ // tag.
318+ const char *CodeViewDebug::getScopeSeparator () const {
319+ NamedMDNode *CUs = MMI->getModule ()->getNamedMetadata (" llvm.dbg.cu" );
320+ const DICompileUnit *CU = cast<DICompileUnit>(*CUs->operands ().begin ());
321+ return CU->getSourceLanguage () == dwarf::DW_LANG_D ? " ." : " ::" ;
322+ }
323+
315324struct CodeViewDebug ::TypeLoweringScope {
316325 TypeLoweringScope (CodeViewDebug &CVD) : CVD(CVD) { ++CVD.TypeEmissionLevel ; }
317326 ~TypeLoweringScope () {
@@ -332,7 +341,7 @@ std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope,
332341 TypeLoweringScope S (*this );
333342 SmallVector<StringRef, 5 > QualifiedNameComponents;
334343 collectParentScopeNames (Scope, QualifiedNameComponents);
335- return formatNestedName (QualifiedNameComponents, Name);
344+ return formatNestedName (QualifiedNameComponents, Name, getScopeSeparator () );
336345}
337346
338347std::string CodeViewDebug::getFullyQualifiedName (const DIScope *Ty) {
@@ -1604,8 +1613,8 @@ void CodeViewDebug::addToUDTs(const DIType *Ty) {
16041613 const DISubprogram *ClosestSubprogram =
16051614 collectParentScopeNames (Ty->getScope (), ParentScopeNames);
16061615
1607- std::string FullyQualifiedName =
1608- formatNestedName ( ParentScopeNames, getPrettyScopeName (Ty));
1616+ std::string FullyQualifiedName = formatNestedName (
1617+ ParentScopeNames, getPrettyScopeName (Ty), getScopeSeparator ( ));
16091618
16101619 if (ClosestSubprogram == nullptr ) {
16111620 GlobalUDTs.emplace_back (std::move (FullyQualifiedName), Ty);
0 commit comments