Given the following test case: //------------------------------------------------------------ // typedef.cpp //------------------------------------------------------------ int bar(float Input) { return (int)Input; } unsigned foo(char Param) { typedef int INT; INT Value = Param; { typedef float FLOAT; { FLOAT Added = Value + Param; Value = bar(Added); } } return Value + Param; } //------------------------------------------------------------ Using the following command line options to generate debug info (DWARF) and (COFF): clang -c -g -O0 typedef.cpp -o typedef.o clang -c -g -O0 typedef.cpp -o typedef-coff.o -gcodeview --target=x86_64-windows Looking at the output generated by llvm-dwarfdump and llvm-diva, the debug info shows the typedefs 'INT'and 'FLOAT' to be at the same lexical scope (function scope).
Using llvm-diva with the following command: llvm-diva --print=scopes,types --attribute=level,format typedef.o typedef-coff.o Logical View: [000] {File} 'typedef.o' -> ELF64-x86-64 [001] {CompileUnit} 'typedef.cpp' [002] 1 {Function} extern not_inlined 'bar' -> 'int' [002] 3 {Function} extern not_inlined 'foo' -> 'unsigned int' [003] {Block} [003] 4 {TypeAlias} 'INT' -> 'int' [003] 7 {TypeAlias} 'FLOAT' -> 'float' Logical View: [000] {File} 'typedef-coff.o' -> COFF-x86-64 [001] {CompileUnit} 'typedef.cpp' [002] {Function} not_inlined 'bar' -> 'int' [002] {Function} not_inlined 'foo' -> 'unsigned' [003] {Block} [002] {Namespace} 'foo' [003] {TypeAlias} 'FLOAT' -> 'float' [003] {TypeAlias} 'INT' -> 'int' Both outputs shows 'FLOAT' and 'INT' at level 3, which is incorrect.
Now using GCC with the following line: gcc -c -g -O0 typedef.cpp -o typedef-gcc.o the output generated by llvm-diva is: Logical View: [000] {File} 'typedef-gcc.o' -> ELF64-x86-64 [001] {CompileUnit} 'typedef.cpp' [002] 1 {Function} extern not_inlined 'bar' -> 'int' [002] 3 {Function} extern not_inlined 'foo' -> 'unsigned int' [003] {Block} [004] {Block} [004] 7 {TypeAlias} 'FLOAT' -> 'float' [003] 4 {TypeAlias} 'INT' -> 'int' It shows: 'INT' at level (3) (Function scope). 'FLOAT' at level (4) (Lexical scope). which is correct.