brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.4 KiB · cd1ee43 Raw
128 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 DWARF debug24; information generated by the Clang compiler does not include any25; references to the enumerators 'RED' and 'BLUE'. The DWARF generated26; by GCC, 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-dwarf-clang.o \32; RUN:                         %p/Inputs/pr-46466-dwarf-gcc.o 2>&1 | \33; RUN: FileCheck --strict-whitespace -check-prefix=ONE %s34 35; ONE:      Logical View:36; ONE-NEXT: [000]           {File} 'pr-46466-dwarf-clang.o' -> elf64-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} 'DW_LANG_C_plus_plus_14'41; ONE-NEXT: [002]     8         {Variable} extern 'S' -> 'Struct'42; ONE-NEXT: [002]     1         {Struct} 'Struct' [Size = 1]43; ONE-NEXT: [003]     5           {Member} public 'U' -> 'Union'44; ONE-EMPTY:45; ONE-NEXT: Logical View:46; ONE-NEXT: [000]           {File} 'pr-46466-dwarf-gcc.o' -> elf64-x86-6447; ONE-EMPTY:48; ONE-NEXT: [001]             {CompileUnit} 'pr-46466.cpp'49; ONE-NEXT: [002]               {Producer} 'GNU C++14 10.3.0 {{.*}}'50; ONE-NEXT: [002]               {Language} 'DW_LANG_C_plus_plus'51; ONE-NEXT: [002]     8         {Variable} extern 'S' -> 'Struct'52; ONE-NEXT: [002]     1         {Struct} 'Struct' [Size = 1]53; ONE-NEXT: [003]     5           {Member} public 'U' -> 'Union'54; ONE-NEXT: [003]     2           {Union} 'Union' [Size = 1]55; ONE-NEXT: [004]     3             {Enumeration} 'NestedEnum' -> 'unsigned int'56; ONE-NEXT: [005]                     {Enumerator} 'BLUE' = '0x1'57; ONE-NEXT: [005]                     {Enumerator} 'RED' = '0x0'58 59; Using the selection facilities, we can produce a logical view60; showing just the logical types that are 'Enumerator' and its61; parents. The logical view is sorted by the types name.62 63; RUN: llvm-debuginfo-analyzer --attribute=level,format,size \64; RUN:                         --output-sort=name \65; RUN:                         --select-types=Enumerator \66; RUN:                         --report=parents \67; RUN:                         --print=types \68; RUN:                         %p/Inputs/pr-46466-*.o 2>&1 | \69; RUN: FileCheck --strict-whitespace -check-prefix=TWO %s70 71; TWO:      Logical View:72; TWO-NEXT: [000]           {File} 'pr-46466-dwarf-clang.o' -> elf64-x86-6473; TWO-EMPTY:74; TWO-NEXT: [001]             {CompileUnit} 'pr-46466.cpp'75; TWO-EMPTY:76; TWO-NEXT: Logical View:77; TWO-NEXT: [000]           {File} 'pr-46466-dwarf-gcc.o' -> elf64-x86-6478; TWO-EMPTY:79; TWO-NEXT: [001]             {CompileUnit} 'pr-46466.cpp'80; TWO-NEXT: [002]     1         {Struct} 'Struct' [Size = 1]81; TWO-NEXT: [003]     2           {Union} 'Union' [Size = 1]82; TWO-NEXT: [004]     3             {Enumeration} 'NestedEnum' -> 'unsigned int'83; TWO-NEXT: [005]                     {Enumerator} 'BLUE' = '0x1'84; TWO-NEXT: [005]                     {Enumerator} 'RED' = '0x0'85 86; Using the selection facilities, we can produce a simple tabular output87; including a summary for the logical types that are 'Enumerator'. The88; logical view is sorted by the types name.89 90; RUN: llvm-debuginfo-analyzer --attribute=level,format \91; RUN:                         --output-sort=name \92; RUN:                         --select-types=Enumerator \93; RUN:                         --print=types,summary \94; RUN:                         %p/Inputs/pr-46466-*.o 2>&1 | \95; RUN: FileCheck --strict-whitespace -check-prefix=THR %s96 97; THR:      Logical View:98; THR-NEXT: [000]           {File} 'pr-46466-dwarf-clang.o' -> elf64-x86-6499; THR-EMPTY:100; THR-NEXT: [001]           {CompileUnit} 'pr-46466.cpp'101; THR-EMPTY:102; THR-NEXT: -----------------------------103; THR-NEXT: Element      Total    Printed104; THR-NEXT: -----------------------------105; THR-NEXT: Scopes           4          0106; THR-NEXT: Symbols          0          0107; THR-NEXT: Types            0          0108; THR-NEXT: Lines            0          0109; THR-NEXT: -----------------------------110; THR-NEXT: Total            4          0111; THR-EMPTY:112; THR-NEXT: Logical View:113; THR-NEXT: [000]           {File} 'pr-46466-dwarf-gcc.o' -> elf64-x86-64114; THR-EMPTY:115; THR-NEXT: [001]           {CompileUnit} 'pr-46466.cpp'116; THR-NEXT: [005]           {Enumerator} 'BLUE' = '0x1'117; THR-NEXT: [005]           {Enumerator} 'RED' = '0x0'118; THR-EMPTY:119; THR-NEXT: -----------------------------120; THR-NEXT: Element      Total    Printed121; THR-NEXT: -----------------------------122; THR-NEXT: Scopes           5          0123; THR-NEXT: Symbols          0          0124; THR-NEXT: Types            2          2125; THR-NEXT: Lines            0          0126; THR-NEXT: -----------------------------127; THR-NEXT: Total            7          2128