[PATCH] D26981: Limit maximum number of errors to 1000.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 22 10:53:28 PST 2016
ruiu updated this revision to Diff 78898.
ruiu added a comment.
- Updated as per comments.
https://reviews.llvm.org/D26981
Files:
ELF/Driver.cpp
ELF/Error.cpp
ELF/Error.h
Index: ELF/Error.h
===================================================================
--- ELF/Error.h
+++ ELF/Error.h
@@ -31,7 +31,12 @@
namespace lld {
namespace elf {
+// The maximum number of errors. If error() is called more than
+// this number, LLD bails out. 0 means no limit.
+const unsigned ErrorLimit = 1000;
+
extern bool HasError;
+extern unsigned ErrorCount;
extern llvm::raw_ostream *ErrorOS;
extern llvm::StringRef Argv0;
Index: ELF/Error.cpp
===================================================================
--- ELF/Error.cpp
+++ ELF/Error.cpp
@@ -24,6 +24,7 @@
namespace lld {
bool elf::HasError;
+unsigned elf::ErrorCount;
raw_ostream *elf::ErrorOS;
StringRef elf::Argv0;
@@ -40,8 +41,15 @@
}
void elf::error(const Twine &Msg) {
- *ErrorOS << Argv0 << ": error: " << Msg << "\n";
+ if (ErrorLimit == 0 || ErrorCount < ErrorLimit) {
+ *ErrorOS << Argv0 << ": error: " << Msg << "\n";
+ } else if (Config->ExitEarly) {
+ *ErrorOS << Argv0 << ": error: too many errors emitted, stopping now\n";
+ exitLld(1);
+ }
+
HasError = true;
+ ErrorCount++;
}
void elf::error(std::error_code EC, const Twine &Prefix) {
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -43,6 +43,7 @@
bool elf::link(ArrayRef<const char *> Args, bool CanExitEarly,
raw_ostream &Error) {
HasError = false;
+ ErrorCount = 0;
ErrorOS = &Error;
Argv0 = Args[0];
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26981.78898.patch
Type: text/x-patch
Size: 1500 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161122/38c502ca/attachment.bin>
More information about the llvm-commits
mailing list