[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / undef-spell-corrector.s
blob3ad2421a6cd63b300d03ff7e26b8d6cb15b4c962
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
4 ## Insert a character.
5 ## The spell corrector is enabled for the first two "undefined symbol" diagnostics.
6 # RUN: echo 'call bcde; call abcd; call abde' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
7 # RUN: not ld.lld %t.o %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=INSERT %s -DFILE=%t.o
9 ## Symbols defined in DSO can be suggested.
10 # RUN: ld.lld %t.o -shared -o %t.so
11 # RUN: not ld.lld %t.so %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=INSERT %s -DFILE=%t.so
13 # INSERT: error: undefined symbol: bcde
14 # INSERT-NEXT: >>> referenced by {{.*}}
15 # INSERT-NEXT: >>> did you mean: abcde
16 # INSERT-NEXT: >>> defined in: [[FILE]]
17 # INSERT: error: undefined symbol: abcd
18 # INSERT-NEXT: >>> referenced by {{.*}}
19 # INSERT-NEXT: >>> did you mean: abcde
20 # INSERT-NEXT: >>> defined in: [[FILE]]
21 # INSERT: error: undefined symbol: abde
22 # INSERT-NEXT: >>> referenced by {{.*}}
23 # INSERT-NOT: >>>
25 ## Substitute a character.
26 # RUN: echo 'call bbcde; call abcdd' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
27 # RUN: not ld.lld %t.o %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=SUBST %s
29 # SUBST: error: undefined symbol: bbcde
30 # SUBST-NEXT: >>> referenced by {{.*}}
31 # SUBST-NEXT: >>> did you mean: abcde
32 # SUBST: error: undefined symbol: abcdd
33 # SUBST-NEXT: >>> referenced by {{.*}}
34 # SUBST-NEXT: >>> did you mean: abcde
36 ## Delete a character.
37 # RUN: echo 'call aabcde; call abcdee' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
38 # RUN: not ld.lld %t.o %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=DELETE %s
40 # DELETE: error: undefined symbol: aabcde
41 # DELETE-NEXT: >>> referenced by {{.*}}
42 # DELETE-NEXT: >>> did you mean: abcde
43 # DELETE: error: undefined symbol: abcdee
44 # DELETE-NEXT: >>> referenced by {{.*}}
45 # DELETE-NEXT: >>> did you mean: abcde
47 ## Transpose.
48 # RUN: echo 'call bacde' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
49 # RUN: not ld.lld %t.o %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=TRANSPOSE %s
51 # TRANSPOSE: error: undefined symbol: bacde
52 # TRANSPOSE-NEXT: >>> referenced by {{.*}}
53 # TRANSPOSE-NEXT: >>> did you mean: abcde
55 ## Missing const qualifier.
56 # RUN: echo 'call _Z3fooPi' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
57 # RUN: not ld.lld %t.o %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=CONST %s
58 ## Local defined symbols.
59 # RUN: echo '_Z3fooPKi: call _Z3fooPi' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
60 # RUN: not ld.lld %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=CONST %s
62 # CONST: error: undefined symbol: foo(int*)
63 # CONST-NEXT: >>> referenced by {{.*}}
64 # CONST-NEXT: >>> did you mean: foo(int const*)
66 ## Case mismatch.
67 # RUN: echo 'call _Z3FOOPKi' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
68 # RUN: not ld.lld %t.o %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=CASE %s
69 # RUN: echo '_Z3fooPKi: call _Z3FOOPKi' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
70 # RUN: not ld.lld %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=CASE %s
72 # CASE: error: undefined symbol: FOO(int const*)
73 # CASE-NEXT: >>> referenced by {{.*}}
74 # CASE-NEXT: >>> did you mean: foo(int const*)
76 .globl _start, abcde, _Z3fooPKi
77 _start:
78 abcde:
79 _Z3fooPKi: