[llvm] r265579 - [IRVerifier] Prefer dyn_cast<> over isa<> + cast<>.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 6 11:13:45 PDT 2016


Author: davide
Date: Wed Apr  6 13:13:44 2016
New Revision: 265579

URL: http://llvm.org/viewvc/llvm-project?rev=265579&view=rev
Log:
[IRVerifier] Prefer dyn_cast<> over isa<> + cast<>.

Thanks to Rafael for the suggestion!

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

Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=265579&r1=265578&r2=265579&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Wed Apr  6 13:13:44 2016
@@ -4375,15 +4375,14 @@ void Verifier::verifyTypeRefs() {
 
   // Visit all the compile units again to map the type references.
   SmallDenseMap<const MDString *, const DIType *, 32> TypeRefs;
-  for (auto *CU : CUs->operands())
-    if (isa<DICompileUnit>(CU))
-      if (auto Ts = cast<DICompileUnit>(CU)->getRetainedTypes())
-        for (DIType *Op : Ts)
-          if (auto *T = dyn_cast_or_null<DICompositeType>(Op))
-            if (auto *S = T->getRawIdentifier()) {
-              UnresolvedTypeRefs.erase(S);
-              TypeRefs.insert(std::make_pair(S, T));
-            }
+  for (auto *MD : CUs->operands())
+    if (auto *CU = dyn_cast<DICompileUnit>(MD))
+      for (DIType *Op : CU->getRetainedTypes())
+        if (auto *T = dyn_cast_or_null<DICompositeType>(Op))
+          if (auto *S = T->getRawIdentifier()) {
+            UnresolvedTypeRefs.erase(S);
+            TypeRefs.insert(std::make_pair(S, T));
+          }
 
   // Verify debug info intrinsic bit piece expressions.  This needs a second
   // pass through the intructions, since we haven't built TypeRefs yet when




More information about the llvm-commits mailing list