From: Dan Gohman Date: Thu, 29 Oct 2009 00:09:08 +0000 (+0000) Subject: Add a hasAddressTaken for BasicBlock. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=eeb8ef1f37a8d106a9fb77b9dd6a7ab6866904e5;p=oota-llvm.git Add a hasAddressTaken for BasicBlock. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85449 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h index 95e39716f2e..c6e60802093 100644 --- a/include/llvm/BasicBlock.h +++ b/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/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp index 50cf84c3fe6..ede2d124510 100644 --- a/lib/VMCore/BasicBlock.cpp +++ b/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; +}