From 3903320a48b2cc4ca08c04b6e621ace34de74b29 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 29 Oct 2009 00:09:08 +0000 Subject: [PATCH] Add a hasAddressTaken for BasicBlock. llvm-svn: 85449 --- llvm/include/llvm/BasicBlock.h | 4 ++++ llvm/lib/VMCore/BasicBlock.cpp | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/llvm/include/llvm/BasicBlock.h b/llvm/include/llvm/BasicBlock.h index 95e39716f2e7..c6e60802093f 100644 --- a/llvm/include/llvm/BasicBlock.h +++ b/llvm/include/llvm/BasicBlock.h @@ -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 diff --git a/llvm/lib/VMCore/BasicBlock.cpp b/llvm/lib/VMCore/BasicBlock.cpp index 50cf84c3fe62..ede2d1245107 100644 --- a/llvm/lib/VMCore/BasicBlock.cpp +++ b/llvm/lib/VMCore/BasicBlock.cpp @@ -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(*I)) + return true; + return false; +}