; REQUIRES: webassembly-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 emit correct lexical scope for both typedefs.
; RUN: llvm-mc -arch=wasm32 -filetype=obj \
; RUN: %p/Inputs/pr-44884-clang.s -o %t.pr-44884-clang.o
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
; RUN: --output-sort=kind \
; RUN: --print=symbols,types,lines \
; RUN: %t.pr-44884-clang.o \
; RUN: %p/../DWARF/Inputs/pr-44884-dwarf-gcc.o 2>&1 | \
; RUN: FileCheck --strict-whitespace -check-prefix=ONE %s
; ONE: Logical View:
; ONE-NEXT: [000] {File} '{{.*}}pr-44884-clang.o' -> WASM
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-44884.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 19{{.*}}'
; ONE-NEXT: [002] 1 {Function} extern not_inlined 'bar' -> 'int'
; ONE-NEXT: [003] 1 {Parameter} 'Input' -> 'float'
; ONE-NEXT: [003] 1 {Line}
; ONE-NEXT: [003] 1 {Line}
; ONE-NEXT: [003] - {Line}
; ONE-NEXT: [003] 1 {Line}
; ONE-NEXT: [003] - {Line}
; ONE-NEXT: [003] 1 {Line}
; ONE-NEXT: [003] 1 {Line}
; ONE-NEXT: [003] 1 {Line}
; ONE-NEXT: [002] 3 {Function} extern not_inlined 'foo' -> 'unsigned int'
; ONE-NEXT: [003] {Block}
; ONE-NEXT: [004] 9 {Variable} 'Added' -> 'FLOAT'
; ONE-NEXT: [004] 9 {Line}
; ONE-NEXT: [004] 9 {Line}
; ONE-NEXT: [004] 9 {Line}
; ONE-NEXT: [004] 9 {Line}
; ONE-NEXT: [004] 9 {Line}
; ONE-NEXT: [004] 10 {Line}
; ONE-NEXT: [004] 10 {Line}
; ONE-NEXT: [004] 10 {Line}
; ONE-NEXT: [004] 13 {Line}
; ONE-NEXT: [003] 3 {Parameter} 'Param' -> 'char'
; ONE-NEXT: [003] 7 {TypeAlias} 'FLOAT' -> 'float'
; ONE-NEXT: [003] 4 {TypeAlias} 'INT' -> 'int'
; ONE-NEXT: [003] 5 {Variable} 'Value' -> 'INT'
; ONE-NEXT: [003] 3 {Line}
; ONE-NEXT: [003] 5 {Line}
; ONE-NEXT: [003] 5 {Line}
; ONE-NEXT: [003] 13 {Line}
; ONE-NEXT: [003] 13 {Line}
; ONE-NEXT: [003] 13 {Line}
; ONE-NEXT: [003] 13 {Line}
; ONE-EMPTY:
; ONE-NEXT: Logical View:
; ONE-NEXT: [000] {File} 'pr-44884-dwarf-gcc.o' -> elf64-x86-64
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-44884.cpp'
; ONE-NEXT: [002] {Producer} 'GNU C++14 10.3.0 {{.*}}'
; ONE-NEXT: [002] 1 {Function} extern not_inlined 'bar' -> 'int'
; ONE-NEXT: [003] 1 {Parameter} 'Input' -> 'float'
; ONE-NEXT: [003] 1 {Line}
; ONE-NEXT: [003] 1 {Line}
; ONE-NEXT: [003] 1 {Line}
; ONE-NEXT: [002] 3 {Function} extern not_inlined 'foo' -> 'unsigned int'
; ONE-NEXT: [003] {Block}
; ONE-NEXT: [004] {Block}
; ONE-NEXT: [005] 9 {Variable} 'Added' -> 'FLOAT'
; ONE-NEXT: [005] 9 {Line}
; ONE-NEXT: [005] 9 {Line}
; ONE-NEXT: [005] 9 {Line}
; ONE-NEXT: [005] 10 {Line}
; ONE-NEXT: [005] 13 {Line}
; ONE-NEXT: [004] 7 {TypeAlias} 'FLOAT' -> 'float'
; ONE-NEXT: [003] 3 {Parameter} 'Param' -> 'char'
; ONE-NEXT: [003] 4 {TypeAlias} 'INT' -> 'int'
; ONE-NEXT: [003] 5 {Variable} 'Value' -> 'INT'
; ONE-NEXT: [003] 3 {Line}
; ONE-NEXT: [003] 5 {Line}
; ONE-NEXT: [003] 13 {Line}
; ONE-NEXT: [003] 14 {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: %t.pr-44884-clang.o \
; RUN: %p/../DWARF/Inputs/pr-44884-dwarf-gcc.o 2>&1 | \
; RUN: FileCheck --strict-whitespace -check-prefix=TWO %s
; TWO: Logical View:
; TWO-NEXT: [000] {File} '{{.*}}pr-44884-clang.o' -> WASM
; TWO-EMPTY:
; TWO-NEXT: [001] {CompileUnit} 'pr-44884.cpp'
; TWO-NEXT: [003] 7 {TypeAlias} 'FLOAT' -> 'float'
; TWO-NEXT: [003] 4 {TypeAlias} 'INT' -> 'int'
; TWO-EMPTY:
; TWO-NEXT: Logical View:
; TWO-NEXT: [000] {File} 'pr-44884-dwarf-gcc.o' -> elf64-x86-64
; TWO-EMPTY:
; TWO-NEXT: [001] {CompileUnit} 'pr-44884.cpp'
; TWO-NEXT: [004] 7 {TypeAlias} 'FLOAT' -> 'float'
; TWO-NEXT: [003] 4 {TypeAlias} 'INT' -> 'int'