@@ -297,17 +297,26 @@ const DISubprogram *CodeViewDebug::collectParentScopeNames(
297297}
298298
299299static  std::string formatNestedName (ArrayRef<StringRef> QualifiedNameComponents,
300-                                     StringRef TypeName) {
300+                                     StringRef TypeName,
301+                                     const  std::string &Separator) {
301302  std::string FullyQualifiedName;
302303  for  (StringRef QualifiedNameComponent :
303304       llvm::reverse (QualifiedNameComponents)) {
304305    FullyQualifiedName.append (std::string (QualifiedNameComponent));
305-     FullyQualifiedName.append (" :: " 
306+     FullyQualifiedName.append (Separator );
306307  }
307308  FullyQualifiedName.append (std::string (TypeName));
308309  return  FullyQualifiedName;
309310}
310311
312+ //  Added for LDC: use `.` as scope separator for compile units with D language
313+ //  tag.
314+ const  char  *CodeViewDebug::getScopeSeparator () const  {
315+   NamedMDNode *CUs = MMI->getModule ()->getNamedMetadata (" llvm.dbg.cu" 
316+   const  DICompileUnit *CU = cast<DICompileUnit>(*CUs->operands ().begin ());
317+   return  CU->getSourceLanguage () == dwarf::DW_LANG_D ? " ." " ::" 
318+ }
319+ 
311320struct  CodeViewDebug ::TypeLoweringScope {
312321  TypeLoweringScope (CodeViewDebug &CVD) : CVD(CVD) { ++CVD.TypeEmissionLevel ; }
313322  ~TypeLoweringScope () {
@@ -328,7 +337,7 @@ std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope,
328337  TypeLoweringScope S (*this );
329338  SmallVector<StringRef, 5 > QualifiedNameComponents;
330339  collectParentScopeNames (Scope, QualifiedNameComponents);
331-   return  formatNestedName (QualifiedNameComponents, Name);
340+   return  formatNestedName (QualifiedNameComponents, Name,  getScopeSeparator () );
332341}
333342
334343std::string CodeViewDebug::getFullyQualifiedName (const  DIScope *Ty) {
@@ -1640,8 +1649,8 @@ void CodeViewDebug::addToUDTs(const DIType *Ty) {
16401649  const  DISubprogram *ClosestSubprogram =
16411650      collectParentScopeNames (Ty->getScope (), ParentScopeNames);
16421651
1643-   std::string FullyQualifiedName =
1644-       formatNestedName ( ParentScopeNames, getPrettyScopeName (Ty));
1652+   std::string FullyQualifiedName =  formatNestedName ( 
1653+       ParentScopeNames, getPrettyScopeName (Ty),  getScopeSeparator ( ));
16451654
16461655  if  (ClosestSubprogram == nullptr ) {
16471656    GlobalUDTs.emplace_back (std::move (FullyQualifiedName), Ty);
0 commit comments