Use more precise type.

llvm-svn: 315426
This commit is contained in:
Rui Ueyama 2017-10-11 04:01:13 +00:00
parent 187b67a533
commit 0543343170
4 changed files with 17 additions and 20 deletions

View File

@ -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]));
}
}
}

View File

@ -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;

View File

@ -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 InputSectionDescription *Cmd) {
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<InputSectionBase *> V) {
}
}
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::processSectionCommands(OutputSectionFactory &Factory) {
}
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::processSectionCommands(OutputSectionFactory &Factory) {
}
// 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;

View File

@ -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);