[lld] r313556 - Remove redundant cast<> and null check.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 18 12:15:54 PDT 2017


Author: ruiu
Date: Mon Sep 18 12:15:54 2017
New Revision: 313556

URL: http://llvm.org/viewvc/llvm-project?rev=313556&view=rev
Log:
Remove redundant cast<> and null check.

"Repl" member is guranteed to have a non-null pointer. If an input
section is not merged by ICF, "Repl" points to "this". Otherwise, it
points to some other section. It must not be NULL.

Modified:
    lld/trunk/ELF/SyntheticSections.cpp

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=313556&r1=313555&r2=313556&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Mon Sep 18 12:15:54 2017
@@ -446,12 +446,10 @@ bool EhFrameSection<ELFT>::isFdeLive(EhS
 
   const RelTy &Rel = Rels[FirstRelI];
   SymbolBody &B = Sec->template getFile<ELFT>()->getRelocTargetSym(Rel);
-  auto *D = dyn_cast<DefinedRegular>(&B);
-  if (!D || !D->Section)
-    return false;
-  auto *Target =
-      cast<InputSectionBase>(cast<InputSectionBase>(D->Section)->Repl);
-  return Target && Target->Live;
+  if (auto *D = dyn_cast<DefinedRegular>(&B))
+    if (D->Section)
+      return cast<InputSectionBase>(D->Section)->Repl->Live;
+  return false;
 }
 
 // .eh_frame is a sequence of CIE or FDE records. In general, there




More information about the llvm-commits mailing list