1;; This test checks output of the DWARF embedded source. 2 3; REQUIRES: x86-registered-target 4 5; RUN: llc -filetype=obj -o %t.o %s 6 7;; Check LLVM style output. 8; RUN: llvm-symbolizer --print-source-context-lines=3 --obj=%t.o 0 | \ 9; RUN: FileCheck %s --check-prefixes=COMMON,LLVM --strict-whitespace --match-full-lines --implicit-check-not={{.}} 10 11;; Check GNU output style. 12; RUN: llvm-symbolizer --print-source-context-lines=3 --obj=%t.o 0 --output-style=GNU | \ 13; RUN: FileCheck %s --check-prefixes=COMMON,GNU --strict-whitespace --match-full-lines --implicit-check-not={{.}} 14 15; COMMON:foo 16; LLVM-NEXT:/source.c:3:13 17; GNU-NEXT:/source.c:3 18; COMMON-NEXT:2 : // Line 2 19; COMMON-NEXT:3 >: void foo() {} 20; COMMON-NEXT:4 : // Line 4 21 22;; Check JSON style output. 23; RUN: llvm-symbolizer --print-source-context-lines=3 --obj=%t.o 0 --output-style=JSON | \ 24; RUN: FileCheck %s --check-prefix=JSON --strict-whitespace --match-full-lines --implicit-check-not={{.}} 25; JSON:[{"Address":"0x0","ModuleName":"{{.*}}.o","Symbol":[{"Column":13,"Discriminator":0,"FileName":"/source.c","FunctionName":"foo","Line":3,"Source":"2 : // Line 2\n3 >: void foo() {}\n4 : // Line 4\n","StartAddress":"0x0","StartFileName":"/source.c","StartLine":3}]}] 26 27;; Generated from the following source: 28;; // Line 1 29;; // Line 2 30;; void foo() {} 31;; // Line 4 32;; // Line 5 33;; clang --target=x86_64-pc-linux -gdwarf-5 -gembed-source -g -emit-llvm -S source.c -o source.ll 34 35source_filename = "source.c" 36target triple = "x86_64-pc-linux" 37 38define dso_local void @foo() #0 !dbg !7 { 39entry: 40 ret void, !dbg !10 41} 42 43!llvm.dbg.cu = !{!0} 44!llvm.module.flags = !{!3, !4, !5} 45!llvm.ident = !{!6} 46 47!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) 48!1 = !DIFile(filename: "source.c", directory: "/", source: "// Line 1\0A// Line 2\0Avoid foo() {}\0A// Line 4\0A// Line 5\0A") 49!2 = !{} 50!3 = !{i32 7, !"Dwarf Version", i32 5} 51!4 = !{i32 2, !"Debug Info Version", i32 3} 52!5 = !{i32 1, !"wchar_size", i32 4} 53!6 = !{!"clang version 12.0.0"} 54!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 55!8 = !DISubroutineType(types: !9) 56!9 = !{null} 57!10 = !DILocation(line: 3, column: 13, scope: !7) 58