mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-31 10:34:17 +00:00
Cleanup else-after-return and add an early-return to llvm-nm
The loop and error handling in checkMachOAndArchFlags didn't make sense to me (a loop that only ever executes once? An error path that uses the element the loop stopped at (which must always be a buffer overrun if I'm reading that right?)... I'm confused) but I've made a guess at what was intended. Based on a patch by Richard Thomson to simplify boolean expressions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233025 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c9ad3ab624
commit
dce96380c1
@ -188,85 +188,77 @@ static bool compareSymbolAddress(const NMSymbol &A, const NMSymbol &B) {
|
|||||||
if (!ReverseSort) {
|
if (!ReverseSort) {
|
||||||
if (A.Address < B.Address)
|
if (A.Address < B.Address)
|
||||||
return true;
|
return true;
|
||||||
else if (A.Address == B.Address && A.Name < B.Name)
|
if (A.Address == B.Address && A.Name < B.Name)
|
||||||
return true;
|
return true;
|
||||||
else if (A.Address == B.Address && A.Name == B.Name && A.Size < B.Size)
|
if (A.Address == B.Address && A.Name == B.Name && A.Size < B.Size)
|
||||||
return true;
|
return true;
|
||||||
else
|
return false;
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (A.Address > B.Address)
|
|
||||||
return true;
|
|
||||||
else if (A.Address == B.Address && A.Name > B.Name)
|
|
||||||
return true;
|
|
||||||
else if (A.Address == B.Address && A.Name == B.Name && A.Size > B.Size)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (A.Address > B.Address)
|
||||||
|
return true;
|
||||||
|
if (A.Address == B.Address && A.Name > B.Name)
|
||||||
|
return true;
|
||||||
|
if (A.Address == B.Address && A.Name == B.Name && A.Size > B.Size)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool compareSymbolSize(const NMSymbol &A, const NMSymbol &B) {
|
static bool compareSymbolSize(const NMSymbol &A, const NMSymbol &B) {
|
||||||
if (!ReverseSort) {
|
if (!ReverseSort) {
|
||||||
if (A.Size < B.Size)
|
if (A.Size < B.Size)
|
||||||
return true;
|
return true;
|
||||||
else if (A.Size == B.Size && A.Name < B.Name)
|
if (A.Size == B.Size && A.Name < B.Name)
|
||||||
return true;
|
return true;
|
||||||
else if (A.Size == B.Size && A.Name == B.Name && A.Address < B.Address)
|
if (A.Size == B.Size && A.Name == B.Name && A.Address < B.Address)
|
||||||
return true;
|
return true;
|
||||||
else
|
return false;
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (A.Size > B.Size)
|
|
||||||
return true;
|
|
||||||
else if (A.Size == B.Size && A.Name > B.Name)
|
|
||||||
return true;
|
|
||||||
else if (A.Size == B.Size && A.Name == B.Name && A.Address > B.Address)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (A.Size > B.Size)
|
||||||
|
return true;
|
||||||
|
if (A.Size == B.Size && A.Name > B.Name)
|
||||||
|
return true;
|
||||||
|
if (A.Size == B.Size && A.Name == B.Name && A.Address > B.Address)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool compareSymbolName(const NMSymbol &A, const NMSymbol &B) {
|
static bool compareSymbolName(const NMSymbol &A, const NMSymbol &B) {
|
||||||
if (!ReverseSort) {
|
if (!ReverseSort) {
|
||||||
if (A.Name < B.Name)
|
if (A.Name < B.Name)
|
||||||
return true;
|
return true;
|
||||||
else if (A.Name == B.Name && A.Size < B.Size)
|
if (A.Name == B.Name && A.Size < B.Size)
|
||||||
return true;
|
return true;
|
||||||
else if (A.Name == B.Name && A.Size == B.Size && A.Address < B.Address)
|
if (A.Name == B.Name && A.Size == B.Size && A.Address < B.Address)
|
||||||
return true;
|
return true;
|
||||||
else
|
return false;
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (A.Name > B.Name)
|
|
||||||
return true;
|
|
||||||
else if (A.Name == B.Name && A.Size > B.Size)
|
|
||||||
return true;
|
|
||||||
else if (A.Name == B.Name && A.Size == B.Size && A.Address > B.Address)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
if (A.Name > B.Name)
|
||||||
|
return true;
|
||||||
|
if (A.Name == B.Name && A.Size > B.Size)
|
||||||
|
return true;
|
||||||
|
if (A.Name == B.Name && A.Size == B.Size && A.Address > B.Address)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char isSymbolList64Bit(SymbolicFile &Obj) {
|
static char isSymbolList64Bit(SymbolicFile &Obj) {
|
||||||
if (isa<IRObjectFile>(Obj))
|
if (isa<IRObjectFile>(Obj))
|
||||||
return false;
|
return false;
|
||||||
else if (isa<COFFObjectFile>(Obj))
|
if (isa<COFFObjectFile>(Obj))
|
||||||
return false;
|
return false;
|
||||||
else if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj))
|
if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj))
|
||||||
return MachO->is64Bit();
|
return MachO->is64Bit();
|
||||||
else if (isa<ELF32LEObjectFile>(Obj))
|
if (isa<ELF32LEObjectFile>(Obj))
|
||||||
return false;
|
return false;
|
||||||
else if (isa<ELF64LEObjectFile>(Obj))
|
if (isa<ELF64LEObjectFile>(Obj))
|
||||||
return true;
|
return true;
|
||||||
else if (isa<ELF32BEObjectFile>(Obj))
|
if (isa<ELF32BEObjectFile>(Obj))
|
||||||
return false;
|
return false;
|
||||||
else if (isa<ELF64BEObjectFile>(Obj))
|
if (isa<ELF64BEObjectFile>(Obj))
|
||||||
return true;
|
return true;
|
||||||
else
|
return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static StringRef CurrentFilename;
|
static StringRef CurrentFilename;
|
||||||
@ -973,30 +965,26 @@ static void dumpSymbolNamesFromObject(SymbolicFile &Obj, bool printName,
|
|||||||
// architectures was specificed. If not then an error is generated and this
|
// architectures was specificed. If not then an error is generated and this
|
||||||
// routine returns false. Else it returns true.
|
// routine returns false. Else it returns true.
|
||||||
static bool checkMachOAndArchFlags(SymbolicFile *O, std::string &Filename) {
|
static bool checkMachOAndArchFlags(SymbolicFile *O, std::string &Filename) {
|
||||||
if (isa<MachOObjectFile>(O) && !ArchAll && ArchFlags.size() != 0) {
|
MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(O);
|
||||||
MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(O);
|
|
||||||
bool ArchFound = false;
|
if (!MachO || ArchAll || ArchFlags.size() == 0)
|
||||||
MachO::mach_header H;
|
return true;
|
||||||
MachO::mach_header_64 H_64;
|
|
||||||
Triple T;
|
MachO::mach_header H;
|
||||||
if (MachO->is64Bit()) {
|
MachO::mach_header_64 H_64;
|
||||||
H_64 = MachO->MachOObjectFile::getHeader64();
|
Triple T;
|
||||||
T = MachOObjectFile::getArch(H_64.cputype, H_64.cpusubtype);
|
if (MachO->is64Bit()) {
|
||||||
} else {
|
H_64 = MachO->MachOObjectFile::getHeader64();
|
||||||
H = MachO->MachOObjectFile::getHeader();
|
T = MachOObjectFile::getArch(H_64.cputype, H_64.cpusubtype);
|
||||||
T = MachOObjectFile::getArch(H.cputype, H.cpusubtype);
|
} else {
|
||||||
}
|
H = MachO->MachOObjectFile::getHeader();
|
||||||
unsigned i;
|
T = MachOObjectFile::getArch(H.cputype, H.cpusubtype);
|
||||||
for (i = 0; i < ArchFlags.size(); ++i) {
|
}
|
||||||
if (ArchFlags[i] == T.getArchName())
|
if (std::none_of(
|
||||||
ArchFound = true;
|
ArchFlags.begin(), ArchFlags.end(),
|
||||||
break;
|
[&](const std::string &Name) { return Name == T.getArchName(); })) {
|
||||||
}
|
error("No architecture specified", Filename);
|
||||||
if (!ArchFound) {
|
return false;
|
||||||
error(ArchFlags[i],
|
|
||||||
"file: " + Filename + " does not contain architecture");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user