summaryrefslogtreecommitdiffstats
path: root/lld/Common/ErrorHandler.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2019-08-02 05:11:19 +0000
committerRui Ueyama <ruiu@google.com>2019-08-02 05:11:19 +0000
commitc1981b2b269da946aa38f665495edb693deb5e96 (patch)
treeac907ccdbb1db53b18669155df21bbda420dd9e1 /lld/Common/ErrorHandler.cpp
parent96a7a225f5f99b1145687dc678c08663bd3b9370 (diff)
downloadbcm5719-llvm-c1981b2b269da946aa38f665495edb693deb5e96.tar.gz
bcm5719-llvm-c1981b2b269da946aa38f665495edb693deb5e96.zip
Add an assert() to catch possible regexp errors.
llvm-svn: 367651
Diffstat (limited to 'lld/Common/ErrorHandler.cpp')
-rw-r--r--lld/Common/ErrorHandler.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/lld/Common/ErrorHandler.cpp b/lld/Common/ErrorHandler.cpp
index f22de2531f9..a012afcd694 100644
--- a/lld/Common/ErrorHandler.cpp
+++ b/lld/Common/ErrorHandler.cpp
@@ -124,13 +124,14 @@ std::string ErrorHandler::getLocation(const Twine &msg) {
std::string str = msg.str();
for (std::regex &re : regexes) {
- std::smatch match;
- if (!std::regex_search(str, match, re))
+ std::smatch m;
+ if (!std::regex_search(str, m, re))
continue;
+ assert(m.size() == 2 || m.size() == 3);
- if (match.size() > 2)
- return match.str(1) + "(" + match.str(2) + ")";
- return match.str(1);
+ if (m.size() == 2)
+ return m.str(1);
+ return m.str(1) + "(" + m.str(2) + ")";
}
return logName;
OpenPOWER on IntegriCloud