@@ -293,17 +293,26 @@ const DISubprogram *CodeViewDebug::collectParentScopeNames(
293
293
}
294
294
295
295
static std::string formatNestedName (ArrayRef<StringRef> QualifiedNameComponents,
296
- StringRef TypeName) {
296
+ StringRef TypeName,
297
+ const std::string &Separator) {
297
298
std::string FullyQualifiedName;
298
299
for (StringRef QualifiedNameComponent :
299
300
llvm::reverse (QualifiedNameComponents)) {
300
301
FullyQualifiedName.append (std::string (QualifiedNameComponent));
301
- FullyQualifiedName.append (" :: " );
302
+ FullyQualifiedName.append (Separator );
302
303
}
303
304
FullyQualifiedName.append (std::string (TypeName));
304
305
return FullyQualifiedName;
305
306
}
306
307
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
+
307
316
struct CodeViewDebug ::TypeLoweringScope {
308
317
TypeLoweringScope (CodeViewDebug &CVD) : CVD(CVD) { ++CVD.TypeEmissionLevel ; }
309
318
~TypeLoweringScope () {
@@ -324,7 +333,7 @@ std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope,
324
333
TypeLoweringScope S (*this );
325
334
SmallVector<StringRef, 5 > QualifiedNameComponents;
326
335
collectParentScopeNames (Scope, QualifiedNameComponents);
327
- return formatNestedName (QualifiedNameComponents, Name);
336
+ return formatNestedName (QualifiedNameComponents, Name, getScopeSeparator () );
328
337
}
329
338
330
339
std::string CodeViewDebug::getFullyQualifiedName (const DIScope *Ty) {
@@ -1610,8 +1619,8 @@ void CodeViewDebug::addToUDTs(const DIType *Ty) {
1610
1619
const DISubprogram *ClosestSubprogram =
1611
1620
collectParentScopeNames (Ty->getScope (), ParentScopeNames);
1612
1621
1613
- std::string FullyQualifiedName =
1614
- formatNestedName ( ParentScopeNames, getPrettyScopeName (Ty));
1622
+ std::string FullyQualifiedName = formatNestedName (
1623
+ ParentScopeNames, getPrettyScopeName (Ty), getScopeSeparator ( ));
1615
1624
1616
1625
if (ClosestSubprogram == nullptr ) {
1617
1626
GlobalUDTs.emplace_back (std::move (FullyQualifiedName), Ty);
0 commit comments