Use dyn_cast instead of isa + cast.
authorDevang Patel <dpatel@apple.com>
Sat, 23 Feb 2008 00:47:00 +0000 (00:47 +0000)
committerDevang Patel <dpatel@apple.com>
Sat, 23 Feb 2008 00:47:00 +0000 (00:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47511 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Instructions.h
lib/VMCore/AsmWriter.cpp

index 8d912f2370269250eb0fbca41a57301b6dcc4d3f..1335031e5a35eede9e2bd6d14edd1984e89d6d1a 100644 (file)
@@ -2375,7 +2375,11 @@ public:
     return getOperand(0);
   }
 
-  unsigned getIndex() {
+  inline unsigned getIndex() {
+    return Idx;
+  }
+
+  inline const unsigned getIndex() const {
     return Idx;
   }
 
index 8a7eec9b0480d029c0daa7318b0a35bb641e49b3..adbcd78c25f10f1e93d1728fbf16b256fd1061d5 100644 (file)
@@ -1291,7 +1291,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
       writeOperand(I.getOperand(op  ), false); Out << ',';
       writeOperand(I.getOperand(op+1), false); Out << " ]";
     }
-  } else if (isa<GetResultInst>(I)) {
+  } else if (const GetResultInst *GRI = dyn_cast<GetResultInst>(&I)) {
     const StructType *STy = cast<StructType>(I.getOperand(0)->getType());
     unsigned NumElems = STy->getNumElements();
     Out << " {";
@@ -1303,7 +1303,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
     }
     Out << " }";
     writeOperand(I.getOperand(0), false);
-    Out << ", " << cast<GetResultInst>(I).getIndex();
+    Out << ", " << GRI->getIndex();
   } else if (isa<ReturnInst>(I) && !Operand) {
     Out << " void";
   } else if (const CallInst *CI = dyn_cast<CallInst>(&I)) {