From d2276205821f5fd72934d9d2f9ae29dfc08a780d Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sun, 24 Jul 2016 01:18:18 +0000 Subject: [PATCH] Simplify. NFC. llvm-svn: 276540 --- lld/ELF/LinkerScript.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 9f9252a..073832c 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -330,23 +330,21 @@ LinkerScript::filter(std::vector *> &Sections) { if (!Cmd) continue; - OutputSectionBase *Sec = *It; - switch (Cmd->Constraint) { - case ConstraintKind::NoConstraint: + if (Cmd->Constraint == ConstraintKind::NoConstraint) { ++It; continue; - case ConstraintKind::ReadOnly: - if (Sec->getFlags() & SHF_WRITE) - break; - ++It; - continue; - case ConstraintKind::ReadWrite: - if (!(Sec->getFlags() & SHF_WRITE)) - break; - ++It; + } + + OutputSectionBase *Sec = *It; + bool Writable = (Sec->getFlags() & SHF_WRITE); + bool RO = (Cmd->Constraint == ConstraintKind::ReadOnly); + bool RW = (Cmd->Constraint == ConstraintKind::ReadWrite); + + if ((RO && Writable) || (RW && !Writable)) { + Sections.erase(It); continue; } - Sections.erase(It); + ++It; } return Sections; } -- 2.7.4