@@ -569,40 +569,30 @@ void CodeViewDebug::emitCodeViewMagicVersion() {
569
569
OS.emitInt32 (COFF::DEBUG_SECTION_MAGIC);
570
570
}
571
571
572
- static SourceLanguage MapDWLangToCVLang (unsigned DWLang) {
573
- switch (DWLang) {
574
- case dwarf::DW_LANG_C:
575
- case dwarf::DW_LANG_C89:
576
- case dwarf::DW_LANG_C99:
577
- case dwarf::DW_LANG_C11:
572
+ static SourceLanguage
573
+ MapDWARFLanguageToCVLang (dwarf::SourceLanguageName DWLName) {
574
+ switch (DWLName) {
575
+ case dwarf::DW_LNAME_C:
578
576
return SourceLanguage::C;
579
- case dwarf::DW_LANG_C_plus_plus:
580
- case dwarf::DW_LANG_C_plus_plus_03:
581
- case dwarf::DW_LANG_C_plus_plus_11:
582
- case dwarf::DW_LANG_C_plus_plus_14:
577
+ case dwarf::DW_LNAME_C_plus_plus:
583
578
return SourceLanguage::Cpp;
584
- case dwarf::DW_LANG_Fortran77:
585
- case dwarf::DW_LANG_Fortran90:
586
- case dwarf::DW_LANG_Fortran95:
587
- case dwarf::DW_LANG_Fortran03:
588
- case dwarf::DW_LANG_Fortran08:
579
+ case dwarf::DW_LNAME_Fortran:
589
580
return SourceLanguage::Fortran;
590
- case dwarf::DW_LANG_Pascal83 :
581
+ case dwarf::DW_LNAME_Pascal :
591
582
return SourceLanguage::Pascal;
592
- case dwarf::DW_LANG_Cobol74:
593
- case dwarf::DW_LANG_Cobol85:
583
+ case dwarf::DW_LNAME_Cobol:
594
584
return SourceLanguage::Cobol;
595
- case dwarf::DW_LANG_Java :
585
+ case dwarf::DW_LNAME_Java :
596
586
return SourceLanguage::Java;
597
- case dwarf::DW_LANG_D :
587
+ case dwarf::DW_LNAME_D :
598
588
return SourceLanguage::D;
599
- case dwarf::DW_LANG_Swift :
589
+ case dwarf::DW_LNAME_Swift :
600
590
return SourceLanguage::Swift;
601
- case dwarf::DW_LANG_Rust :
591
+ case dwarf::DW_LNAME_Rust :
602
592
return SourceLanguage::Rust;
603
- case dwarf::DW_LANG_ObjC :
593
+ case dwarf::DW_LNAME_ObjC :
604
594
return SourceLanguage::ObjC;
605
- case dwarf::DW_LANG_ObjC_plus_plus :
595
+ case dwarf::DW_LNAME_ObjC_plus_plus :
606
596
return SourceLanguage::ObjCpp;
607
597
default :
608
598
// There's no CodeView representation for this language, and CV doesn't
@@ -612,6 +602,14 @@ static SourceLanguage MapDWLangToCVLang(unsigned DWLang) {
612
602
}
613
603
}
614
604
605
+ static SourceLanguage MapDWARFLanguageToCVLang (dwarf::SourceLanguage DWLang) {
606
+ auto MaybeLName = dwarf::toDW_LNAME (DWLang);
607
+ if (!MaybeLName)
608
+ return MapDWARFLanguageToCVLang (static_cast <dwarf::SourceLanguageName>(0 ));
609
+
610
+ return MapDWARFLanguageToCVLang (MaybeLName->first );
611
+ }
612
+
615
613
void CodeViewDebug::beginModule (Module *M) {
616
614
// If COFF debug section is not available, skip any debug info related stuff.
617
615
if (!Asm->getObjFileLowering ().getCOFFDebugSymbolsSection ()) {
@@ -633,8 +631,13 @@ void CodeViewDebug::beginModule(Module *M) {
633
631
Node = *CUs->operands ().begin ();
634
632
}
635
633
const auto *CU = cast<DICompileUnit>(Node);
634
+ DISourceLanguageName Lang = CU->getSourceLanguage ();
636
635
CurrentSourceLanguage =
637
- MapDWLangToCVLang (CU->getSourceLanguage ().getUnversionedName ());
636
+ Lang.hasVersionedName ()
637
+ ? MapDWARFLanguageToCVLang (
638
+ static_cast <dwarf::SourceLanguageName>(Lang.getName ()))
639
+ : MapDWARFLanguageToCVLang (
640
+ static_cast <dwarf::SourceLanguage>(Lang.getName ()));
638
641
if (!M->getCodeViewFlag () ||
639
642
CU->getEmissionKind () == DICompileUnit::NoDebug) {
640
643
Asm = nullptr ;
0 commit comments