summaryrefslogtreecommitdiff
path: root/lld
diff options
context:
space:
mode:
authorJez Ng <jezng@fb.com>2023-04-05 01:48:34 -0400
committerJez Ng <jezng@fb.com>2023-04-05 07:50:28 -0400
commitc4d9df9f78f3109f6c3c7bafa6fc91162e8771b4 (patch)
tree431b968cf3b733c1dba01ad555a436216ea9aff9 /lld
parent981932bc57aeaa6d4dd02b011d848ed9fa4dd615 (diff)
downloadllvm-c4d9df9f78f3109f6c3c7bafa6fc91162e8771b4.tar.gz
[lld-macho][nfc] Clean up a bunch of clang-tidy issues
Diffstat (limited to 'lld')
-rw-r--r--lld/MachO/ICF.cpp8
-rw-r--r--lld/MachO/InputFiles.cpp13
-rw-r--r--lld/MachO/SymbolTable.cpp24
-rw-r--r--lld/MachO/SyntheticSections.cpp2
-rw-r--r--lld/MachO/UnwindInfoSection.cpp6
-rw-r--r--lld/MachO/Writer.cpp2
6 files changed, 29 insertions, 26 deletions
diff --git a/lld/MachO/ICF.cpp b/lld/MachO/ICF.cpp
index 3dfc46412e84..d5f3c19c6278 100644
--- a/lld/MachO/ICF.cpp
+++ b/lld/MachO/ICF.cpp
@@ -213,8 +213,10 @@ bool ICF::equalsVariable(const ConcatInputSection *ia,
// symbols at offset zero within the section (which is typically the case with
// .subsections_via_symbols.)
auto hasUnwind = [](Defined *d) { return d->unwindEntry != nullptr; };
- auto itA = std::find_if(ia->symbols.begin(), ia->symbols.end(), hasUnwind);
- auto itB = std::find_if(ib->symbols.begin(), ib->symbols.end(), hasUnwind);
+ const auto *itA =
+ std::find_if(ia->symbols.begin(), ia->symbols.end(), hasUnwind);
+ const auto *itB =
+ std::find_if(ib->symbols.begin(), ib->symbols.end(), hasUnwind);
if (itA == ia->symbols.end())
return itB == ib->symbols.end();
if (itB == ib->symbols.end())
@@ -290,7 +292,7 @@ void ICF::run() {
if (auto *sym = r.referent.dyn_cast<Symbol *>()) {
if (auto *defined = dyn_cast<Defined>(sym)) {
if (defined->isec) {
- if (auto referentIsec =
+ if (auto *referentIsec =
dyn_cast<ConcatInputSection>(defined->isec))
hash += defined->value + referentIsec->icfEqClass[icfPass % 2];
else
diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 6edb21ffe672..9f0c003d6aa2 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -89,7 +89,7 @@ std::string lld::toString(const InputFile *f) {
return "<internal>";
// Multiple dylibs can be defined in one .tbd file.
- if (auto dylibFile = dyn_cast<DylibFile>(f))
+ if (const auto *dylibFile = dyn_cast<DylibFile>(f))
if (f->getName().endswith(".tbd"))
return (f->getName() + "(" + dylibFile->installName + ")").str();
@@ -753,7 +753,7 @@ macho::Symbol *ObjFile::parseNonSectionSymbol(const NList &sym,
StringRef aliasedName = StringRef(strtab + sym.n_value);
// isPrivateExtern is the only symbol flag that has an impact on the final
// aliased symbol.
- auto alias = make<AliasSymbol>(this, name, aliasedName, isPrivateExtern);
+ auto *alias = make<AliasSymbol>(this, name, aliasedName, isPrivateExtern);
aliases.push_back(alias);
return alias;
}
@@ -1597,8 +1597,8 @@ static DylibFile *findDylib(StringRef path, DylibFile *umbrella,
make_pointee_range(currentTopLevelTapi->documents())) {
assert(child.documents().empty());
if (path == child.getInstallName()) {
- auto file = make<DylibFile>(child, umbrella, /*isBundleLoader=*/false,
- /*explicitlyLinked=*/false);
+ auto *file = make<DylibFile>(child, umbrella, /*isBundleLoader=*/false,
+ /*explicitlyLinked=*/false);
file->parseReexports(child);
return file;
}
@@ -1692,14 +1692,15 @@ DylibFile::DylibFile(MemoryBufferRef mb, DylibFile *umbrella,
error(toString(this) +
": dylib has both LC_DYLD_INFO_ONLY and LC_DYLD_EXPORTS_TRIE");
return;
- } else if (dyldInfo) {
+ }
+
+ if (dyldInfo) {
parseExportedSymbols(dyldInfo->export_off, dyldInfo->export_size);
} else if (exportsTrie) {
parseExportedSymbols(exportsTrie->dataoff, exportsTrie->datasize);
} else {
error("No LC_DYLD_INFO_ONLY or LC_DYLD_EXPORTS_TRIE found in " +
toString(this));
- return;
}
}
diff --git a/lld/MachO/SymbolTable.cpp b/lld/MachO/SymbolTable.cpp
index 09b3d8a376e6..78ac40bc52ce 100644
--- a/lld/MachO/SymbolTable.cpp
+++ b/lld/MachO/SymbolTable.cpp
@@ -459,8 +459,8 @@ static bool canSuggestExternCForCXX(StringRef ref, StringRef def) {
// the suggested symbol, which is either in the symbol table, or in the same
// file of sym.
static const Symbol *getAlternativeSpelling(const Undefined &sym,
- std::string &pre_hint,
- std::string &post_hint) {
+ std::string &preHint,
+ std::string &postHint) {
DenseMap<StringRef, const Symbol *> map;
if (sym.getFile() && sym.getFile()->kind() == InputFile::ObjKind) {
// Build a map of local defined symbols.
@@ -540,28 +540,28 @@ static const Symbol *getAlternativeSpelling(const Undefined &sym,
const Symbol *s = suggest((Twine("_") + buf).str());
free(buf);
if (s) {
- pre_hint = ": extern \"C\" ";
+ preHint = ": extern \"C\" ";
return s;
}
}
} else {
- StringRef name_without_underscore = name;
- name_without_underscore.consume_front("_");
+ StringRef nameWithoutUnderscore = name;
+ nameWithoutUnderscore.consume_front("_");
const Symbol *s = nullptr;
for (auto &it : map)
- if (canSuggestExternCForCXX(name_without_underscore, it.first)) {
+ if (canSuggestExternCForCXX(nameWithoutUnderscore, it.first)) {
s = it.second;
break;
}
if (!s)
for (Symbol *sym : symtab->getSymbols())
- if (canSuggestExternCForCXX(name_without_underscore, sym->getName())) {
+ if (canSuggestExternCForCXX(nameWithoutUnderscore, sym->getName())) {
s = sym;
break;
}
if (s) {
- pre_hint = " to declare ";
- post_hint = " as extern \"C\"?";
+ preHint = " to declare ";
+ postHint = " as extern \"C\"?";
return s;
}
}
@@ -605,11 +605,11 @@ static void reportUndefinedSymbol(const Undefined &sym,
.str();
if (correctSpelling) {
- std::string pre_hint = ": ", post_hint;
+ std::string preHint = ": ", postHint;
if (const Symbol *corrected =
- getAlternativeSpelling(sym, pre_hint, post_hint)) {
+ getAlternativeSpelling(sym, preHint, postHint)) {
message +=
- "\n>>> did you mean" + pre_hint + toString(*corrected) + post_hint;
+ "\n>>> did you mean" + preHint + toString(*corrected) + postHint;
if (corrected->getFile())
message += "\n>>> defined in: " + toString(corrected->getFile());
}
diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 72ec67ad1e30..75453a5b3ee5 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -1875,7 +1875,7 @@ void ObjCImageInfoSection::finalizeContents() {
info.hasCategoryClassProperties = true;
const InputFile *firstFile;
- for (auto file : files) {
+ for (const InputFile *file : files) {
ImageInfo inputInfo = parseImageInfo(file);
info.hasCategoryClassProperties &= inputInfo.hasCategoryClassProperties;
diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp
index 6820e177875c..2dbd8ed20272 100644
--- a/lld/MachO/UnwindInfoSection.cpp
+++ b/lld/MachO/UnwindInfoSection.cpp
@@ -559,10 +559,10 @@ void UnwindInfoSectionImpl::finalize() {
while (wordsRemaining >= 1 && i < cuIndices.size()) {
idx = cuIndices[i];
const CompactUnwindEntry *cuPtr = &cuEntries[idx];
- if (cuPtr->functionAddress >= functionAddressMax) {
+ if (cuPtr->functionAddress >= functionAddressMax)
break;
- } else if (commonEncodingIndexes.count(cuPtr->encoding) ||
- page.localEncodingIndexes.count(cuPtr->encoding)) {
+ if (commonEncodingIndexes.count(cuPtr->encoding) ||
+ page.localEncodingIndexes.count(cuPtr->encoding)) {
i++;
wordsRemaining--;
} else if (wordsRemaining >= 2 && n < COMPACT_ENCODINGS_MAX) {
diff --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp
index b090ca2a72b7..fe7cd39d2db8 100644
--- a/lld/MachO/Writer.cpp
+++ b/lld/MachO/Writer.cpp
@@ -1060,7 +1060,7 @@ void Writer::finalizeAddresses() {
if (!osec->isNeeded())
continue;
// Other kinds of OutputSections have already been finalized.
- if (auto concatOsec = dyn_cast<ConcatOutputSection>(osec))
+ if (auto *concatOsec = dyn_cast<ConcatOutputSection>(osec))
concatOsec->finalizeContents();
}
}