[PATCH] D41204: Inline a small function.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 13 14:48:06 PST 2017
LGTM
Rui Ueyama via Phabricator <reviews at reviews.llvm.org> writes:
> ruiu created this revision.
> ruiu added a reviewer: rafael.
> Herald added a subscriber: emaste.
>
> Inline a small function.
>
>
> https://reviews.llvm.org/D41204
>
> Files:
> lld/ELF/InputFiles.cpp
> lld/ELF/InputFiles.h
>
>
> Index: lld/ELF/InputFiles.h
> ===================================================================
> --- lld/ELF/InputFiles.h
> +++ lld/ELF/InputFiles.h
> @@ -194,7 +194,6 @@
> StringRef SourceFile;
>
> private:
> - InputSectionBase *getSection(uint32_t Index) const;
> void
> initializeSections(llvm::DenseSet<llvm::CachedHashStringRef> &ComdatGroups);
> void initializeSymbols();
> Index: lld/ELF/InputFiles.cpp
> ===================================================================
> --- lld/ELF/InputFiles.cpp
> +++ lld/ELF/InputFiles.cpp
> @@ -599,19 +599,14 @@
> this->Symbols.push_back(createSymbol(&Sym));
> }
>
> -template <class ELFT>
> -InputSectionBase *ObjFile<ELFT>::getSection(uint32_t Index) const {
> - if (Index == 0)
> - return nullptr;
> - if (Index >= this->Sections.size())
> - fatal(toString(this) + ": invalid section index: " + Twine(Index));
> - return this->Sections[Index];
> -}
> -
> template <class ELFT> Symbol *ObjFile<ELFT>::createSymbol(const Elf_Sym *Sym) {
> int Binding = Sym->getBinding();
> - InputSectionBase *Sec = getSection(this->getSectionIndex(*Sym));
>
> + uint32_t SecIdx = this->getSectionIndex(*Sym);
> + if (SecIdx >= this->Sections.size())
> + fatal(toString(this) + ": invalid section index: " + Twine(SecIdx));
> +
> + InputSectionBase *Sec = this->Sections[SecIdx];
> uint8_t StOther = Sym->st_other;
> uint8_t Type = Sym->getType();
> uint64_t Value = Sym->st_value;
>
>
> Index: lld/ELF/InputFiles.h
> ===================================================================
> --- lld/ELF/InputFiles.h
> +++ lld/ELF/InputFiles.h
> @@ -194,7 +194,6 @@
> StringRef SourceFile;
>
> private:
> - InputSectionBase *getSection(uint32_t Index) const;
> void
> initializeSections(llvm::DenseSet<llvm::CachedHashStringRef> &ComdatGroups);
> void initializeSymbols();
> Index: lld/ELF/InputFiles.cpp
> ===================================================================
> --- lld/ELF/InputFiles.cpp
> +++ lld/ELF/InputFiles.cpp
> @@ -599,19 +599,14 @@
> this->Symbols.push_back(createSymbol(&Sym));
> }
>
> -template <class ELFT>
> -InputSectionBase *ObjFile<ELFT>::getSection(uint32_t Index) const {
> - if (Index == 0)
> - return nullptr;
> - if (Index >= this->Sections.size())
> - fatal(toString(this) + ": invalid section index: " + Twine(Index));
> - return this->Sections[Index];
> -}
> -
> template <class ELFT> Symbol *ObjFile<ELFT>::createSymbol(const Elf_Sym *Sym) {
> int Binding = Sym->getBinding();
> - InputSectionBase *Sec = getSection(this->getSectionIndex(*Sym));
>
> + uint32_t SecIdx = this->getSectionIndex(*Sym);
> + if (SecIdx >= this->Sections.size())
> + fatal(toString(this) + ": invalid section index: " + Twine(SecIdx));
> +
> + InputSectionBase *Sec = this->Sections[SecIdx];
> uint8_t StOther = Sym->st_other;
> uint8_t Type = Sym->getType();
> uint64_t Value = Sym->st_value;
More information about the llvm-commits
mailing list