[lld] r287849 - Remove HasError and use ErrorCount instead.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 23 17:43:22 PST 2016
Author: ruiu
Date: Wed Nov 23 19:43:21 2016
New Revision: 287849
URL: http://llvm.org/viewvc/llvm-project?rev=287849&view=rev
Log:
Remove HasError and use ErrorCount instead.
HasError was always true if ErrorCount > 0, so we can use ErrorCount instead.
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Error.cpp
lld/trunk/ELF/Error.h
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/Relocations.cpp
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=287849&r1=287848&r2=287849&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Wed Nov 23 19:43:21 2016
@@ -42,7 +42,6 @@ LinkerDriver *elf::Driver;
bool elf::link(ArrayRef<const char *> Args, bool CanExitEarly,
raw_ostream &Error) {
- HasError = false;
ErrorCount = 0;
ErrorOS = &Error;
Argv0 = Args[0];
@@ -56,7 +55,7 @@ bool elf::link(ArrayRef<const char *> Ar
Driver->main(Args, CanExitEarly);
freeArena();
- return !HasError;
+ return !ErrorCount;
}
// Parses a linker -m option.
@@ -321,7 +320,7 @@ void LinkerDriver::main(ArrayRef<const c
createFiles(Args);
inferMachineType();
checkOptions(Args);
- if (HasError)
+ if (ErrorCount)
return;
switch (Config->EKind) {
@@ -670,7 +669,7 @@ void LinkerDriver::createFiles(opt::Inpu
}
}
- if (Files.empty() && !HasError)
+ if (Files.empty() && ErrorCount == 0)
error("no input files");
}
@@ -767,7 +766,7 @@ template <class ELFT> void LinkerDriver:
if (Symtab.find(Config->Entry))
Symtab.addUndefined(Config->Entry);
- if (HasError)
+ if (ErrorCount)
return; // There were duplicate symbols or incompatible files
Symtab.scanUndefinedFlags();
@@ -776,7 +775,7 @@ template <class ELFT> void LinkerDriver:
Symtab.scanVersionScript();
Symtab.addCombinedLtoObject();
- if (HasError)
+ if (ErrorCount)
return;
for (auto *Arg : Args.filtered(OPT_wrap))
Modified: lld/trunk/ELF/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.cpp?rev=287849&r1=287848&r2=287849&view=diff
==============================================================================
--- lld/trunk/ELF/Error.cpp (original)
+++ lld/trunk/ELF/Error.cpp Wed Nov 23 19:43:21 2016
@@ -24,7 +24,6 @@ using namespace llvm;
namespace lld {
-bool elf::HasError;
uint64_t elf::ErrorCount;
raw_ostream *elf::ErrorOS;
StringRef elf::Argv0;
@@ -59,7 +58,6 @@ void elf::error(const Twine &Msg) {
exitLld(1);
}
- HasError = true;
++ErrorCount;
}
Modified: lld/trunk/ELF/Error.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.h?rev=287849&r1=287848&r2=287849&view=diff
==============================================================================
--- lld/trunk/ELF/Error.h (original)
+++ lld/trunk/ELF/Error.h Wed Nov 23 19:43:21 2016
@@ -12,7 +12,7 @@
// Fatal makes the program exit immediately with an error message.
// You shouldn't use it except for reporting a corrupted input file.
//
-// Error prints out an error message and set a global variable HasError
+// Error prints out an error message and set a global variable ErrorCount
// to true to record the fact that we met an error condition. It does
// not exit, so it is safe for a lld-as-a-library use case. It is generally
// useful because it can report more than one errors in a single run.
@@ -31,7 +31,6 @@
namespace lld {
namespace elf {
-extern bool HasError;
extern uint64_t ErrorCount;
extern llvm::raw_ostream *ErrorOS;
extern llvm::StringRef Argv0;
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=287849&r1=287848&r2=287849&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Wed Nov 23 19:43:21 2016
@@ -1315,7 +1315,7 @@ InputSectionDescription *
ScriptParser::readInputSectionRules(StringRef FilePattern) {
auto *Cmd = new InputSectionDescription(FilePattern);
expect("(");
- while (!HasError && !consume(")")) {
+ while (!Error && !consume(")")) {
SortSectionPolicy Outer = readSortKind();
SortSectionPolicy Inner = SortSectionPolicy::Default;
std::vector<SectionPattern> V;
Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=287849&r1=287848&r2=287849&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Wed Nov 23 19:43:21 2016
@@ -649,7 +649,7 @@ static void scanRelocs(InputSectionBase<
bool Preemptible = isPreemptible(Body, Type);
Expr = adjustExpr(*File, Body, IsWrite, Expr, Type, Buf + RI.r_offset, C,
RI.r_offset);
- if (HasError)
+ if (ErrorCount)
continue;
// Skip a relocation that points to a dead piece
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=287849&r1=287848&r2=287849&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Wed Nov 23 19:43:21 2016
@@ -80,7 +80,7 @@ template <class ELFT> void SymbolTable<E
if (auto *F = dyn_cast<SharedFile<ELFT>>(File)) {
// DSOs are uniquified not by filename but by soname.
F->parseSoName();
- if (HasError || !SoNames.insert(F->getSoName()).second)
+ if (ErrorCount || !SoNames.insert(F->getSoName()).second)
return;
SharedFiles.push_back(F);
F->parseRest();
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=287849&r1=287848&r2=287849&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Nov 23 19:43:21 2016
@@ -174,7 +174,7 @@ template <class ELFT> void Writer<ELFT>:
// to the string table, and add entries to .got and .plt.
// finalizeSections does that.
finalizeSections();
- if (HasError)
+ if (ErrorCount)
return;
if (Config->Relocatable) {
@@ -201,7 +201,7 @@ template <class ELFT> void Writer<ELFT>:
// Write the result down to a file.
openFile();
- if (HasError)
+ if (ErrorCount)
return;
if (!Config->OFormatBinary) {
writeHeader();
@@ -213,7 +213,7 @@ template <class ELFT> void Writer<ELFT>:
// Backfill .note.gnu.build-id section content. This is done at last
// because the content is usually a hash value of the entire output file.
writeBuildId();
- if (HasError)
+ if (ErrorCount)
return;
if (auto EC = Buffer->commit())
@@ -924,7 +924,7 @@ template <class ELFT> void Writer<ELFT>:
}
// Do not proceed if there was an undefined symbol.
- if (HasError)
+ if (ErrorCount)
return;
// So far we have added sections from input object files.
More information about the llvm-commits
mailing list