@@ -297,17 +297,26 @@ const DISubprogram *CodeViewDebug::collectParentScopeNames(
297
297
}
298
298
299
299
static std::string formatNestedName (ArrayRef<StringRef> QualifiedNameComponents,
300
- StringRef TypeName) {
300
+ StringRef TypeName,
301
+ const std::string &Separator) {
301
302
std::string FullyQualifiedName;
302
303
for (StringRef QualifiedNameComponent :
303
304
llvm::reverse (QualifiedNameComponents)) {
304
305
FullyQualifiedName.append (std::string (QualifiedNameComponent));
305
- FullyQualifiedName.append (" :: " );
306
+ FullyQualifiedName.append (Separator );
306
307
}
307
308
FullyQualifiedName.append (std::string (TypeName));
308
309
return FullyQualifiedName;
309
310
}
310
311
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
+
311
320
struct CodeViewDebug ::TypeLoweringScope {
312
321
TypeLoweringScope (CodeViewDebug &CVD) : CVD(CVD) { ++CVD.TypeEmissionLevel ; }
313
322
~TypeLoweringScope () {
@@ -328,7 +337,7 @@ std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope,
328
337
TypeLoweringScope S (*this );
329
338
SmallVector<StringRef, 5 > QualifiedNameComponents;
330
339
collectParentScopeNames (Scope, QualifiedNameComponents);
331
- return formatNestedName (QualifiedNameComponents, Name);
340
+ return formatNestedName (QualifiedNameComponents, Name, getScopeSeparator () );
332
341
}
333
342
334
343
std::string CodeViewDebug::getFullyQualifiedName (const DIScope *Ty) {
@@ -1640,8 +1649,8 @@ void CodeViewDebug::addToUDTs(const DIType *Ty) {
1640
1649
const DISubprogram *ClosestSubprogram =
1641
1650
collectParentScopeNames (Ty->getScope (), ParentScopeNames);
1642
1651
1643
- std::string FullyQualifiedName =
1644
- formatNestedName ( ParentScopeNames, getPrettyScopeName (Ty));
1652
+ std::string FullyQualifiedName = formatNestedName (
1653
+ ParentScopeNames, getPrettyScopeName (Ty), getScopeSeparator ( ));
1645
1654
1646
1655
if (ClosestSubprogram == nullptr ) {
1647
1656
GlobalUDTs.emplace_back (std::move (FullyQualifiedName), Ty);
0 commit comments