[PATCH] D27676: [ELF] - Use full object name if source file name exist when reporting errors.
Sean Silva via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 14 15:15:31 PST 2016
silvas added a comment.
In https://reviews.llvm.org/D27676#622851, @ruiu wrote:
> I thought about this for a while. I'd say that having `foo.a(foo.o)(foo.c)` and `foo.o(foo.c)` are not correct because they are inconsistent. If the former were `foo.a(foo.o(foo.c))`, the two are at least consistent, but I guess that's hard to read.
>
> We have a lot of combinations here.
>
> - Is an object file in an archive file? Yes or no
> - Do we know source filename? Yes or not
> - What do we know about the error location inside of the object file: Line number in the original source code, section name in an object file, or nothing
I think we can keep the source file / line location information completely separate from the object file location information.
If you think of clang, the `error:` is often consistent with GCC. When clang provides more information (e.g. "did you mean?", "expanded from macro FOO defined here.", ...) it is usually as a note. Maybe we can be consistent with that: we produce a similar diagnostic to existing linkers, but below each `error:` line, we can add a handy `note:`.
For example, look at Clang's output for this:
https://godbolt.org/g/GMFHeq
#line 1 "foo.c"
#define DEFINITION_OF_FOO void foo() {}
DEFINITION_OF_FOO
DEFINITION_OF_FOO
The diagnostic is:
foo.c:4:1: error: redefinition of 'foo'
DEFINITION_OF_FOO
^
foo.c:1:32: note: expanded from macro 'DEFINITION_OF_FOO'
#define DEFINITION_OF_FOO void foo() {}
^
foo.c:3:1: note: previous definition is here
DEFINITION_OF_FOO
^
foo.c:1:32: note: expanded from macro 'DEFINITION_OF_FOO'
#define DEFINITION_OF_FOO void foo() {}
^
1 error generated.
I think we can be consistent with that. The `error: redefinition of 'foo'` and `note: previous definition is here` would be basically traditional object location linker diagnostics.
The `note: expanded from macro 'DEFINITION_OF_FOO'` and `note: expanded from macro 'DEFINITION_OF_FOO'` would be our extended linker diagnostics providing the original source location. But instead of "expanded from macro" they would be a message like `note: source code of definition is here`
https://reviews.llvm.org/D27676
More information about the llvm-commits
mailing list