[binutils] NFC: fix clang-tidy warning: use empty() instead of size() == 0
llvm-svn: 349710
This commit is contained in:
parent
dff33c38e1
commit
16a0de2e55
|
@ -125,7 +125,7 @@ static void failIfError(std::error_code EC, Twine Context = "") {
|
|||
return;
|
||||
|
||||
std::string ContextStr = Context.str();
|
||||
if (ContextStr == "")
|
||||
if (ContextStr.empty())
|
||||
fail(EC.message());
|
||||
fail(Context + ": " + EC.message());
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ static void failIfError(Error E, Twine Context = "") {
|
|||
|
||||
handleAllErrors(std::move(E), [&](const llvm::ErrorInfoBase &EIB) {
|
||||
std::string ContextStr = Context.str();
|
||||
if (ContextStr == "")
|
||||
if (ContextStr.empty())
|
||||
fail(EIB.message());
|
||||
fail(Context + ": " + EIB.message());
|
||||
});
|
||||
|
@ -196,7 +196,7 @@ static std::vector<StringRef> Members;
|
|||
// Extract the member filename from the command line for the [relpos] argument
|
||||
// associated with a, b, and i modifiers
|
||||
static void getRelPos() {
|
||||
if (PositionalArgs.size() == 0)
|
||||
if (PositionalArgs.empty())
|
||||
fail("Expected [relpos] for a, b, or i modifier");
|
||||
RelPos = PositionalArgs[0];
|
||||
PositionalArgs.erase(PositionalArgs.begin());
|
||||
|
@ -204,7 +204,7 @@ static void getRelPos() {
|
|||
|
||||
// Get the archive file name from the command line
|
||||
static void getArchive() {
|
||||
if (PositionalArgs.size() == 0)
|
||||
if (PositionalArgs.empty())
|
||||
fail("An archive name must be specified");
|
||||
ArchiveName = PositionalArgs[0];
|
||||
PositionalArgs.erase(PositionalArgs.begin());
|
||||
|
@ -760,11 +760,11 @@ static void performWriteOperation(ArchiveOperation Operation,
|
|||
else if (OldArchive)
|
||||
Kind = OldArchive->kind();
|
||||
else if (NewMembersP)
|
||||
Kind = NewMembersP->size() ? getKindFromMember(NewMembersP->front())
|
||||
: getDefaultForHost();
|
||||
Kind = !NewMembersP->empty() ? getKindFromMember(NewMembersP->front())
|
||||
: getDefaultForHost();
|
||||
else
|
||||
Kind = NewMembers.size() ? getKindFromMember(NewMembers.front())
|
||||
: getDefaultForHost();
|
||||
Kind = !NewMembers.empty() ? getKindFromMember(NewMembers.front())
|
||||
: getDefaultForHost();
|
||||
break;
|
||||
case GNU:
|
||||
Kind = object::Archive::K_GNU;
|
||||
|
|
|
@ -691,7 +691,7 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {
|
|||
PathRemapping = EquivPair;
|
||||
|
||||
// If a demangler is supplied, check if it exists and register it.
|
||||
if (DemanglerOpts.size()) {
|
||||
if (!DemanglerOpts.empty()) {
|
||||
auto DemanglerPathOrErr = sys::findProgramByName(DemanglerOpts[0]);
|
||||
if (!DemanglerPathOrErr) {
|
||||
error("Could not find the demangler!",
|
||||
|
|
|
@ -31,7 +31,7 @@ void CoveragePrinter::StreamDestructor::operator()(raw_ostream *OS) const {
|
|||
std::string CoveragePrinter::getOutputPath(StringRef Path, StringRef Extension,
|
||||
bool InToplevel,
|
||||
bool Relative) const {
|
||||
assert(Extension.size() && "The file extension may not be empty");
|
||||
assert(!Extension.empty() && "The file extension may not be empty");
|
||||
|
||||
SmallString<256> FullPath;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ std::string escape(StringRef Str, const CoverageViewOptions &Opts) {
|
|||
std::string tag(const std::string &Name, const std::string &Str,
|
||||
const std::string &ClassName = "") {
|
||||
std::string Tag = "<" + Name;
|
||||
if (ClassName != "")
|
||||
if (!ClassName.empty())
|
||||
Tag += " class='" + ClassName + "'";
|
||||
return Tag + ">" + Str + "</" + Name + ">";
|
||||
}
|
||||
|
|
|
@ -677,7 +677,7 @@ static void darwinPrintStab(MachOObjectFile *MachO, SymbolListT::iterator I) {
|
|||
}
|
||||
|
||||
static Optional<std::string> demangle(StringRef Name, bool StripUnderscore) {
|
||||
if (StripUnderscore && Name.size() > 0 && Name[0] == '_')
|
||||
if (StripUnderscore && !Name.empty() && Name[0] == '_')
|
||||
Name = Name.substr(1);
|
||||
|
||||
if (!Name.startswith("_Z"))
|
||||
|
@ -1163,7 +1163,7 @@ dumpSymbolNamesFromObject(SymbolicFile &Obj, bool printName,
|
|||
// file get the section number for that section in this object file.
|
||||
unsigned int Nsect = 0;
|
||||
MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj);
|
||||
if (SegSect.size() != 0 && MachO) {
|
||||
if (!SegSect.empty() && MachO) {
|
||||
Nsect = getNsectForSegSect(MachO);
|
||||
// If this section is not in the object file no symbols are printed.
|
||||
if (Nsect == 0)
|
||||
|
@ -1800,7 +1800,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
|||
}
|
||||
if (MachOUniversalBinary *UB = dyn_cast<MachOUniversalBinary>(&Bin)) {
|
||||
// If we have a list of architecture flags specified dump only those.
|
||||
if (!ArchAll && ArchFlags.size() != 0) {
|
||||
if (!ArchAll && !ArchFlags.empty()) {
|
||||
// Look for a slice in the universal binary that matches each ArchFlag.
|
||||
bool ArchFound;
|
||||
for (unsigned i = 0; i < ArchFlags.size(); ++i) {
|
||||
|
@ -2071,7 +2071,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
if (SegSect.size() != 0 && SegSect.size() != 2)
|
||||
if (!SegSect.empty() && SegSect.size() != 2)
|
||||
error("bad number of arguments (must be two arguments)",
|
||||
"for the -s option");
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ static Error dumpSectionToFile(StringRef SecName, StringRef Filename,
|
|||
Object &Obj) {
|
||||
for (auto &Sec : Obj.sections()) {
|
||||
if (Sec.Name == SecName) {
|
||||
if (Sec.OriginalData.size() == 0)
|
||||
if (Sec.OriginalData.empty())
|
||||
return make_error<StringError>("Can't dump section \"" + SecName +
|
||||
"\": it has no contents",
|
||||
object_error::parse_failed);
|
||||
|
|
|
@ -1412,7 +1412,7 @@ static void DumpSectionContents(StringRef Filename, MachOObjectFile *O,
|
|||
std::pair<StringRef, StringRef> DumpSegSectName;
|
||||
DumpSegSectName = DumpSection.split(',');
|
||||
StringRef DumpSegName, DumpSectName;
|
||||
if (DumpSegSectName.second.size()) {
|
||||
if (!DumpSegSectName.second.empty()) {
|
||||
DumpSegName = DumpSegSectName.first;
|
||||
DumpSectName = DumpSegSectName.second;
|
||||
} else {
|
||||
|
@ -1582,7 +1582,7 @@ static void ProcessMachO(StringRef Name, MachOObjectFile *MachOOF,
|
|||
if (Disassemble || Relocations || PrivateHeaders || ExportsTrie || Rebase ||
|
||||
Bind || SymbolTable || LazyBind || WeakBind || IndirectSymbols ||
|
||||
DataInCode || LinkOptHints || DylibsUsed || DylibId || ObjcMetaData ||
|
||||
(FilterSections.size() != 0)) {
|
||||
(!FilterSections.empty())) {
|
||||
if (!NoLeadingHeaders) {
|
||||
outs() << Name;
|
||||
if (!ArchiveMemberName.empty())
|
||||
|
@ -1607,8 +1607,7 @@ static void ProcessMachO(StringRef Name, MachOObjectFile *MachOOF,
|
|||
// If we need the symbol table to do the operation then check it here to
|
||||
// produce a good error message as to where the Mach-O file comes from in
|
||||
// the error message.
|
||||
if (Disassemble || IndirectSymbols || FilterSections.size() != 0 ||
|
||||
UnwindInfo)
|
||||
if (Disassemble || IndirectSymbols || !FilterSections.empty() || UnwindInfo)
|
||||
if (Error Err = MachOOF->checkSymbolTable())
|
||||
report_error(ArchiveName, FileName, std::move(Err), ArchitectureName);
|
||||
|
||||
|
@ -1631,7 +1630,7 @@ static void ProcessMachO(StringRef Name, MachOObjectFile *MachOOF,
|
|||
PrintSectionHeaders(MachOOF);
|
||||
if (SectionContents)
|
||||
PrintSectionContents(MachOOF);
|
||||
if (FilterSections.size() != 0)
|
||||
if (!FilterSections.empty())
|
||||
DumpSectionContents(FileName, MachOOF, !NonVerbose);
|
||||
if (InfoPlist)
|
||||
DumpInfoPlistSectionContents(FileName, MachOOF);
|
||||
|
@ -2026,7 +2025,7 @@ void llvm::ParseInputMachO(MachOUniversalBinary *UB) {
|
|||
printMachOUniversalHeaders(UB, !NonVerbose);
|
||||
|
||||
// If we have a list of architecture flags specified dump only those.
|
||||
if (!ArchAll && ArchFlags.size() != 0) {
|
||||
if (!ArchAll && !ArchFlags.empty()) {
|
||||
// Look for a slice in the universal binary that matches each ArchFlag.
|
||||
bool ArchFound;
|
||||
for (unsigned i = 0; i < ArchFlags.size(); ++i) {
|
||||
|
@ -6831,7 +6830,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
|
|||
|
||||
// Package up features to be passed to target/subtarget
|
||||
std::string FeaturesStr;
|
||||
if (MAttrs.size()) {
|
||||
if (!MAttrs.empty()) {
|
||||
SubtargetFeatures Features;
|
||||
for (unsigned i = 0; i != MAttrs.size(); ++i)
|
||||
Features.AddFeature(MAttrs[i]);
|
||||
|
@ -6989,7 +6988,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
|
|||
diContext = DWARFContext::create(*DbgObj);
|
||||
}
|
||||
|
||||
if (FilterSections.size() == 0)
|
||||
if (FilterSections.empty())
|
||||
outs() << "(" << DisSegName << "," << DisSectName << ") section\n";
|
||||
|
||||
for (unsigned SectIdx = 0; SectIdx != Sections.size(); SectIdx++) {
|
||||
|
@ -7052,7 +7051,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
|
|||
unsigned int Arch = MachOOF->getArch();
|
||||
|
||||
// Skip all symbols if this is a stubs file.
|
||||
if (Bytes.size() == 0)
|
||||
if (Bytes.empty())
|
||||
return;
|
||||
|
||||
// If the section has symbols but no symbol at the start of the section
|
||||
|
|
|
@ -1306,7 +1306,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
|
|||
|
||||
// Package up features to be passed to target/subtarget
|
||||
SubtargetFeatures Features = Obj->getFeatures();
|
||||
if (MAttrs.size()) {
|
||||
if (!MAttrs.empty()) {
|
||||
for (unsigned i = 0; i != MAttrs.size(); ++i)
|
||||
Features.AddFeature(MAttrs[i]);
|
||||
}
|
||||
|
@ -2456,7 +2456,7 @@ int main(int argc, char **argv) {
|
|||
ToolName = argv[0];
|
||||
|
||||
// Defaults to a.out if no filenames specified.
|
||||
if (InputFilenames.size() == 0)
|
||||
if (InputFilenames.empty())
|
||||
InputFilenames.push_back("a.out");
|
||||
|
||||
if (AllHeaders)
|
||||
|
@ -2490,7 +2490,7 @@ int main(int argc, char **argv) {
|
|||
&& !(DylibsUsed && MachOOpt)
|
||||
&& !(DylibId && MachOOpt)
|
||||
&& !(ObjcMetaData && MachOOpt)
|
||||
&& !(FilterSections.size() != 0 && MachOOpt)
|
||||
&& !(!FilterSections.empty() && MachOOpt)
|
||||
&& !PrintFaultMaps
|
||||
&& DwarfDumpType == DIDT_Null) {
|
||||
cl::PrintHelpMessage();
|
||||
|
|
|
@ -578,7 +578,7 @@ template <class ELFT> void ELFDumper<ELFT>::LoadVersionMap() const {
|
|||
return;
|
||||
|
||||
// Has the VersionMap already been loaded?
|
||||
if (VersionMap.size() > 0)
|
||||
if (!VersionMap.empty())
|
||||
return;
|
||||
|
||||
// The first two version indexes are reserved.
|
||||
|
|
|
@ -681,7 +681,7 @@ int main(int argc, const char *argv[]) {
|
|||
}
|
||||
|
||||
// Default to stdin if no filename is specified.
|
||||
if (opts::InputFilenames.size() == 0)
|
||||
if (opts::InputFilenames.empty())
|
||||
opts::InputFilenames.push_back("-");
|
||||
|
||||
llvm::for_each(opts::InputFilenames, dumpInput);
|
||||
|
|
|
@ -578,7 +578,7 @@ static void printFileSectionSizes(StringRef file) {
|
|||
} else if (MachOUniversalBinary *UB =
|
||||
dyn_cast<MachOUniversalBinary>(&Bin)) {
|
||||
// If we have a list of architecture flags specified dump only those.
|
||||
if (!ArchAll && ArchFlags.size() != 0) {
|
||||
if (!ArchAll && !ArchFlags.empty()) {
|
||||
// Look for a slice in the universal binary that matches each ArchFlag.
|
||||
bool ArchFound;
|
||||
for (unsigned i = 0; i < ArchFlags.size(); ++i) {
|
||||
|
|
Loading…
Reference in New Issue