[lld] r233456 - Use cast instead of dyn_cast in combination with llvm_unreachable.

Rui Ueyama ruiu at google.com
Fri Mar 27 17:09:26 PDT 2015


Author: ruiu
Date: Fri Mar 27 19:09:26 2015
New Revision: 233456

URL: http://llvm.org/viewvc/llvm-project?rev=233456&view=rev
Log:
Use cast instead of dyn_cast in combination with llvm_unreachable.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h

Modified: lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h?rev=233456&r1=233455&r2=233456&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h Fri Mar 27 19:09:26 2015
@@ -635,14 +635,13 @@ DefaultLayout<ELFT>::addAtom(const Atom
     }
     return section->appendAtom(atom);
   }
-  if (const AbsoluteAtom *absoluteAtom = dyn_cast<AbsoluteAtom>(atom)) {
-    // Absolute atoms are not part of any section, they are global for the whole
-    // link
-    _absoluteAtoms.push_back(new (_allocator)
-        lld::AtomLayout(absoluteAtom, 0, absoluteAtom->value()));
-    return _absoluteAtoms.back();
-  }
-  llvm_unreachable("Only absolute / defined atoms can be added here");
+
+  const AbsoluteAtom *absoluteAtom = cast<AbsoluteAtom>(atom);
+  // Absolute atoms are not part of any section, they are global for the whole
+  // link
+  _absoluteAtoms.push_back(
+      new (_allocator) lld::AtomLayout(absoluteAtom, 0, absoluteAtom->value()));
+  return _absoluteAtoms.back();
 }
 
 /// Output sections with the same name into a OutputSection





More information about the llvm-commits mailing list