-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lld/mac] Port typo correction for undefined symbols from ELF port
Ports: - core feature: https://reviews.llvm.org/D67039 - case mismatch: https://reviews.llvm.org/D70506 - extern "C" suggestions: https://reviews.llvm.org/D69592, https://reviews.llvm.org/D69650 Does not port https://reviews.llvm.org/D71735 since I believe that that doesn't apply to lld/Mach-O. Differential Revision: https://reviews.llvm.org/D135038
- Loading branch information
Showing
4 changed files
with
264 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# REQUIRES: x86 | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %s -o %t.o | ||
|
||
## Insert a character. | ||
## The spell corrector is enabled for the first two "undefined symbol" diagnostics. | ||
# RUN: echo 'call bcde; call abcd; call abde' | llvm-mc -filetype=obj -triple=x86_64-apple-macos - -o %t1.o | ||
# RUN: not %lld %t.o %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=INSERT %s -DFILE=%t.o | ||
|
||
## Symbols defined in DSO can be suggested. | ||
# RUN: %lld %t.o -dylib -o %t.dylib | ||
# RUN: not %lld %t.dylib %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=INSERT %s -DFILE=%t.dylib | ||
|
||
# INSERT: error: undefined symbol: abde | ||
# INSERT-NEXT: >>> referenced by {{.*}} | ||
# INSERT-NEXT: >>> did you mean: abcde | ||
# INSERT-NEXT: >>> defined in: [[FILE]] | ||
# INSERT: error: undefined symbol: abcd | ||
# INSERT-NEXT: >>> referenced by {{.*}} | ||
# INSERT-NEXT: >>> did you mean: abcde | ||
# INSERT-NEXT: >>> defined in: [[FILE]] | ||
# INSERT: error: undefined symbol: bcde | ||
# INSERT-NEXT: >>> referenced by {{.*}} | ||
# INSERT-NOT: >>> | ||
|
||
## Substitute a character. | ||
# RUN: echo 'call bbcde; call abcdd' | llvm-mc -filetype=obj -triple=x86_64-apple-macos - -o %t1.o | ||
# RUN: not %lld %t.o %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=SUBST %s | ||
|
||
# SUBST: error: undefined symbol: abcdd | ||
# SUBST-NEXT: >>> referenced by {{.*}} | ||
# SUBST-NEXT: >>> did you mean: abcde | ||
# SUBST: error: undefined symbol: bbcde | ||
# SUBST-NEXT: >>> referenced by {{.*}} | ||
# SUBST-NEXT: >>> did you mean: abcde | ||
|
||
## Delete a character. | ||
# RUN: echo 'call aabcde; call abcdee' | llvm-mc -filetype=obj -triple=x86_64-apple-macos - -o %t1.o | ||
# RUN: not %lld %t.o %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=DELETE %s | ||
|
||
# DELETE: error: undefined symbol: abcdee | ||
# DELETE-NEXT: >>> referenced by {{.*}} | ||
# DELETE-NEXT: >>> did you mean: abcde | ||
# DELETE: error: undefined symbol: aabcde | ||
# DELETE-NEXT: >>> referenced by {{.*}} | ||
# DELETE-NEXT: >>> did you mean: abcde | ||
|
||
## Transpose. | ||
# RUN: echo 'call bacde' | llvm-mc -filetype=obj -triple=x86_64-apple-macos - -o %t1.o | ||
# RUN: not %lld %t.o %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=TRANSPOSE %s | ||
|
||
# TRANSPOSE: error: undefined symbol: bacde | ||
# TRANSPOSE-NEXT: >>> referenced by {{.*}} | ||
# TRANSPOSE-NEXT: >>> did you mean: abcde | ||
|
||
## Missing const qualifier. | ||
# RUN: echo 'call __Z3fooPi' | llvm-mc -filetype=obj -triple=x86_64-apple-macos - -o %t1.o | ||
# RUN: not %lld %t.o %t1.o -demangle -o /dev/null 2>&1 | FileCheck --check-prefix=CONST %s | ||
## Local defined symbols. | ||
# RUN: echo '__Z3fooPKi: call __Z3fooPi' | llvm-mc -filetype=obj -triple=x86_64-apple-macos - -o %t1.o | ||
# RUN: not %lld %t1.o -demangle -o /dev/null 2>&1 | FileCheck --check-prefix=CONST %s | ||
|
||
# CONST: error: undefined symbol: foo(int*) | ||
# CONST-NEXT: >>> referenced by {{.*}} | ||
# CONST-NEXT: >>> did you mean: foo(int const*) | ||
|
||
## Case mismatch. | ||
# RUN: echo 'call __Z3FOOPKi' | llvm-mc -filetype=obj -triple=x86_64-apple-macos - -o %t1.o | ||
# RUN: not %lld %t.o %t1.o -demangle -o /dev/null 2>&1 | FileCheck --check-prefix=CASE %s | ||
# RUN: echo '__Z3fooPKi: call __Z3FOOPKi' | llvm-mc -filetype=obj -triple=x86_64-apple-macos - -o %t1.o | ||
# RUN: not %lld %t1.o -demangle -o /dev/null 2>&1 | FileCheck --check-prefix=CASE %s | ||
|
||
# CASE: error: undefined symbol: FOO(int const*) | ||
# CASE-NEXT: >>> referenced by {{.*}} | ||
# CASE-NEXT: >>> did you mean: foo(int const*) | ||
|
||
.globl _main, abcde, __Z3fooPKi | ||
_main: | ||
abcde: | ||
__Z3fooPKi: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# REQUIRES: x86 | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %s -o %t.o | ||
|
||
## The reference is mangled while the definition is not, suggest a missing | ||
## extern "C". | ||
# RUN: echo 'call __Z3fooi' | llvm-mc -filetype=obj -triple=x86_64-apple-macos - -o %t1.o | ||
# RUN: not %lld %t.o %t1.o -demangle -o /dev/null 2>&1 | FileCheck %s | ||
|
||
# CHECK: error: undefined symbol: foo(int) | ||
# CHECK-NEXT: >>> referenced by {{.*}} | ||
# CHECK-NEXT: >>> did you mean: extern "C" _foo | ||
|
||
## Don't suggest for nested names like F::foo() and foo::foo(). | ||
# RUN: echo 'call __ZN1F3fooEv; call __ZN3fooC1Ev' | llvm-mc -filetype=obj -triple=x86_64-apple-macos - -o %t2.o | ||
# RUN: not ld.lld %t.o %t2.o -o /dev/null 2>&1 | FileCheck /dev/null --implicit-check-not='did you mean' | ||
|
||
.globl _start, _foo | ||
_start: | ||
_foo: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# REQUIRES: x86 | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %s -o %t.o | ||
|
||
## The definition is mangled while the reference is not, suggest an arbitrary | ||
## C++ overload. | ||
# RUN: echo '.globl __Z3fooi; __Z3fooi:' | llvm-mc -filetype=obj -triple=x86_64-apple-macos - -o %t1.o | ||
# RUN: not %lld %t.o %t1.o -demangle -o /dev/null 2>&1 | FileCheck %s | ||
|
||
## Check that we can suggest a local definition. | ||
# RUN: echo '__Z3fooi: call _foo' | llvm-mc -filetype=obj -triple=x86_64-apple-macos - -o %t2.o | ||
# RUN: not %lld %t2.o -demangle -o /dev/null 2>&1 | FileCheck %s | ||
|
||
# CHECK: error: undefined symbol: _foo | ||
# CHECK-NEXT: >>> referenced by {{.*}} | ||
# CHECK-NEXT: >>> did you mean to declare foo(int) as extern "C"? | ||
|
||
## Don't suggest nested names whose base name is "foo", e.g. F::foo(). | ||
# RUN: echo '.globl __ZN1F3fooEv; __ZN1F3fooEv:' | llvm-mc -filetype=obj -triple=x86_64-apple-macos - -o %t3.o | ||
# RUN: not %lld %t.o %t3.o -o /dev/null 2>&1 | FileCheck /dev/null --implicit-check-not='did you mean' | ||
|
||
call _foo |