@@ -295,17 +295,26 @@ const DISubprogram *CodeViewDebug::collectParentScopeNames(
295295}
296296
297297static std::string formatNestedName (ArrayRef<StringRef> QualifiedNameComponents,
298- StringRef TypeName) {
298+ StringRef TypeName,
299+ const std::string &Separator) {
299300 std::string FullyQualifiedName;
300301 for (StringRef QualifiedNameComponent :
301302 llvm::reverse (QualifiedNameComponents)) {
302303 FullyQualifiedName.append (std::string (QualifiedNameComponent));
303- FullyQualifiedName.append (" :: " );
304+ FullyQualifiedName.append (Separator );
304305 }
305306 FullyQualifiedName.append (std::string (TypeName));
306307 return FullyQualifiedName;
307308}
308309
310+ // Added for LDC: use `.` as scope separator for compile units with D language
311+ // tag.
312+ const char *CodeViewDebug::getScopeSeparator () const {
313+ NamedMDNode *CUs = MMI->getModule ()->getNamedMetadata (" llvm.dbg.cu" );
314+ const DICompileUnit *CU = cast<DICompileUnit>(*CUs->operands ().begin ());
315+ return CU->getSourceLanguage () == dwarf::DW_LANG_D ? " ." : " ::" ;
316+ }
317+
309318struct CodeViewDebug ::TypeLoweringScope {
310319 TypeLoweringScope (CodeViewDebug &CVD) : CVD(CVD) { ++CVD.TypeEmissionLevel ; }
311320 ~TypeLoweringScope () {
@@ -326,7 +335,7 @@ std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope,
326335 TypeLoweringScope S (*this );
327336 SmallVector<StringRef, 5 > QualifiedNameComponents;
328337 collectParentScopeNames (Scope, QualifiedNameComponents);
329- return formatNestedName (QualifiedNameComponents, Name);
338+ return formatNestedName (QualifiedNameComponents, Name, getScopeSeparator () );
330339}
331340
332341std::string CodeViewDebug::getFullyQualifiedName (const DIScope *Ty) {
@@ -1591,8 +1600,8 @@ void CodeViewDebug::addToUDTs(const DIType *Ty) {
15911600 const DISubprogram *ClosestSubprogram =
15921601 collectParentScopeNames (Ty->getScope (), ParentScopeNames);
15931602
1594- std::string FullyQualifiedName =
1595- formatNestedName ( ParentScopeNames, getPrettyScopeName (Ty));
1603+ std::string FullyQualifiedName = formatNestedName (
1604+ ParentScopeNames, getPrettyScopeName (Ty), getScopeSeparator ( ));
15961605
15971606 if (ClosestSubprogram == nullptr ) {
15981607 GlobalUDTs.emplace_back (std::move (FullyQualifiedName), Ty);
0 commit comments