@@ -332,17 +332,26 @@ const DISubprogram *CodeViewDebug::collectParentScopeNames(
332332}
333333
334334static std::string formatNestedName (ArrayRef<StringRef> QualifiedNameComponents,
335- StringRef TypeName) {
335+ StringRef TypeName,
336+ const std::string &Separator) {
336337 std::string FullyQualifiedName;
337338 for (StringRef QualifiedNameComponent :
338339 llvm::reverse (QualifiedNameComponents)) {
339340 FullyQualifiedName.append (std::string (QualifiedNameComponent));
340- FullyQualifiedName.append (" :: " );
341+ FullyQualifiedName.append (Separator );
341342 }
342343 FullyQualifiedName.append (std::string (TypeName));
343344 return FullyQualifiedName;
344345}
345346
347+ // Added for LDC: use `.` as scope separator for compile units with D language
348+ // tag.
349+ const char *CodeViewDebug::getScopeSeparator () const {
350+ NamedMDNode *CUs = MMI->getModule ()->getNamedMetadata (" llvm.dbg.cu" );
351+ const DICompileUnit *CU = cast<DICompileUnit>(*CUs->operands ().begin ());
352+ return CU->getSourceLanguage () == dwarf::DW_LANG_D ? " ." : " ::" ;
353+ }
354+
346355struct CodeViewDebug ::TypeLoweringScope {
347356 TypeLoweringScope (CodeViewDebug &CVD) : CVD(CVD) { ++CVD.TypeEmissionLevel ; }
348357 ~TypeLoweringScope () {
@@ -363,7 +372,7 @@ std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope,
363372 TypeLoweringScope S (*this );
364373 SmallVector<StringRef, 5 > QualifiedNameComponents;
365374 collectParentScopeNames (Scope, QualifiedNameComponents);
366- return formatNestedName (QualifiedNameComponents, Name);
375+ return formatNestedName (QualifiedNameComponents, Name, getScopeSeparator () );
367376}
368377
369378std::string CodeViewDebug::getFullyQualifiedName (const DIScope *Ty) {
@@ -1493,8 +1502,8 @@ void CodeViewDebug::addToUDTs(const DIType *Ty) {
14931502 const DISubprogram *ClosestSubprogram =
14941503 collectParentScopeNames (Ty->getScope (), ParentScopeNames);
14951504
1496- std::string FullyQualifiedName =
1497- formatNestedName ( ParentScopeNames, getPrettyScopeName (Ty));
1505+ std::string FullyQualifiedName = formatNestedName (
1506+ ParentScopeNames, getPrettyScopeName (Ty), getScopeSeparator ( ));
14981507
14991508 if (ClosestSubprogram == nullptr ) {
15001509 GlobalUDTs.emplace_back (std::move (FullyQualifiedName), Ty);
0 commit comments