llvm.org GIT mirror llvm / f6ea129
[binutils] NFC: fix clang-tidy warning: use empty() instead of size() == 0 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349710 91177308-0d34-0410-b5e6-96231b3b80d8 Jordan Rupprecht 8 months ago
11 changed file(s) with 30 addition(s) and 31 deletion(s). Raw diff Collapse all Expand all
124124 return;
125125
126126 std::string ContextStr = Context.str();
127 if (ContextStr == "")
127 if (ContextStr.empty())
128128 fail(EC.message());
129129 fail(Context + ": " + EC.message());
130130 }
135135
136136 handleAllErrors(std::move(E), [&](const llvm::ErrorInfoBase &EIB) {
137137 std::string ContextStr = Context.str();
138 if (ContextStr == "")
138 if (ContextStr.empty())
139139 fail(EIB.message());
140140 fail(Context + ": " + EIB.message());
141141 });
195195 // Extract the member filename from the command line for the [relpos] argument
196196 // associated with a, b, and i modifiers
197197 static void getRelPos() {
198 if (PositionalArgs.size() == 0)
198 if (PositionalArgs.empty())
199199 fail("Expected [relpos] for a, b, or i modifier");
200200 RelPos = PositionalArgs[0];
201201 PositionalArgs.erase(PositionalArgs.begin());
203203
204204 // Get the archive file name from the command line
205205 static void getArchive() {
206 if (PositionalArgs.size() == 0)
206 if (PositionalArgs.empty())
207207 fail("An archive name must be specified");
208208 ArchiveName = PositionalArgs[0];
209209 PositionalArgs.erase(PositionalArgs.begin());
759759 else if (OldArchive)
760760 Kind = OldArchive->kind();
761761 else if (NewMembersP)
762 Kind = NewMembersP->size() ? getKindFromMember(NewMembersP->front())
762 Kind = !NewMembersP->empty() ? getKindFromMember(NewMembersP->front())
763 : getDefaultForHost();
764 else
765 Kind = !NewMembers.empty() ? getKindFromMember(NewMembers.front())
763766 : getDefaultForHost();
764 else
765 Kind = NewMembers.size() ? getKindFromMember(NewMembers.front())
766 : getDefaultForHost();
767767 break;
768768 case GNU:
769769 Kind = object::Archive::K_GNU;
690690 PathRemapping = EquivPair;
691691
692692 // If a demangler is supplied, check if it exists and register it.
693 if (DemanglerOpts.size()) {
693 if (!DemanglerOpts.empty()) {
694694 auto DemanglerPathOrErr = sys::findProgramByName(DemanglerOpts[0]);
695695 if (!DemanglerPathOrErr) {
696696 error("Could not find the demangler!",
3030 std::string CoveragePrinter::getOutputPath(StringRef Path, StringRef Extension,
3131 bool InToplevel,
3232 bool Relative) const {
33 assert(Extension.size() && "The file extension may not be empty");
33 assert(!Extension.empty() && "The file extension may not be empty");
3434
3535 SmallString<256> FullPath;
3636
5353 std::string tag(const std::string &Name, const std::string &Str,
5454 const std::string &ClassName = "") {
5555 std::string Tag = "<" + Name;
56 if (ClassName != "")
56 if (!ClassName.empty())
5757 Tag += " class='" + ClassName + "'";
5858 return Tag + ">" + Str + "";
5959 }
676676 }
677677
678678 static Optional demangle(StringRef Name, bool StripUnderscore) {
679 if (StripUnderscore && Name.size() > 0 && Name[0] == '_')
679 if (StripUnderscore && !Name.empty() && Name[0] == '_')
680680 Name = Name.substr(1);
681681
682682 if (!Name.startswith("_Z"))
11621162 // file get the section number for that section in this object file.
11631163 unsigned int Nsect = 0;
11641164 MachOObjectFile *MachO = dyn_cast(&Obj);
1165 if (SegSect.size() != 0 && MachO) {
1165 if (!SegSect.empty() && MachO) {
11661166 Nsect = getNsectForSegSect(MachO);
11671167 // If this section is not in the object file no symbols are printed.
11681168 if (Nsect == 0)
17991799 }
18001800 if (MachOUniversalBinary *UB = dyn_cast(&Bin)) {
18011801 // If we have a list of architecture flags specified dump only those.
1802 if (!ArchAll && ArchFlags.size() != 0) {
1802 if (!ArchAll && !ArchFlags.empty()) {
18031803 // Look for a slice in the universal binary that matches each ArchFlag.
18041804 bool ArchFound;
18051805 for (unsigned i = 0; i < ArchFlags.size(); ++i) {
20702070 }
20712071 }
20722072
2073 if (SegSect.size() != 0 && SegSect.size() != 2)
2073 if (!SegSect.empty() && SegSect.size() != 2)
20742074 error("bad number of arguments (must be two arguments)",
20752075 "for the -s option");
20762076
182182 Object &Obj) {
183183 for (auto &Sec : Obj.sections()) {
184184 if (Sec.Name == SecName) {
185 if (Sec.OriginalData.size() == 0)
185 if (Sec.OriginalData.empty())
186186 return make_error("Can't dump section \"" + SecName +
187187 "\": it has no contents",
188188 object_error::parse_failed);
14111411 std::pair DumpSegSectName;
14121412 DumpSegSectName = DumpSection.split(',');
14131413 StringRef DumpSegName, DumpSectName;
1414 if (DumpSegSectName.second.size()) {
1414 if (!DumpSegSectName.second.empty()) {
14151415 DumpSegName = DumpSegSectName.first;
14161416 DumpSectName = DumpSegSectName.second;
14171417 } else {
15811581 if (Disassemble || Relocations || PrivateHeaders || ExportsTrie || Rebase ||
15821582 Bind || SymbolTable || LazyBind || WeakBind || IndirectSymbols ||
15831583 DataInCode || LinkOptHints || DylibsUsed || DylibId || ObjcMetaData ||
1584 (FilterSections.size() != 0)) {
1584 (!FilterSections.empty())) {
15851585 if (!NoLeadingHeaders) {
15861586 outs() << Name;
15871587 if (!ArchiveMemberName.empty())
16061606 // If we need the symbol table to do the operation then check it here to
16071607 // produce a good error message as to where the Mach-O file comes from in
16081608 // the error message.
1609 if (Disassemble || IndirectSymbols || FilterSections.size() != 0 ||
1610 UnwindInfo)
1609 if (Disassemble || IndirectSymbols || !FilterSections.empty() || UnwindInfo)
16111610 if (Error Err = MachOOF->checkSymbolTable())
16121611 report_error(ArchiveName, FileName, std::move(Err), ArchitectureName);
16131612
16301629 PrintSectionHeaders(MachOOF);
16311630 if (SectionContents)
16321631 PrintSectionContents(MachOOF);
1633 if (FilterSections.size() != 0)
1632 if (!FilterSections.empty())
16341633 DumpSectionContents(FileName, MachOOF, !NonVerbose);
16351634 if (InfoPlist)
16361635 DumpInfoPlistSectionContents(FileName, MachOOF);
20252024 printMachOUniversalHeaders(UB, !NonVerbose);
20262025
20272026 // If we have a list of architecture flags specified dump only those.
2028 if (!ArchAll && ArchFlags.size() != 0) {
2027 if (!ArchAll && !ArchFlags.empty()) {
20292028 // Look for a slice in the universal binary that matches each ArchFlag.
20302029 bool ArchFound;
20312030 for (unsigned i = 0; i < ArchFlags.size(); ++i) {
68306829
68316830 // Package up features to be passed to target/subtarget
68326831 std::string FeaturesStr;
6833 if (MAttrs.size()) {
6832 if (!MAttrs.empty()) {
68346833 SubtargetFeatures Features;
68356834 for (unsigned i = 0; i != MAttrs.size(); ++i)
68366835 Features.AddFeature(MAttrs[i]);
69886987 diContext = DWARFContext::create(*DbgObj);
69896988 }
69906989
6991 if (FilterSections.size() == 0)
6990 if (FilterSections.empty())
69926991 outs() << "(" << DisSegName << "," << DisSectName << ") section\n";
69936992
69946993 for (unsigned SectIdx = 0; SectIdx != Sections.size(); SectIdx++) {
70517050 unsigned int Arch = MachOOF->getArch();
70527051
70537052 // Skip all symbols if this is a stubs file.
7054 if (Bytes.size() == 0)
7053 if (Bytes.empty())
70557054 return;
70567055
70577056 // If the section has symbols but no symbol at the start of the section
13051305
13061306 // Package up features to be passed to target/subtarget
13071307 SubtargetFeatures Features = Obj->getFeatures();
1308 if (MAttrs.size()) {
1308 if (!MAttrs.empty()) {
13091309 for (unsigned i = 0; i != MAttrs.size(); ++i)
13101310 Features.AddFeature(MAttrs[i]);
13111311 }
24552455 ToolName = argv[0];
24562456
24572457 // Defaults to a.out if no filenames specified.
2458 if (InputFilenames.size() == 0)
2458 if (InputFilenames.empty())
24592459 InputFilenames.push_back("a.out");
24602460
24612461 if (AllHeaders)
24892489 && !(DylibsUsed && MachOOpt)
24902490 && !(DylibId && MachOOpt)
24912491 && !(ObjcMetaData && MachOOpt)
2492 && !(FilterSections.size() != 0 && MachOOpt)
2492 && !(!FilterSections.empty() && MachOOpt)
24932493 && !PrintFaultMaps
24942494 && DwarfDumpType == DIDT_Null) {
24952495 cl::PrintHelpMessage();
577577 return;
578578
579579 // Has the VersionMap already been loaded?
580 if (VersionMap.size() > 0)
580 if (!VersionMap.empty())
581581 return;
582582
583583 // The first two version indexes are reserved.
680680 }
681681
682682 // Default to stdin if no filename is specified.
683 if (opts::InputFilenames.size() == 0)
683 if (opts::InputFilenames.empty())
684684 opts::InputFilenames.push_back("-");
685685
686686 llvm::for_each(opts::InputFilenames, dumpInput);
577577 } else if (MachOUniversalBinary *UB =
578578 dyn_cast(&Bin)) {
579579 // If we have a list of architecture flags specified dump only those.
580 if (!ArchAll && ArchFlags.size() != 0) {
580 if (!ArchAll && !ArchFlags.empty()) {
581581 // Look for a slice in the universal binary that matches each ArchFlag.
582582 bool ArchFound;
583583 for (unsigned i = 0; i < ArchFlags.size(); ++i) {