139 lines · plain
1; REQUIRES: x86-registered-target2 3; Test case 4 - Missing nested enumerations.4 5; pr-46466.cpp6; 1 struct Struct {7; 2 union Union {8; 3 enum NestedEnum { RED, BLUE };9; 4 };10; 5 Union U;11; 6 };12; 713; 8 Struct S;14; 9 int test() {15; 10 return S.U.BLUE;16; 11 }17 18; The above test is used to illustrate a scope issue found in the Clang19; compiler.20; PR46466: https://bugs.llvm.org/show_bug.cgi?id=4646621; PR45811: https://github.com/llvm/llvm-project/issues/4581122 23; In the following logical views, we can see that the CodeView debug24; information generated by the Clang compiler does not include any25; references to the enumerators 'RED' and 'BLUE'. The CodeView generated26; by GCC and MSVC, does include such references.27 28; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer,size \29; RUN: --output-sort=name \30; RUN: --print=symbols,types \31; RUN: %p/Inputs/pr-46466-codeview-clang.o \32; RUN: %p/Inputs/pr-46466-codeview-msvc.o 2>&1 | \33; RUN: FileCheck --strict-whitespace -check-prefix=ONE %s34 35; ONE: Logical View:36; ONE-NEXT: [000] {File} 'pr-46466-codeview-clang.o' -> COFF-x86-6437; ONE-EMPTY:38; ONE-NEXT: [001] {CompileUnit} 'pr-46466.cpp'39; ONE-NEXT: [002] {Producer} 'clang version 15.0.0 {{.*}}'40; ONE-NEXT: [002] {Language} 'Cpp'41; ONE-NEXT: [002] {Variable} extern 'S' -> 'Struct'42; ONE-NEXT: [002] 1 {Struct} 'Struct' [Size = 1]43; ONE-NEXT: [003] {Member} public 'U' -> 'Union'44; ONE-NEXT: [003] 2 {Union} 'Union' [Size = 1]45; ONE-NEXT: [004] 3 {Enumeration} 'NestedEnum' -> 'int'46; ONE-NEXT: [005] {Enumerator} 'BLUE' = '0x1'47; ONE-NEXT: [005] {Enumerator} 'RED' = '0x0'48; ONE-EMPTY:49; ONE-NEXT: Logical View:50; ONE-NEXT: [000] {File} 'pr-46466-codeview-msvc.o' -> COFF-x86-6451; ONE-EMPTY:52; ONE-NEXT: [001] {CompileUnit} 'pr-46466.cpp'53; ONE-NEXT: [002] {Producer} 'Microsoft (R) Optimizing Compiler'54; ONE-NEXT: [002] {Language} 'Cpp'55; ONE-NEXT: [002] {Variable} extern 'S' -> 'Struct'56; ONE-NEXT: [002] 1 {Struct} 'Struct' [Size = 1]57; ONE-NEXT: [003] {Member} public 'U' -> 'Union'58; ONE-NEXT: [003] 2 {Union} 'Union' [Size = 1]59; ONE-NEXT: [004] 3 {Enumeration} 'NestedEnum' -> 'int'60; ONE-NEXT: [005] {Enumerator} 'BLUE' = '0x1'61; ONE-NEXT: [005] {Enumerator} 'RED' = '0x0'62 63; Using the selection facilities, we can produce a logical view64; showing just the logical types that are 'Enumerator' and its65; parents. The logical view is sorted by the types name.66 67; RUN: llvm-debuginfo-analyzer --attribute=level,format,size \68; RUN: --output-sort=name \69; RUN: --select-types=Enumerator \70; RUN: --report=parents \71; RUN: --print=types \72; RUN: %p/Inputs/pr-46466-*.o 2>&1 | \73; RUN: FileCheck --strict-whitespace -check-prefix=TWO %s74 75; TWO: Logical View:76; TWO-NEXT: [000] {File} 'pr-46466-codeview-clang.o' -> COFF-x86-6477; TWO-EMPTY:78; TWO-NEXT: [001] {CompileUnit} 'pr-46466.cpp'79; TWO-NEXT: [002] 1 {Struct} 'Struct' [Size = 1]80; TWO-NEXT: [003] 2 {Union} 'Union' [Size = 1]81; TWO-NEXT: [004] 3 {Enumeration} 'NestedEnum' -> 'int'82; TWO-NEXT: [005] {Enumerator} 'BLUE' = '0x1'83; TWO-NEXT: [005] {Enumerator} 'RED' = '0x0'84; TWO-EMPTY:85; TWO-NEXT: Logical View:86; TWO-NEXT: [000] {File} 'pr-46466-codeview-msvc.o' -> COFF-x86-6487; TWO-EMPTY:88; TWO-NEXT: [001] {CompileUnit} 'pr-46466.cpp'89; TWO-NEXT: [002] 1 {Struct} 'Struct' [Size = 1]90; TWO-NEXT: [003] 2 {Union} 'Union' [Size = 1]91; TWO-NEXT: [004] 3 {Enumeration} 'NestedEnum' -> 'int'92; TWO-NEXT: [005] {Enumerator} 'BLUE' = '0x1'93; TWO-NEXT: [005] {Enumerator} 'RED' = '0x0'94 95; Using the selection facilities, we can produce a simple tabular output96; including a summary for the logical types that are 'Enumerator'. The97; logical view is sorted by the types name.98 99; RUN: llvm-debuginfo-analyzer --attribute=level,format \100; RUN: --output-sort=name \101; RUN: --select-types=Enumerator \102; RUN: --print=types,summary \103; RUN: %p/Inputs/pr-46466-*.o 2>&1 | \104; RUN: FileCheck --strict-whitespace -check-prefix=THR %s105 106; THR: Logical View:107; THR-NEXT: [000] {File} 'pr-46466-codeview-clang.o' -> COFF-x86-64108; THR-EMPTY:109; THR-NEXT: [001] {CompileUnit} 'pr-46466.cpp'110; THR-NEXT: [005] {Enumerator} 'BLUE' = '0x1'111; THR-NEXT: [005] {Enumerator} 'RED' = '0x0'112; THR-EMPTY:113; THR-NEXT: -----------------------------114; THR-NEXT: Element Total Printed115; THR-NEXT: -----------------------------116; THR-NEXT: Scopes 5 0117; THR-NEXT: Symbols 2 0118; THR-NEXT: Types 6 2119; THR-NEXT: Lines 0 0120; THR-NEXT: -----------------------------121; THR-NEXT: Total 13 2122; THR-EMPTY:123; THR-NEXT: Logical View:124; THR-NEXT: [000] {File} 'pr-46466-codeview-msvc.o' -> COFF-x86-64125; THR-EMPTY:126; THR-NEXT: [001] {CompileUnit} 'pr-46466.cpp'127; THR-NEXT: [005] {Enumerator} 'BLUE' = '0x1'128; THR-NEXT: [005] {Enumerator} 'RED' = '0x0'129; THR-EMPTY:130; THR-NEXT: -----------------------------131; THR-NEXT: Element Total Printed132; THR-NEXT: -----------------------------133; THR-NEXT: Scopes 5 0134; THR-NEXT: Symbols 2 0135; THR-NEXT: Types 7 2136; THR-NEXT: Lines 0 0137; THR-NEXT: -----------------------------138; THR-NEXT: Total 14 2139