brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.4 KiB · aa628f7 Raw
100 lines · plain
1; REQUIRES: x86-registered-target2 3; Test case 5 - Incorrect lexical scope variable.4 5; pr-43860.cpp6;  1  #include "definitions.h"7;  2  forceinline int InlineFunction(int Param) {8;  3    int Var_1 = Param;9;  4    {10;  5      int Var_2 = Param + Var_1;11;  6      Var_1 = Var_2;12;  7    }13;  8    return Var_1;14;  9  }15; 1016; 11  int test(int Param_1, int Param_2) {17; 12    int A = Param_1;18; 13    A += InlineFunction(Param_2);19; 14    return A;20; 15  }21 22; The above test is used to illustrate a variable issue found in the23; Clang compiler.24; PR43860: https://bugs.llvm.org/show_bug.cgi?id=4386025; PR43205: https://github.com/llvm/llvm-project/issues/4320526 27; In the following logical views, we can see that the CodeView debug28; information generated by the Clang compiler shows the variables29; 'Var_1' and 'Var_2' are at the same lexical scope (4) in the function30; 'InlineFuction'.31; The CodeView generated by MSVC, show those variables at the correct32; lexical scope: '3' and '4' respectively.33 34; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer \35; RUN:                         --output-sort=name \36; RUN:                         --print=symbols \37; RUN:                         %p/Inputs/pr-43860-codeview-clang.o \38; RUN:                         %p/Inputs/pr-43860-codeview-msvc.o 2>&1 | \39; RUN: FileCheck --strict-whitespace -check-prefix=ONE %s40 41; ONE:      Logical View:42; ONE-NEXT: [000]           {File} 'pr-43860-codeview-clang.o' -> COFF-x86-6443; ONE-EMPTY:44; ONE-NEXT: [001]             {CompileUnit} 'pr-43860.cpp'45; ONE-NEXT: [002]               {Producer} 'clang version 15.0.0 {{.*}}'46; ONE-NEXT: [002]               {Language} 'Cpp'47; ONE-NEXT: [002]     2         {Function} inlined 'InlineFunction' -> 'int'48; ONE-NEXT: [003]                 {Parameter} '' -> 'int'49; ONE-NEXT: [002]               {Function} extern not_inlined 'test' -> 'int'50; ONE-NEXT: [003]                 {Variable} 'A' -> 'int'51; ONE-NEXT: [003]                 {InlinedFunction} inlined 'InlineFunction' -> 'int'52; ONE-NEXT: [004]                   {Parameter} 'Param' -> 'int'53; ONE-NEXT: [004]                   {Variable} 'Var_1' -> 'int'54; ONE-NEXT: [004]                   {Variable} 'Var_2' -> 'int'55; ONE-NEXT: [003]                 {Parameter} 'Param_1' -> 'int'56; ONE-NEXT: [003]                 {Parameter} 'Param_2' -> 'int'57; ONE-EMPTY:58; ONE-NEXT: Logical View:59; ONE-NEXT: [000]           {File} 'pr-43860-codeview-msvc.o' -> COFF-x86-6460; ONE-EMPTY:61; ONE-NEXT: [001]             {CompileUnit} 'pr-43860.cpp'62; ONE-NEXT: [002]               {Producer} 'Microsoft (R) Optimizing Compiler'63; ONE-NEXT: [002]               {Language} 'Cpp'64; ONE-NEXT: [002]               {Function} extern declared_inlined 'InlineFunction' -> 'int'65; ONE-NEXT: [003]                 {Block}66; ONE-NEXT: [004]                   {Variable} 'Var_2' -> 'int'67; ONE-NEXT: [003]                 {Variable} 'Param' -> 'int'68; ONE-NEXT: [003]                 {Variable} 'Var_1' -> 'int'69; ONE-NEXT: [002]               {Function} extern not_inlined 'test' -> 'int'70; ONE-NEXT: [003]                 {Variable} 'A' -> 'int'71; ONE-NEXT: [003]                 {Variable} 'Param_1' -> 'int'72; ONE-NEXT: [003]                 {Variable} 'Param_2' -> 'int'73 74; Using the selection facilities, we can produce a simple tabular output75; showing just the logical elements that have in their name the 'var'76; pattern. The logical view is sorted by the variables name.77 78; RUN: llvm-debuginfo-analyzer --attribute=level,format \79; RUN:                         --output-sort=name \80; RUN:                         --select-regex --select-nocase \81; RUN:                         --select=Var \82; RUN:                         --report=list \83; RUN:                         --print=symbols \84; RUN:                         %p/Inputs/pr-43860-*.o 2>&1 | \85; RUN: FileCheck --strict-whitespace -check-prefix=TWO %s86 87; TWO:      Logical View:88; TWO-NEXT: [000]           {File} 'pr-43860-codeview-clang.o' -> COFF-x86-6489; TWO-EMPTY:90; TWO-NEXT: [001]           {CompileUnit} 'pr-43860.cpp'91; TWO-NEXT: [004]           {Variable} 'Var_1' -> 'int'92; TWO-NEXT: [004]           {Variable} 'Var_2' -> 'int'93; TWO-EMPTY:94; TWO-NEXT: Logical View:95; TWO-NEXT: [000]           {File} 'pr-43860-codeview-msvc.o' -> COFF-x86-6496; TWO-EMPTY:97; TWO-NEXT: [001]           {CompileUnit} 'pr-43860.cpp'98; TWO-NEXT: [003]           {Variable} 'Var_1' -> 'int'99; TWO-NEXT: [004]           {Variable} 'Var_2' -> 'int'100