[lld] r315426 - Use more precise type.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 10 21:01:13 PDT 2017
Author: ruiu
Date: Tue Oct 10 21:01:13 2017
New Revision: 315426
URL: http://llvm.org/viewvc/llvm-project?rev=315426&view=rev
Log:
Use more precise type.
Modified:
lld/trunk/ELF/InputFiles.cpp
lld/trunk/ELF/InputSection.h
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/LinkerScript.h
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=315426&r1=315425&r2=315426&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Tue Oct 10 21:01:13 2017
@@ -344,7 +344,7 @@ void ObjFile<ELFT>::initializeSections(
fatal(toString(this) + ": invalid sh_link index: " +
Twine(Sec.sh_link));
this->Sections[Sec.sh_link]->DependentSections.push_back(
- this->Sections[I]);
+ cast<InputSection>(this->Sections[I]));
}
}
}
Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=315426&r1=315425&r2=315426&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Tue Oct 10 21:01:13 2017
@@ -169,7 +169,7 @@ public:
InputSectionBase *Repl;
// InputSections that are dependent on us (reverse dependency for GC)
- llvm::TinyPtrVector<InputSectionBase *> DependentSections;
+ llvm::TinyPtrVector<InputSection *> DependentSections;
// Returns the size of this section (even if this is a common or BSS.)
size_t getSize() const;
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=315426&r1=315425&r2=315426&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Tue Oct 10 21:01:13 2017
@@ -219,13 +219,13 @@ getComparator(SortSectionPolicy K) {
}
// A helper function for the SORT() command.
-static bool matchConstraints(ArrayRef<InputSectionBase *> Sections,
+static bool matchConstraints(ArrayRef<InputSection *> Sections,
ConstraintKind Kind) {
if (Kind == ConstraintKind::NoConstraint)
return true;
bool IsRW = llvm::any_of(
- Sections, [](InputSectionBase *Sec) { return Sec->Flags & SHF_WRITE; });
+ Sections, [](InputSection *Sec) { return Sec->Flags & SHF_WRITE; });
return (IsRW && Kind == ConstraintKind::ReadWrite) ||
(!IsRW && Kind == ConstraintKind::ReadOnly);
@@ -311,8 +311,8 @@ LinkerScript::computeInputSections(const
return Ret;
}
-void LinkerScript::discard(ArrayRef<InputSectionBase *> V) {
- for (InputSectionBase *S : V) {
+void LinkerScript::discard(ArrayRef<InputSection *> V) {
+ for (InputSection *S : V) {
S->Live = false;
if (S == InX::ShStrTab || S == InX::Dynamic || S == InX::DynSymTab ||
S == InX::DynStrTab)
@@ -321,19 +321,16 @@ void LinkerScript::discard(ArrayRef<Inpu
}
}
-std::vector<InputSectionBase *>
+std::vector<InputSection *>
LinkerScript::createInputSectionList(OutputSection &OutCmd) {
- std::vector<InputSectionBase *> Ret;
+ std::vector<InputSection *> Ret;
for (BaseCommand *Base : OutCmd.SectionCommands) {
- auto *Cmd = dyn_cast<InputSectionDescription>(Base);
- if (!Cmd)
- continue;
-
- Cmd->Sections = computeInputSections(Cmd);
- Ret.insert(Ret.end(), Cmd->Sections.begin(), Cmd->Sections.end());
+ if (auto *Cmd = dyn_cast<InputSectionDescription>(Base)) {
+ Cmd->Sections = computeInputSections(Cmd);
+ Ret.insert(Ret.end(), Cmd->Sections.begin(), Cmd->Sections.end());
+ }
}
-
return Ret;
}
@@ -365,7 +362,7 @@ void LinkerScript::processSectionCommand
}
if (auto *Sec = dyn_cast<OutputSection>(SectionCommands[I])) {
- std::vector<InputSectionBase *> V = createInputSectionList(*Sec);
+ std::vector<InputSection *> V = createInputSectionList(*Sec);
// The output section name `/DISCARD/' is special.
// Any input section assigned to it is discarded.
@@ -405,8 +402,8 @@ void LinkerScript::processSectionCommand
}
// Add input sections to an output section.
- for (InputSectionBase *S : V)
- Sec->addSection(cast<InputSection>(S));
+ for (InputSection *S : V)
+ Sec->addSection(S);
assert(Sec->SectionIndex == INT_MAX);
Sec->SectionIndex = I;
Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=315426&r1=315425&r2=315426&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Tue Oct 10 21:01:13 2017
@@ -207,7 +207,7 @@ class LinkerScript final {
std::vector<InputSection *>
computeInputSections(const InputSectionDescription *);
- std::vector<InputSectionBase *> createInputSectionList(OutputSection &Cmd);
+ std::vector<InputSection *> createInputSectionList(OutputSection &Cmd);
std::vector<size_t> getPhdrIndices(OutputSection *Sec);
@@ -229,7 +229,7 @@ public:
bool hasPhdrsCommands() { return !PhdrsCommands.empty(); }
uint64_t getDot() { return Dot; }
- void discard(ArrayRef<InputSectionBase *> V);
+ void discard(ArrayRef<InputSection *> V);
ExprValue getSymbolValue(const Twine &Loc, StringRef S);
More information about the llvm-commits
mailing list