[DebugInfo] Add Verifier check for local enums in CU's enums field (#185228)
Since #165032, DwarfDebug asserts if function-local enums are present in the enums field of DICompileUnit. This patch adds a check to the Verifier to detect such invalid IR earlier. Incorrect occurence of a local enum in DICompileUnit's enums field in `llvm/test/DebugInfo/COFF/enum-co.ll` is fixed. This change is extracted from https://reviews.llvm.org/D144008.
This commit is contained in:
parent
f093ccb2eb
commit
c5847b113e
@ -1574,6 +1574,9 @@ void Verifier::visitDICompileUnit(const DICompileUnit &N) {
|
||||
auto *Enum = dyn_cast_or_null<DICompositeType>(Op);
|
||||
CheckDI(Enum && Enum->getTag() == dwarf::DW_TAG_enumeration_type,
|
||||
"invalid enum type", &N, N.getEnumTypes(), Op);
|
||||
CheckDI(!Enum->getScope() || !isa<DILocalScope>(Enum->getScope()),
|
||||
"function-local enum in a DICompileUnit's enum list", &N,
|
||||
N.getEnumTypes(), Op);
|
||||
}
|
||||
}
|
||||
if (auto *Array = N.getRawRetainedTypes()) {
|
||||
|
||||
@ -134,7 +134,7 @@ attributes #1 = { nounwind readnone speculatable }
|
||||
|
||||
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 8.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
|
||||
!1 = !DIFile(filename: "enum-co.cpp", directory: "D:\5Cupstream\5Cllvm\5Ctest\5CDebugInfo\5CCOFF", checksumkind: CSK_MD5, checksum: "2e53b90441669acca735bad28ed3a1ab")
|
||||
!2 = !{!3, !8, !13, !18}
|
||||
!2 = !{!3, !8, !18}
|
||||
!3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", file: !1, line: 4, baseType: !4, size: 32, elements: !5, identifier: ".?AW4Enum@@")
|
||||
!4 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
||||
!5 = !{!6, !7}
|
||||
@ -146,7 +146,7 @@ attributes #1 = { nounwind readnone speculatable }
|
||||
!11 = !DIEnumerator(name: "BLUE", value: 1)
|
||||
!12 = !DIEnumerator(name: "NOTCARE", value: 2)
|
||||
!13 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "ScopedEnum", scope: !14, file: !1, line: 11, baseType: !4, size: 32, elements: !5, identifier: ".?AW4ScopedEnum@?1??Func@@YAXXZ@")
|
||||
!14 = distinct !DISubprogram(name: "Func", linkageName: "?Func@@YAXXZ", scope: !1, file: !1, line: 10, type: !15, isLocal: false, isDefinition: true, scopeLine: 10, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !17)
|
||||
!14 = distinct !DISubprogram(name: "Func", linkageName: "?Func@@YAXXZ", scope: !1, file: !1, line: 10, type: !15, isLocal: false, isDefinition: true, scopeLine: 10, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !47)
|
||||
!15 = !DISubroutineType(types: !16)
|
||||
!16 = !{null}
|
||||
!17 = !{}
|
||||
@ -179,3 +179,4 @@ attributes #1 = { nounwind readnone speculatable }
|
||||
!44 = !DILocalVariable(name: "S", scope: !14, file: !1, line: 20, type: !20)
|
||||
!45 = !DILocation(line: 20, scope: !14)
|
||||
!46 = !DILocation(line: 21, scope: !14, isImplicitCode: true)
|
||||
!47 = !{!13}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user