blob: dea30c9f2b37da62da8a732a68d2bea9aec888a5 [file] [log] [blame]
; REQUIRES: x86-registered-target
; Test case 5 - Incorrect lexical scope variable.
; pr-43860.cpp
; 1 #include "definitions.h"
; 2 forceinline int InlineFunction(int Param) {
; 3 int Var_1 = Param;
; 4 {
; 5 int Var_2 = Param + Var_1;
; 6 Var_1 = Var_2;
; 7 }
; 8 return Var_1;
; 9 }
; 10
; 11 int test(int Param_1, int Param_2) {
; 12 int A = Param_1;
; 13 A += InlineFunction(Param_2);
; 14 return A;
; 15 }
; The above test is used to illustrate a variable issue found in the
; Clang compiler.
; PR43860: https://bugs.llvm.org/show_bug.cgi?id=43860
; PR43205: https://github.com/llvm/llvm-project/issues/43205
; In the following logical views, we can see that the CodeView debug
; information generated by the Clang compiler shows the variables
; 'Var_1' and 'Var_2' are at the same lexical scope (4) in the function
; 'InlineFuction'.
; The CodeView generated by MSVC, show those variables at the correct
; lexical scope: '3' and '4' respectively.
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
; RUN: --output-sort=name \
; RUN: --print=symbols \
; RUN: %p/Inputs/pr-43860-codeview-clang.o \
; RUN: %p/Inputs/pr-43860-codeview-msvc.o 2>&1 | \
; RUN: FileCheck --strict-whitespace -check-prefix=ONE %s
; ONE: Logical View:
; ONE-NEXT: [000] {File} 'pr-43860-codeview-clang.o' -> COFF-x86-64
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-43860.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 15.0.0 {{.*}}'
; ONE-NEXT: [002] 2 {Function} inlined 'InlineFunction' -> 'int'
; ONE-NEXT: [003] {Parameter} '' -> 'int'
; ONE-NEXT: [002] {Function} extern not_inlined 'test' -> 'int'
; ONE-NEXT: [003] {Variable} 'A' -> 'int'
; ONE-NEXT: [003] {InlinedFunction} inlined 'InlineFunction' -> 'int'
; ONE-NEXT: [004] {Parameter} 'Param' -> 'int'
; ONE-NEXT: [004] {Variable} 'Var_1' -> 'int'
; ONE-NEXT: [004] {Variable} 'Var_2' -> 'int'
; ONE-NEXT: [003] {Parameter} 'Param_1' -> 'int'
; ONE-NEXT: [003] {Parameter} 'Param_2' -> 'int'
; ONE-EMPTY:
; ONE-NEXT: Logical View:
; ONE-NEXT: [000] {File} 'pr-43860-codeview-msvc.o' -> COFF-x86-64
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-43860.cpp'
; ONE-NEXT: [002] {Producer} 'Microsoft (R) Optimizing Compiler'
; ONE-NEXT: [002] {Function} extern declared_inlined 'InlineFunction' -> 'int'
; ONE-NEXT: [003] {Block}
; ONE-NEXT: [004] {Variable} 'Var_2' -> 'int'
; ONE-NEXT: [003] {Variable} 'Param' -> 'int'
; ONE-NEXT: [003] {Variable} 'Var_1' -> 'int'
; ONE-NEXT: [002] {Function} extern not_inlined 'test' -> 'int'
; ONE-NEXT: [003] {Variable} 'A' -> 'int'
; ONE-NEXT: [003] {Variable} 'Param_1' -> 'int'
; ONE-NEXT: [003] {Variable} 'Param_2' -> 'int'
; Using the selection facilities, we can produce a simple tabular output
; showing just the logical elements that have in their name the 'var'
; pattern. The logical view is sorted by the variables name.
; RUN: llvm-debuginfo-analyzer --attribute=level,format \
; RUN: --output-sort=name \
; RUN: --select-regex --select-nocase \
; RUN: --select=Var \
; RUN: --report=list \
; RUN: --print=symbols \
; RUN: %p/Inputs/pr-43860-*.o 2>&1 | \
; RUN: FileCheck --strict-whitespace -check-prefix=TWO %s
; TWO: Logical View:
; TWO-NEXT: [000] {File} 'pr-43860-codeview-clang.o' -> COFF-x86-64
; TWO-EMPTY:
; TWO-NEXT: [001] {CompileUnit} 'pr-43860.cpp'
; TWO-NEXT: [004] {Variable} 'Var_1' -> 'int'
; TWO-NEXT: [004] {Variable} 'Var_2' -> 'int'
; TWO-EMPTY:
; TWO-NEXT: Logical View:
; TWO-NEXT: [000] {File} 'pr-43860-codeview-msvc.o' -> COFF-x86-64
; TWO-EMPTY:
; TWO-NEXT: [001] {CompileUnit} 'pr-43860.cpp'
; TWO-NEXT: [003] {Variable} 'Var_1' -> 'int'
; TWO-NEXT: [004] {Variable} 'Var_2' -> 'int'