[llvm] r217796 - Use dyn_cast<> instead of isa<> and cast<>

Matt Arsenault Matthew.Arsenault at amd.com
Mon Sep 15 10:56:52 PDT 2014


Author: arsenm
Date: Mon Sep 15 12:56:51 2014
New Revision: 217796

URL: http://llvm.org/viewvc/llvm-project?rev=217796&view=rev
Log:
Use dyn_cast<> instead of isa<> and cast<>

Modified:
    llvm/trunk/lib/IR/Instructions.cpp

Modified: llvm/trunk/lib/IR/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instructions.cpp?rev=217796&r1=217795&r2=217796&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instructions.cpp (original)
+++ llvm/trunk/lib/IR/Instructions.cpp Mon Sep 15 12:56:51 2014
@@ -365,7 +365,8 @@ bool CallInst::paramHasAttr(unsigned i,
 /// IsConstantOne - Return true only if val is constant int 1
 static bool IsConstantOne(Value *val) {
   assert(val && "IsConstantOne does not work with NULL val");
-  return isa<ConstantInt>(val) && cast<ConstantInt>(val)->isOne();
+  const ConstantInt *CVal = dyn_cast<ConstantInt>(val);
+  return CVal && CVal->isOne();
 }
 
 static Instruction *createMalloc(Instruction *InsertBefore,





More information about the llvm-commits mailing list