diff --git a/lld/MachO/ConcatOutputSection.cpp b/lld/MachO/ConcatOutputSection.cpp --- a/lld/MachO/ConcatOutputSection.cpp +++ b/lld/MachO/ConcatOutputSection.cpp @@ -353,7 +353,7 @@ size_t i = 0, ie = inputs.size(); size_t t = 0, te = thunks.size(); while (i < ie || t < te) { - while (i < ie && (t == te || inputs[i]->getSize() == 0 || + while (i < ie && (t == te || inputs[i]->empty() || inputs[i]->outSecOff < thunks[t]->outSecOff)) { inputs[i]->writeTo(buf + inputs[i]->outSecOff); ++i; diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -174,7 +174,7 @@ for (const Arg *arg : args.filtered(OPT_syslibroot)) roots.push_back(arg->getValue()); // NOTE: the final `-syslibroot` being `/` will ignore all roots - if (roots.size() && roots.back() == "/") + if (!roots.empty() && roots.back() == "/") roots.clear(); // NOTE: roots can never be empty - add an empty root to simplify the library // and framework search path computation. @@ -206,7 +206,9 @@ args.filtered(OPT_thinlto_cache_policy, OPT_prune_interval_lto, OPT_prune_after_lto, OPT_max_relative_cache_size_lto)) { switch (arg->getOption().getID()) { - case OPT_thinlto_cache_policy: add(arg->getValue()); break; + case OPT_thinlto_cache_policy: + add(arg->getValue()); + break; case OPT_prune_interval_lto: if (!strcmp("-1", arg->getValue())) add("prune_interval=87600h"); // 10 years diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp --- a/lld/MachO/InputFiles.cpp +++ b/lld/MachO/InputFiles.cpp @@ -269,7 +269,7 @@ auto splitRecords = [&](int recordSize) -> void { subsections.push_back({}); - if (data.size() == 0) + if (data.empty()) return; SubsectionMap &subsecMap = subsections.back(); @@ -619,8 +619,7 @@ } } -template -static bool isUndef(const NList &sym) { +template static bool isUndef(const NList &sym) { return (sym.n_type & N_TYPE) == N_UNDF && sym.n_value == 0; } @@ -1211,7 +1210,7 @@ void DylibFile::parseReexports(const InterfaceFile &interface) { const InterfaceFile *topLevel = interface.getParent() == nullptr ? &interface : interface.getParent(); - for (InterfaceFileRef intfRef : interface.reexportedLibraries()) { + for (const InterfaceFileRef &intfRef : interface.reexportedLibraries()) { InterfaceFile::const_target_range targets = intfRef.targets(); if (is_contained(skipPlatformChecks, intfRef.getInstallName()) || is_contained(targets, config->platformInfo.target)) diff --git a/lld/MachO/InputSection.h b/lld/MachO/InputSection.h --- a/lld/MachO/InputSection.h +++ b/lld/MachO/InputSection.h @@ -38,6 +38,7 @@ Kind kind() const { return shared->sectionKind; } virtual ~InputSection() = default; virtual uint64_t getSize() const { return data.size(); } + virtual bool empty() const { return data.empty(); } InputFile *getFile() const { return shared->file; } StringRef getName() const { return shared->name; } StringRef getSegName() const { return shared->segname; } @@ -115,7 +116,7 @@ // ConcatInputSections are entirely live or dead, so the offset is irrelevant. bool isLive(uint64_t off) const override { return live; } void markLive(uint64_t off) override { live = true; } - bool isCoalescedWeak() const { return wasCoalesced && symbols.size() == 0; } + bool isCoalescedWeak() const { return wasCoalesced && symbols.empty(); } bool shouldOmitFromOutput() const { return !live || isCoalescedWeak(); } bool isHashableForICF() const; void hashForICF(); diff --git a/lld/MachO/InputSection.cpp b/lld/MachO/InputSection.cpp --- a/lld/MachO/InputSection.cpp +++ b/lld/MachO/InputSection.cpp @@ -110,7 +110,7 @@ copy->symbols.clear(); // Remove duplicate compact unwind info for symbols at the same address. - if (symbols.size() == 0) + if (symbols.empty()) return; it = symbols.begin(); uint64_t v = (*it)->value; diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp --- a/lld/MachO/UnwindInfoSection.cpp +++ b/lld/MachO/UnwindInfoSection.cpp @@ -602,7 +602,7 @@ *ep++ = (it->second << COMPRESSED_ENTRY_FUNC_OFFSET_BITS) | (cuep->functionAddress - functionAddressBase); } - if (page.localEncodings.size() != 0) + if (!page.localEncodings.empty()) memcpy(ep, page.localEncodings.data(), page.localEncodings.size() * sizeof(uint32_t)); } else {