@@ -293,17 +293,26 @@ const DISubprogram *CodeViewDebug::collectParentScopeNames(
293293}
294294
295295static std::string formatNestedName (ArrayRef<StringRef> QualifiedNameComponents,
296- StringRef TypeName) {
296+ StringRef TypeName,
297+ const std::string &Separator) {
297298 std::string FullyQualifiedName;
298299 for (StringRef QualifiedNameComponent :
299300 llvm::reverse (QualifiedNameComponents)) {
300301 FullyQualifiedName.append (std::string (QualifiedNameComponent));
301- FullyQualifiedName.append (" :: " );
302+ FullyQualifiedName.append (Separator );
302303 }
303304 FullyQualifiedName.append (std::string (TypeName));
304305 return FullyQualifiedName;
305306}
306307
308+ // Added for LDC: use `.` as scope separator for compile units with D language
309+ // tag.
310+ const char *CodeViewDebug::getScopeSeparator () const {
311+ NamedMDNode *CUs = MMI->getModule ()->getNamedMetadata (" llvm.dbg.cu" );
312+ const DICompileUnit *CU = cast<DICompileUnit>(*CUs->operands ().begin ());
313+ return CU->getSourceLanguage () == dwarf::DW_LANG_D ? " ." : " ::" ;
314+ }
315+
307316struct CodeViewDebug ::TypeLoweringScope {
308317 TypeLoweringScope (CodeViewDebug &CVD) : CVD(CVD) { ++CVD.TypeEmissionLevel ; }
309318 ~TypeLoweringScope () {
@@ -324,7 +333,7 @@ std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope,
324333 TypeLoweringScope S (*this );
325334 SmallVector<StringRef, 5 > QualifiedNameComponents;
326335 collectParentScopeNames (Scope, QualifiedNameComponents);
327- return formatNestedName (QualifiedNameComponents, Name);
336+ return formatNestedName (QualifiedNameComponents, Name, getScopeSeparator () );
328337}
329338
330339std::string CodeViewDebug::getFullyQualifiedName (const DIScope *Ty) {
@@ -1622,8 +1631,8 @@ void CodeViewDebug::addToUDTs(const DIType *Ty) {
16221631 const DISubprogram *ClosestSubprogram =
16231632 collectParentScopeNames (Ty->getScope (), ParentScopeNames);
16241633
1625- std::string FullyQualifiedName =
1626- formatNestedName ( ParentScopeNames, getPrettyScopeName (Ty));
1634+ std::string FullyQualifiedName = formatNestedName (
1635+ ParentScopeNames, getPrettyScopeName (Ty), getScopeSeparator ( ));
16271636
16281637 if (ClosestSubprogram == nullptr ) {
16291638 GlobalUDTs.emplace_back (std::move (FullyQualifiedName), Ty);
0 commit comments