Use more precise type.
authorRui Ueyama <ruiu@google.com>
Wed, 11 Oct 2017 04:01:13 +0000 (04:01 +0000)
committerRui Ueyama <ruiu@google.com>
Wed, 11 Oct 2017 04:01:13 +0000 (04:01 +0000)
llvm-svn: 315426

lld/ELF/InputFiles.cpp
lld/ELF/InputSection.h
lld/ELF/LinkerScript.cpp
lld/ELF/LinkerScript.h

index 69930d0e49a3571d6cb880813b4f5073b8042ac9..fb9559131837753cb2f44ba9f9c186abc78ea4e6 100644 (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]));
     }
   }
 }
index dd3d3740c8de411b8db4ac9d68e0980bfad1dad2..51b22599aac24f2ad330192e6407dd3bb515b274 100644 (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;
index b73e378e445a0582ca165a72efabe2f873fd06ae..501fb9476124a385762d33ee7306710e58d8c95a 100644 (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;
index 3b82bceeeb0ab857227de879b3561dc633b8aebe..42273d0c89b654e971f3c7f1c940833887d212ac 100644 (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);