@@ -332,17 +332,26 @@ const DISubprogram *CodeViewDebug::collectParentScopeNames(
332
332
}
333
333
334
334
static std::string formatNestedName (ArrayRef<StringRef> QualifiedNameComponents,
335
- StringRef TypeName) {
335
+ StringRef TypeName,
336
+ const std::string &Separator) {
336
337
std::string FullyQualifiedName;
337
338
for (StringRef QualifiedNameComponent :
338
339
llvm::reverse (QualifiedNameComponents)) {
339
340
FullyQualifiedName.append (std::string (QualifiedNameComponent));
340
- FullyQualifiedName.append (" :: " );
341
+ FullyQualifiedName.append (Separator );
341
342
}
342
343
FullyQualifiedName.append (std::string (TypeName));
343
344
return FullyQualifiedName;
344
345
}
345
346
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
+
346
355
struct CodeViewDebug ::TypeLoweringScope {
347
356
TypeLoweringScope (CodeViewDebug &CVD) : CVD(CVD) { ++CVD.TypeEmissionLevel ; }
348
357
~TypeLoweringScope () {
@@ -363,7 +372,7 @@ std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope,
363
372
TypeLoweringScope S (*this );
364
373
SmallVector<StringRef, 5 > QualifiedNameComponents;
365
374
collectParentScopeNames (Scope, QualifiedNameComponents);
366
- return formatNestedName (QualifiedNameComponents, Name);
375
+ return formatNestedName (QualifiedNameComponents, Name, getScopeSeparator () );
367
376
}
368
377
369
378
std::string CodeViewDebug::getFullyQualifiedName (const DIScope *Ty) {
@@ -1493,8 +1502,8 @@ void CodeViewDebug::addToUDTs(const DIType *Ty) {
1493
1502
const DISubprogram *ClosestSubprogram =
1494
1503
collectParentScopeNames (Ty->getScope (), ParentScopeNames);
1495
1504
1496
- std::string FullyQualifiedName =
1497
- formatNestedName ( ParentScopeNames, getPrettyScopeName (Ty));
1505
+ std::string FullyQualifiedName = formatNestedName (
1506
+ ParentScopeNames, getPrettyScopeName (Ty), getScopeSeparator ( ));
1498
1507
1499
1508
if (ClosestSubprogram == nullptr ) {
1500
1509
GlobalUDTs.emplace_back (std::move (FullyQualifiedName), Ty);
0 commit comments