blob: b7c646a10301911447f899cf260f9f7f06815aec [file] [log] [blame]
; REQUIRES: x86-registered-target
; Test case 3 - Incorrect lexical scope for typedef.
; pr-44884.cpp
; 1 int bar(float Input) { return (int)Input; }
; 2
; 3 unsigned foo(char Param) {
; 4 typedef int INT; // ** Definition for INT **
; 5 INT Value = Param;
; 6 {
; 7 typedef float FLOAT; // ** Definition for FLOAT **
; 8 {
; 9 FLOAT Added = Value + Param;
; 10 Value = bar(Added);
; 11 }
; 12 }
; 13 return Value + Param;
; 14 }
; The lines 4 and 7 contains 2 typedefs, defined at different lexical
; scopes.
; The above test is used to illustrates a scope issue found in the
; Clang compiler.
; PR44884: https://bugs.llvm.org/show_bug.cgi?id=44884
; PR44229: https://github.com/llvm/llvm-project/issues/44229
; In the following logical views, we can see that the Clang compiler
; emits both typedefs at the same lexical scope (3), which is wrong.
; GCC and MSVC emit correct lexical scope for both typedefs.
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
; RUN: --output-sort=kind \
; RUN: --print=symbols,types,lines \
; RUN: %p/Inputs/pr-44884-codeview-clang.o \
; RUN: %p/Inputs/pr-44884-codeview-msvc.o 2>&1 | \
; RUN: FileCheck --strict-whitespace -check-prefix=ONE %s
; ONE: Logical View:
; ONE-NEXT: [000] {File} 'pr-44884-codeview-clang.o' -> COFF-x86-64
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-44884.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 15.0.0 {{.*}}'
; ONE-NEXT: [002] {Function} extern not_inlined 'bar' -> 'int'
; ONE-NEXT: [003] {Parameter} 'Input' -> 'float'
; ONE-NEXT: [003] 1 {Line}
; ONE-NEXT: [002] {Function} extern not_inlined 'foo' -> 'unsigned'
; ONE-NEXT: [003] {Block}
; ONE-NEXT: [004] {Variable} 'Added' -> 'float'
; ONE-NEXT: [004] 9 {Line}
; ONE-NEXT: [004] 10 {Line}
; ONE-NEXT: [003] {Parameter} 'Param' -> 'char'
; ONE-NEXT: [003] {TypeAlias} 'FLOAT' -> 'float'
; ONE-NEXT: [003] {TypeAlias} 'INT' -> 'int'
; ONE-NEXT: [003] {Variable} 'Value' -> 'int'
; ONE-NEXT: [003] 3 {Line}
; ONE-NEXT: [003] 5 {Line}
; ONE-NEXT: [003] 13 {Line}
; ONE-EMPTY:
; ONE-NEXT: Logical View:
; ONE-NEXT: [000] {File} 'pr-44884-codeview-msvc.o' -> COFF-x86-64
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-44884.cpp'
; ONE-NEXT: [002] {Producer} 'Microsoft (R) Optimizing Compiler'
; ONE-NEXT: [002] {Function} extern not_inlined 'bar' -> 'int'
; ONE-NEXT: [003] {Variable} 'Input' -> 'float'
; ONE-NEXT: [003] 1 {Line}
; ONE-NEXT: [002] {Function} extern not_inlined 'foo' -> 'unsigned'
; ONE-NEXT: [003] {Block}
; ONE-NEXT: [004] {Block}
; ONE-NEXT: [005] {Variable} 'Added' -> 'float'
; ONE-NEXT: [004] {TypeAlias} 'FLOAT' -> 'float'
; ONE-NEXT: [004] 9 {Line}
; ONE-NEXT: [004] 10 {Line}
; ONE-NEXT: [003] {TypeAlias} 'INT' -> 'int'
; ONE-NEXT: [003] {Variable} 'Param' -> 'char'
; ONE-NEXT: [003] {Variable} 'Value' -> 'int'
; ONE-NEXT: [003] 3 {Line}
; ONE-NEXT: [003] 5 {Line}
; ONE-NEXT: [003] 13 {Line}
; ONE-NEXT: [003] 14 {Line}
; Using the selection facilities, we can produce a simple tabular
; output showing just the logical types that are 'Typedef'.
; RUN: llvm-debuginfo-analyzer --attribute=level,format \
; RUN: --output-sort=name \
; RUN: --select-types=Typedef \
; RUN: --report=list \
; RUN: --print=types \
; RUN: %p/Inputs/pr-44884-*.o 2>&1 | \
; RUN: FileCheck --strict-whitespace -check-prefix=TWO %s
; TWO: Logical View:
; TWO-NEXT: [000] {File} 'pr-44884-codeview-clang.o' -> COFF-x86-64
; TWO-EMPTY:
; TWO-NEXT: [001] {CompileUnit} 'pr-44884.cpp'
; TWO-NEXT: [003] {TypeAlias} 'FLOAT' -> 'float'
; TWO-NEXT: [003] {TypeAlias} 'INT' -> 'int'
; TWO-EMPTY:
; TWO-NEXT: Logical View:
; TWO-NEXT: [000] {File} 'pr-44884-codeview-msvc.o' -> COFF-x86-64
; TWO-EMPTY:
; TWO-NEXT: [001] {CompileUnit} 'pr-44884.cpp'
; TWO-NEXT: [004] {TypeAlias} 'FLOAT' -> 'float'
; TWO-NEXT: [003] {TypeAlias} 'INT' -> 'int'