xref: /llvm-project/lld/test/ELF/undef-spell-corrector.s (revision 427b728834622dc879bca845def8d3d1c0108058)
1# REQUIRES: x86
2
3# RUN: rm -rf %t && split-file %s %t
4# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/test.s -o %t/test.o
5# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/bcde-abcd-abde.s -o %t/bcde-abcd-abde.o
6# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/bbcde-abcdd.s -o %t/bbcde-abcdd.o
7# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/aabcde-abcdee.s -o %t/aabcde-abcdee.o
8# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/bacde.s -o %t/bacde.o
9# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/_Z3fooPi.s -o %t/_Z3fooPi.o
10# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/_Z3fooPKi-_Z3fooPi.s -o %t/_Z3fooPKi-_Z3fooPi.o
11# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/_Z3FOOPKi.s -o %t/_Z3FOOPKi.o
12# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/_Z3fooPKi-_Z3FOOPKi.s -o %t/_Z3fooPKi-_Z3FOOPKi.o
13
14## Insert a character.
15## The spell corrector is enabled for the first two "undefined symbol" diagnostics.
16# RUN: not ld.lld %t/test.o %t/bcde-abcd-abde.o -o /dev/null 2>&1 | FileCheck --check-prefix=INSERT %s -DFILE=%t/test.o
17
18## Symbols defined in DSO can be suggested.
19# RUN: ld.lld %t/test.o -shared -o %t.so
20# RUN: not ld.lld %t.so %t/bcde-abcd-abde.o -o /dev/null 2>&1 | FileCheck --check-prefix=INSERT %s -DFILE=%t.so
21
22# INSERT:      error: undefined symbol: bcde
23# INSERT-NEXT: >>> referenced by {{.*}}
24# INSERT-NEXT: >>> did you mean: abcde
25# INSERT-NEXT: >>> defined in: [[FILE]]
26# INSERT:      error: undefined symbol: abcd
27# INSERT-NEXT: >>> referenced by {{.*}}
28# INSERT-NEXT: >>> did you mean: abcde
29# INSERT-NEXT: >>> defined in: [[FILE]]
30# INSERT:      error: undefined symbol: abde
31# INSERT-NEXT: >>> referenced by {{.*}}
32# INSERT-NOT:  >>>
33
34## Substitute a character.
35# RUN: not ld.lld %t/test.o %t/bbcde-abcdd.o -o /dev/null 2>&1 | FileCheck --check-prefix=SUBST %s
36
37# SUBST:      error: undefined symbol: bbcde
38# SUBST-NEXT: >>> referenced by {{.*}}
39# SUBST-NEXT: >>> did you mean: abcde
40# SUBST:      error: undefined symbol: abcdd
41# SUBST-NEXT: >>> referenced by {{.*}}
42# SUBST-NEXT: >>> did you mean: abcde
43
44## Delete a character.
45# RUN: not ld.lld %t/test.o %t/aabcde-abcdee.o -o /dev/null 2>&1 | FileCheck --check-prefix=DELETE %s
46
47# DELETE:      error: undefined symbol: aabcde
48# DELETE-NEXT: >>> referenced by {{.*}}
49# DELETE-NEXT: >>> did you mean: abcde
50# DELETE:      error: undefined symbol: abcdee
51# DELETE-NEXT: >>> referenced by {{.*}}
52# DELETE-NEXT: >>> did you mean: abcde
53
54## Transpose.
55# RUN: not ld.lld %t/test.o %t/bacde.o -o /dev/null 2>&1 | FileCheck --check-prefix=TRANSPOSE %s
56
57# TRANSPOSE:      error: undefined symbol: bacde
58# TRANSPOSE-NEXT: >>> referenced by {{.*}}
59# TRANSPOSE-NEXT: >>> did you mean: abcde
60
61## Missing const qualifier.
62# RUN: not ld.lld %t/test.o %t/_Z3fooPi.o -o /dev/null 2>&1 | FileCheck --check-prefix=CONST %s
63## Local defined symbols.
64# RUN: not ld.lld %t/_Z3fooPKi-_Z3fooPi.o -o /dev/null 2>&1 | FileCheck --check-prefix=CONST %s
65
66# CONST:      error: undefined symbol: foo(int*)
67# CONST-NEXT: >>> referenced by {{.*}}
68# CONST-NEXT: >>> did you mean: foo(int const*)
69
70## Case mismatch.
71# RUN: not ld.lld %t/test.o %t/_Z3FOOPKi.o -o /dev/null 2>&1 | FileCheck --check-prefix=CASE %s
72# RUN: not ld.lld %t/_Z3fooPKi-_Z3FOOPKi.o -o /dev/null 2>&1 | FileCheck --check-prefix=CASE %s
73
74# CASE:      error: undefined symbol: FOO(int const*)
75# CASE-NEXT: >>> referenced by {{.*}}
76# CASE-NEXT: >>> did you mean: foo(int const*)
77
78#--- test.s
79.globl _start, abcde, _Z3fooPKi
80_start:
81abcde:
82_Z3fooPKi:
83
84#--- bcde-abcd-abde.s
85call bcde
86call abcd
87call abde
88
89#--- bbcde-abcdd.s
90call bbcde
91call abcdd
92
93#--- aabcde-abcdee.s
94call aabcde
95call abcdee
96
97#--- bacde.s
98call bacde
99
100#--- _Z3fooPi.s
101call _Z3fooPi
102
103#--- _Z3fooPKi-_Z3fooPi.s
104_Z3fooPKi: call _Z3fooPi
105
106#--- _Z3FOOPKi.s
107call _Z3FOOPKi
108
109#--- _Z3fooPKi-_Z3FOOPKi.s
110_Z3fooPKi: call _Z3FOOPKi
111