diff options
| author | Igor Kudrin <ikudrin@accesssoftek.com> | 2019-08-01 09:58:03 +0000 |
|---|---|---|
| committer | Igor Kudrin <ikudrin@accesssoftek.com> | 2019-08-01 09:58:03 +0000 |
| commit | 07ceadda2524582147ebac69d2dd22c876df4693 (patch) | |
| tree | 792c2b51744aacad0672119a5db2ae991b626b4c /lld/Common | |
| parent | 8a40cedfe695869408412c018799d08a6ffc006c (diff) | |
| download | bcm5719-llvm-07ceadda2524582147ebac69d2dd22c876df4693.tar.gz bcm5719-llvm-07ceadda2524582147ebac69d2dd22c876df4693.zip | |
[ELF] With --vs-diagnostics, print a separate message for each location of a duplicate symbol.
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
are defined in several locations, it is more convenient to have separate
error messages, which allows a user to easily access all the locations.
Differential Revision: https://reviews.llvm.org/D65213
llvm-svn: 367536
Diffstat (limited to 'lld/Common')
| -rw-r--r-- | lld/Common/ErrorHandler.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/lld/Common/ErrorHandler.cpp b/lld/Common/ErrorHandler.cpp index 7e417da8989..68ea0a10bf5 100644 --- a/lld/Common/ErrorHandler.cpp +++ b/lld/Common/ErrorHandler.cpp @@ -153,13 +153,34 @@ void ErrorHandler::warn(const Twine &msg) { *errorOS << msg << "\n"; } +void ErrorHandler::printErrorMsg(const Twine &msg) { + newline(errorOS, msg); + printHeader("error: ", raw_ostream::RED, msg); + *errorOS << msg << "\n"; +} + +void ErrorHandler::printError(const Twine &msg) { + if (vsDiagnostics) { + static std::regex reDuplicateSymbol( + R"(^(duplicate symbol: .*))" + R"((\n>>> defined at \S+:\d+\n>>>.*))" + R"((\n>>> defined at \S+:\d+\n>>>.*))"); + std::string msgStr = msg.str(); + std::smatch match; + if (std::regex_match(msgStr, match, reDuplicateSymbol)) { + printErrorMsg(match.str(1) + match.str(2)); + printErrorMsg(match.str(1) + match.str(3)); + return; + } + } + printErrorMsg(msg); +} + void ErrorHandler::error(const Twine &msg) { std::lock_guard<std::mutex> lock(mu); if (errorLimit == 0 || errorCount < errorLimit) { - newline(errorOS, msg); - printHeader("error: ", raw_ostream::RED, msg); - *errorOS << msg << "\n"; + printError(msg); } else if (errorCount == errorLimit) { newline(errorOS, msg); printHeader("error: ", raw_ostream::RED, msg); |

