@@ -299,17 +299,26 @@ const DISubprogram *CodeViewDebug::collectParentScopeNames(
299299}
300300
301301static std::string formatNestedName (ArrayRef<StringRef> QualifiedNameComponents,
302- StringRef TypeName) {
302+ StringRef TypeName,
303+ const std::string &Separator) {
303304 std::string FullyQualifiedName;
304305 for (StringRef QualifiedNameComponent :
305306 llvm::reverse (QualifiedNameComponents)) {
306307 FullyQualifiedName.append (std::string (QualifiedNameComponent));
307- FullyQualifiedName.append (" :: " );
308+ FullyQualifiedName.append (Separator );
308309 }
309310 FullyQualifiedName.append (std::string (TypeName));
310311 return FullyQualifiedName;
311312}
312313
314+ // Added for LDC: use `.` as scope separator for compile units with D language
315+ // tag.
316+ const char *CodeViewDebug::getScopeSeparator () const {
317+ NamedMDNode *CUs = MMI->getModule ()->getNamedMetadata (" llvm.dbg.cu" );
318+ const DICompileUnit *CU = cast<DICompileUnit>(*CUs->operands ().begin ());
319+ return CU->getSourceLanguage () == dwarf::DW_LANG_D ? " ." : " ::" ;
320+ }
321+
313322struct CodeViewDebug ::TypeLoweringScope {
314323 TypeLoweringScope (CodeViewDebug &CVD) : CVD(CVD) { ++CVD.TypeEmissionLevel ; }
315324 ~TypeLoweringScope () {
@@ -330,7 +339,7 @@ std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope,
330339 TypeLoweringScope S (*this );
331340 SmallVector<StringRef, 5 > QualifiedNameComponents;
332341 collectParentScopeNames (Scope, QualifiedNameComponents);
333- return formatNestedName (QualifiedNameComponents, Name);
342+ return formatNestedName (QualifiedNameComponents, Name, getScopeSeparator () );
334343}
335344
336345std::string CodeViewDebug::getFullyQualifiedName (const DIScope *Ty) {
@@ -1654,8 +1663,8 @@ void CodeViewDebug::addToUDTs(const DIType *Ty) {
16541663 const DISubprogram *ClosestSubprogram =
16551664 collectParentScopeNames (Ty->getScope (), ParentScopeNames);
16561665
1657- std::string FullyQualifiedName =
1658- formatNestedName ( ParentScopeNames, getPrettyScopeName (Ty));
1666+ std::string FullyQualifiedName = formatNestedName (
1667+ ParentScopeNames, getPrettyScopeName (Ty), getScopeSeparator ( ));
16591668
16601669 if (ClosestSubprogram == nullptr ) {
16611670 GlobalUDTs.emplace_back (std::move (FullyQualifiedName), Ty);
0 commit comments