[lld] r367651 - Add an assert() to catch possible regexp errors.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 1 22:11:19 PDT 2019
Author: ruiu
Date: Thu Aug 1 22:11:19 2019
New Revision: 367651
URL: http://llvm.org/viewvc/llvm-project?rev=367651&view=rev
Log:
Add an assert() to catch possible regexp errors.
Modified:
lld/trunk/Common/ErrorHandler.cpp
Modified: lld/trunk/Common/ErrorHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/Common/ErrorHandler.cpp?rev=367651&r1=367650&r2=367651&view=diff
==============================================================================
--- lld/trunk/Common/ErrorHandler.cpp (original)
+++ lld/trunk/Common/ErrorHandler.cpp Thu Aug 1 22:11:19 2019
@@ -124,13 +124,14 @@ std::string ErrorHandler::getLocation(co
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;
More information about the llvm-commits
mailing list