Add a hasAddressTaken for BasicBlock.
authorDan Gohman <gohman@apple.com>
Thu, 29 Oct 2009 00:09:08 +0000 (00:09 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 29 Oct 2009 00:09:08 +0000 (00:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85449 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/BasicBlock.h
lib/VMCore/BasicBlock.cpp

index 95e39716f2e7f510a2918ff4c3f4ad312d0d06b3..c6e60802093fd95a4870a2a8c2784fec04c3fce5 100644 (file)
@@ -235,6 +235,10 @@ public:
   /// keeping loop information consistent, use the SplitBlock utility function.
   ///
   BasicBlock *splitBasicBlock(iterator I, const Twine &BBName = "");
+
+  /// hasAddressTaken - returns true if there are any uses of this basic block
+  /// other than direct branches, switches, etc. to it.
+  bool hasAddressTaken() const;
 };
 
 } // End llvm namespace
index 50cf84c3fe624cbf063fcc3b9e9e3ca29255e230..ede2d1245107befb1a5eab9d010857ac5171fe76 100644 (file)
@@ -277,3 +277,12 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) {
   }
   return New;
 }
+
+/// hasAddressTaken - returns true if there are any uses of this basic block
+/// other than direct branches, switches, etc. to it.
+bool BasicBlock::hasAddressTaken() const {
+  for (Value::use_const_iterator I = use_begin(), E = use_end(); I != E; ++I)
+    if (isa<BlockAddress>(*I))
+      return true;
+  return false;
+}