[PATCH] Use cast<T> for type conversion with assertion.

Rui Ueyama ruiu at google.com
Wed Apr 2 14:34:48 PDT 2014


Hi shankarke,

Use cast<T> for type conversion with assertion.

http://llvm-reviews.chandlerc.com/D3269

Files:
  lib/Core/Resolver.cpp

Index: lib/Core/Resolver.cpp
===================================================================
--- lib/Core/Resolver.cpp
+++ lib/Core/Resolver.cpp
@@ -193,9 +193,7 @@
     if (_context.getAllowDuplicates())
       return true;
     const DefinedAtom *prevGroup =
-        dyn_cast<DefinedAtom>(_symbolTable.findGroup(atom.name()));
-    assert(prevGroup &&
-           "Internal Error: The group atom could only be a defined atom");
+        cast<DefinedAtom>(_symbolTable.findGroup(atom.name()));
     // The atoms should be of the same content type, reject invalid group
     // resolution behaviors.
     if (atom.contentType() != prevGroup->contentType())
@@ -206,9 +204,7 @@
   for (const Reference *r : atom) {
     if ((r->kindNamespace() == lld::Reference::KindNamespace::all) &&
         (r->kindValue() == lld::Reference::kindGroupChild)) {
-      const DefinedAtom *target = dyn_cast<DefinedAtom>(r->target());
-      assert(target && "Internal Error: kindGroupChild references need to "
-                       "be associated with Defined Atoms only");
+      const DefinedAtom *target = cast<DefinedAtom>(r->target());
       _atoms.push_back(target);
       _symbolTable.add(*target);
     }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3269.1.patch
Type: text/x-patch
Size: 1208 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140402/2fe5e33f/attachment.bin>


More information about the llvm-commits mailing list