[lld] r276540 - Simplify. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 23 18:18:18 PDT 2016


Author: ruiu
Date: Sat Jul 23 20:18:18 2016
New Revision: 276540

URL: http://llvm.org/viewvc/llvm-project?rev=276540&view=rev
Log:
Simplify. NFC.

Modified:
    lld/trunk/ELF/LinkerScript.cpp

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=276540&r1=276539&r2=276540&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Sat Jul 23 20:18:18 2016
@@ -330,23 +330,21 @@ LinkerScript<ELFT>::filter(std::vector<O
     if (!Cmd)
       continue;
 
-    OutputSectionBase<ELFT> *Sec = *It;
-    switch (Cmd->Constraint) {
-    case ConstraintKind::NoConstraint:
-      ++It;
-      continue;
-    case ConstraintKind::ReadOnly:
-      if (Sec->getFlags() & SHF_WRITE)
-        break;
+    if (Cmd->Constraint == ConstraintKind::NoConstraint) {
       ++It;
       continue;
-    case ConstraintKind::ReadWrite:
-      if (!(Sec->getFlags() & SHF_WRITE))
-        break;
-      ++It;
+    }
+
+    OutputSectionBase<ELFT> *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;
 }




More information about the llvm-commits mailing list