Don't crash on a query where the block is not in any loop. Thanks to
authorChris Lattner <sabre@nondot.org>
Wed, 29 Jun 2005 17:41:25 +0000 (17:41 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 29 Jun 2005 17:41:25 +0000 (17:41 +0000)
Sameer D. Sahasrabuddhe for pointing this out!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22314 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/LoopInfo.h

index 5e818bcbe1913ca558753e5d9d2041637fd9b8f1..9357d8fb6ea9ab4d17d5157a688bc56c2f7be805 100644 (file)
@@ -250,7 +250,8 @@ public:
 
   // isLoopHeader - True if the block is a loop header node
   bool isLoopHeader(BasicBlock *BB) const {
-    return getLoopFor(BB)->getHeader() == BB;
+    const Loop *L = getLoopFor(BB);
+    return L && L->getHeader() == BB;
   }
 
   /// runOnFunction - Calculate the natural loop information.