Skip to content

Commit 34d4fa2

Browse files
committed
fixup! simplify MapDWARFLanguageToCVLang
1 parent 2f5a3a7 commit 34d4fa2

File tree

1 file changed

+5
-40
lines changed

1 file changed

+5
-40
lines changed

llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -603,46 +603,11 @@ MapDWARFLanguageToCVLang(dwarf::SourceLanguageName DWLName) {
603603
}
604604

605605
static SourceLanguage MapDWARFLanguageToCVLang(dwarf::SourceLanguage DWLang) {
606-
switch (DWLang) {
607-
case dwarf::DW_LANG_C:
608-
case dwarf::DW_LANG_C89:
609-
case dwarf::DW_LANG_C99:
610-
case dwarf::DW_LANG_C11:
611-
return SourceLanguage::C;
612-
case dwarf::DW_LANG_C_plus_plus:
613-
case dwarf::DW_LANG_C_plus_plus_03:
614-
case dwarf::DW_LANG_C_plus_plus_11:
615-
case dwarf::DW_LANG_C_plus_plus_14:
616-
return SourceLanguage::Cpp;
617-
case dwarf::DW_LANG_Fortran77:
618-
case dwarf::DW_LANG_Fortran90:
619-
case dwarf::DW_LANG_Fortran95:
620-
case dwarf::DW_LANG_Fortran03:
621-
case dwarf::DW_LANG_Fortran08:
622-
return SourceLanguage::Fortran;
623-
case dwarf::DW_LANG_Pascal83:
624-
return SourceLanguage::Pascal;
625-
case dwarf::DW_LANG_Cobol74:
626-
case dwarf::DW_LANG_Cobol85:
627-
return SourceLanguage::Cobol;
628-
case dwarf::DW_LANG_Java:
629-
return SourceLanguage::Java;
630-
case dwarf::DW_LANG_D:
631-
return SourceLanguage::D;
632-
case dwarf::DW_LANG_Swift:
633-
return SourceLanguage::Swift;
634-
case dwarf::DW_LANG_Rust:
635-
return SourceLanguage::Rust;
636-
case dwarf::DW_LANG_ObjC:
637-
return SourceLanguage::ObjC;
638-
case dwarf::DW_LANG_ObjC_plus_plus:
639-
return SourceLanguage::ObjCpp;
640-
default:
641-
// There's no CodeView representation for this language, and CV doesn't
642-
// have an "unknown" option for the language field, so we'll use MASM,
643-
// as it's very low level.
644-
return SourceLanguage::Masm;
645-
}
606+
auto MaybeLName = dwarf::toDW_LNAME(DWLang);
607+
if (!MaybeLName)
608+
return MapDWARFLanguageToCVLang(static_cast<dwarf::SourceLanguageName>(0));
609+
610+
return MapDWARFLanguageToCVLang(MaybeLName->first);
646611
}
647612

648613
void CodeViewDebug::beginModule(Module *M) {

0 commit comments

Comments
 (0)