[lld] r297353 - Print an error message instead of an assertion failure.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 8 17:28:50 PST 2017


Author: ruiu
Date: Wed Mar  8 19:28:50 2017
New Revision: 297353

URL: http://llvm.org/viewvc/llvm-project?rev=297353&view=rev
Log:
Print an error message instead of an assertion failure.

This assertion is failing on a Chromium builder and I cannot figure out why.
This patch let it print out more info.

Modified:
    lld/trunk/COFF/Librarian.cpp

Modified: lld/trunk/COFF/Librarian.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Librarian.cpp?rev=297353&r1=297352&r2=297353&view=diff
==============================================================================
--- lld/trunk/COFF/Librarian.cpp (original)
+++ lld/trunk/COFF/Librarian.cpp Wed Mar  8 19:28:50 2017
@@ -104,7 +104,10 @@ static ImportNameType getNameType(String
 
 static std::string replace(StringRef S, StringRef From, StringRef To) {
   size_t Pos = S.find(From);
-  assert(Pos != StringRef::npos);
+  if (Pos == StringRef::npos) {
+    error(S + ": replacing '" + From + "' with '" + To + "' failed");
+    return "";
+  }
   return (Twine(S.substr(0, Pos)) + To + S.substr(Pos + From.size())).str();
 }
 




More information about the llvm-commits mailing list