We extract and print the source location in the message header so that Visual Studio is able to parse it and jump there. As duplicate symbols defined in several locations, it is more convenient to have separate error messages, which allows a user to easily access all the locations.
Details
- Reviewers
ruiu chrisjackson grimar • espindola MaskRay - Commits
- rG07ceadda2524: [ELF] With --vs-diagnostics, print a separate message for each location of a…
rL367536: [ELF] With --vs-diagnostics, print a separate message for each location of a…
rLLD367536: [ELF] With --vs-diagnostics, print a separate message for each location of a…
Diff Detail
- Repository
- rLLD LLVM Linker
Event Timeline
I don't think we should change the original error message, as the original message seems to make more sense than the new one for users. Have you considered changing the regexp to parse this error message?
The original error message, when --vs-diagnostics is not used, is mostly the same. There is only a small improvement for a case when only one section, either for an old or new definition, is present.
On the other hand, one of the reasons for --vs-diagnostics is to provide a user with means to jump to the mentioned location. That is achieved by placing the location in front of the error message. Thus, as there are usually two source locations, there should be two separate error messages.
Have you considered changing the regexp to parse this error message?
I am afraid I might not fully understand your idea. Are you suggesting to detect this particular error message using regexps, divide it into pieces and then reconstruct two separate messages placing source locations at their beginnings?
I am afraid I might not fully understand your idea. Are you suggesting to detect this particular error message using regexps, divide it into pieces and then reconstruct two separate messages placing source locations at their beginnings?
I don't know if what you have suggested is what @ruiu intended, But I think that your interpretation makes a lot of sense. That way most of the vs-diagnostics related implementation can remain in ErrorHandler.
- Updated to use a regex to parse the original message and reconstruct two separate messages if both source locations are known.
@ruiu, is that what you meant?
Common/ErrorHandler.cpp | ||
---|---|---|
182 ↗ | (On Diff #211929) | I am not sure what you meant, but please note that according to https://en.cppreference.com/w/cpp/regex/match_results,
|
Common/ErrorHandler.cpp | ||
---|---|---|
182 ↗ | (On Diff #211929) | Ok, it wasn't obvious behavior. |
Common/ErrorHandler.cpp | ||
---|---|---|
186 ↗ | (On Diff #211929) | That was made in that way deliberately. It would be weird if, for example, having the error limit of 10 we produce 11 messages, no? |
Common/ErrorHandler.cpp | ||
---|---|---|
186 ↗ | (On Diff #211929) | No more wierd than having a fixed number of errors with !vsDiagnostics when error limit == 10/11 and having a different number of errors when vsDiagnostics is set. |
Common/ErrorHandler.cpp | ||
---|---|---|
186 ↗ | (On Diff #211929) | Well, if you insist, I'll change it. |
This LGTM, thanks. Lets see what Rui think.
Common/ErrorHandler.cpp | ||
---|---|---|
186 ↗ | (On Diff #212550) | nit: In LLD if one of the code branches is using {}, then another should also do that: if (errorLimit == 0 || errorCount < errorLimit) { printError(msg); } else ... (LLVM does not always use this style, but in LLD we always do in this way I think). |
test/ELF/vs-diagnostics-duplicate.s | ||
---|---|---|
12 | What about this line? It seems that the second line (e.g. "defined at duplicate2.s:20") is always repeating the same location as the first line (e.g. "duplicate2.s(20: error: ..."). |
Common/ErrorHandler.cpp | ||
---|---|---|
187 ↗ | (On Diff #212550) | Why did you have to change this line? |
Common/ErrorHandler.cpp | ||
---|---|---|
187 ↗ | (On Diff #212550) | I did not have to. It is a possible simplification, as we now have a separate method printErrorMsg. |
LGTM
Common/ErrorHandler.cpp | ||
---|---|---|
187 ↗ | (On Diff #212550) | Ah, OK, I got confused a little because previously there was a call of printError(msg) and printErrorMsg(...), so it looked very similar. |
What about this line? It seems that the second line (e.g. "defined at duplicate2.s:20") is always repeating the same location as the first line (e.g. "duplicate2.s(20: error: ...").