diff options
| author | Simon Atanasyan <simon@atanasyan.com> | 2015-05-08 07:05:04 +0000 |
|---|---|---|
| committer | Simon Atanasyan <simon@atanasyan.com> | 2015-05-08 07:05:04 +0000 |
| commit | 8eb9d1bf124c8344663aca5e45323913be7ff292 (patch) | |
| tree | a37df03af0db23b9e3dc58da6f4b12089f4005df | |
| parent | 40e7eb166aed5dfff668ab89fd2dfe07bc1c0cb8 (diff) | |
| download | bcm5719-llvm-8eb9d1bf124c8344663aca5e45323913be7ff292.tar.gz bcm5719-llvm-8eb9d1bf124c8344663aca5e45323913be7ff292.zip | |
[yaml2elf] Replace error message by assert call in writeSectionContent methods
Now caller of ELFState::writeSectionContent() methods is responsible to check
a section type and selects an appropriate writeSectionContent method.
So unexpected section type inside writeSectionContent method indicates
a wrong usage of the method and should be guarded by assert.
llvm-svn: 236808
| -rw-r--r-- | llvm/tools/yaml2obj/yaml2elf.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/llvm/tools/yaml2obj/yaml2elf.cpp b/llvm/tools/yaml2obj/yaml2elf.cpp index 1226506f624..33865880563 100644 --- a/llvm/tools/yaml2obj/yaml2elf.cpp +++ b/llvm/tools/yaml2obj/yaml2elf.cpp @@ -350,11 +350,9 @@ bool ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::RelocationSection &Section, ContiguousBlobAccumulator &CBA) { - if (Section.Type != llvm::ELF::SHT_REL && - Section.Type != llvm::ELF::SHT_RELA) { - errs() << "error: Invalid relocation section type.\n"; - return false; - } + assert((Section.Type == llvm::ELF::SHT_REL || + Section.Type == llvm::ELF::SHT_RELA) && + "Section type is not SHT_REL nor SHT_RELA"); bool IsRela = Section.Type == llvm::ELF::SHT_RELA; SHeader.sh_entsize = IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel); @@ -392,10 +390,8 @@ bool ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::Group &Section, ContiguousBlobAccumulator &CBA) { typedef typename object::ELFFile<ELFT>::Elf_Word Elf_Word; - if (Section.Type != llvm::ELF::SHT_GROUP) { - errs() << "error: Invalid section type.\n"; - return false; - } + assert(Section.Type == llvm::ELF::SHT_GROUP && + "Section type is not SHT_GROUP"); SHeader.sh_entsize = sizeof(Elf_Word); SHeader.sh_size = SHeader.sh_entsize * Section.Members.size(); @@ -423,10 +419,8 @@ template <class ELFT> bool ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::MipsABIFlags &Section, ContiguousBlobAccumulator &CBA) { - if (Section.Type != llvm::ELF::SHT_MIPS_ABIFLAGS) { - errs() << "error: Invalid section type.\n"; - return false; - } + assert(Section.Type == llvm::ELF::SHT_MIPS_ABIFLAGS && + "Section type is not SHT_MIPS_ABIFLAGS"); object::Elf_Mips_ABIFlags<ELFT> Flags; zero(Flags); |

