diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -153,7 +153,7 @@ void setTag(unsigned Tag) { SubclassData16 = Tag; } public: - unsigned getTag() const { return SubclassData16; } + dwarf::Tag getTag() const { return (dwarf::Tag)SubclassData16; } /// Debug info flags. /// @@ -262,7 +262,7 @@ /// Return a (temporary) clone of this. TempGenericDINode clone() const { return cloneImpl(); } - unsigned getTag() const { return SubclassData16; } + dwarf::Tag getTag() const { return (dwarf::Tag)SubclassData16; } StringRef getHeader() const { return getStringOperand(0); } MDString *getRawHeader() const { return getOperandAs(0); } diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -273,9 +273,9 @@ return ""; case dwarf::DW_TAG_namespace: return "`anonymous namespace'"; + default: + return StringRef(); } - - return StringRef(); } const DISubprogram *CodeViewDebug::collectParentScopeNames( @@ -1487,6 +1487,9 @@ case dwarf::DW_TAG_class_type: case dwarf::DW_TAG_union_type: return false; + default: + // do nothing. + ; } } } @@ -2032,10 +2035,13 @@ static TypeRecordKind getRecordKind(const DICompositeType *Ty) { switch (Ty->getTag()) { - case dwarf::DW_TAG_class_type: return TypeRecordKind::Class; - case dwarf::DW_TAG_structure_type: return TypeRecordKind::Struct; + case dwarf::DW_TAG_class_type: + return TypeRecordKind::Class; + case dwarf::DW_TAG_structure_type: + return TypeRecordKind::Struct; + default: + llvm_unreachable("unexpected tag"); } - llvm_unreachable("unexpected tag"); } /// Return ClassOptions that should be present on both the forward declaration diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h @@ -257,7 +257,7 @@ /// Create a DIE with the given Tag, add the DIE to its parent, and /// call insertDIE if MD is not null. - DIE &createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N = nullptr); + DIE &createAndAddDIE(dwarf::Tag Tag, DIE &Parent, const DINode *N = nullptr); bool useSegmentedStringOffsetsTable() const { return DD->useSegmentedStringOffsetsTable(); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -385,8 +385,8 @@ Entry); } -DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) { - DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, (dwarf::Tag)Tag)); +DIE &DwarfUnit::createAndAddDIE(dwarf::Tag Tag, DIE &Parent, const DINode *N) { + DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, Tag)); if (N) insertDIE(N, &Die); return Die;