[llvm-branch-commits] [llvm-branch] r99387 - in /llvm/branches/ggreif/InvokeInst-operands: include/llvm/Function.h lib/VMCore/Function.cpp

Gabor Greif ggreif at gmail.com
Tue Mar 23 23:02:23 PDT 2010


Author: ggreif
Date: Wed Mar 24 01:02:22 2010
New Revision: 99387

URL: http://llvm.org/viewvc/llvm-project?rev=99387&view=rev
Log:
beef up hasAddressTaken interface to optionally pass back offending user

Modified:
    llvm/branches/ggreif/InvokeInst-operands/include/llvm/Function.h
    llvm/branches/ggreif/InvokeInst-operands/lib/VMCore/Function.cpp

Modified: llvm/branches/ggreif/InvokeInst-operands/include/llvm/Function.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/InvokeInst-operands/include/llvm/Function.h?rev=99387&r1=99386&r2=99387&view=diff
==============================================================================
--- llvm/branches/ggreif/InvokeInst-operands/include/llvm/Function.h (original)
+++ llvm/branches/ggreif/InvokeInst-operands/include/llvm/Function.h Wed Mar 24 01:02:22 2010
@@ -409,8 +409,11 @@
   void dropAllReferences();
 
   /// hasAddressTaken - returns true if there are any uses of this function
-  /// other than direct calls or invokes to it.
-  bool hasAddressTaken() const;
+  /// other than direct calls or invokes to it. Optionally passes back the
+  /// offending user for diagnostic purposes.
+  ///
+  bool hasAddressTaken(const User** = 0) const;
+
 private:
   // Shadow Value::setValueSubclassData with a private forwarding method so that
   // subclasses cannot accidentally use it.

Modified: llvm/branches/ggreif/InvokeInst-operands/lib/VMCore/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/InvokeInst-operands/lib/VMCore/Function.cpp?rev=99387&r1=99386&r2=99387&view=diff
==============================================================================
--- llvm/branches/ggreif/InvokeInst-operands/lib/VMCore/Function.cpp (original)
+++ llvm/branches/ggreif/InvokeInst-operands/lib/VMCore/Function.cpp Wed Mar 24 01:02:22 2010
@@ -403,13 +403,14 @@
 
 /// hasAddressTaken - returns true if there are any uses of this function
 /// other than direct calls or invokes to it.
-bool Function::hasAddressTaken() const {
+bool Function::hasAddressTaken(const User* *PutOffender) const {
   for (Value::use_const_iterator I = use_begin(), E = use_end(); I != E; ++I) {
-    if (!isa<CallInst>(*I) && !isa<InvokeInst>(*I))
-      return true;
-    CallSite CS(const_cast<Instruction*>(static_cast<const Instruction*>(*I)));
+    const User *U = *I;
+    if (!isa<CallInst>(U) && !isa<InvokeInst>(U))
+      return PutOffender ? (*PutOffender = U, true) : true;
+    CallSite CS(const_cast<Instruction*>(static_cast<const Instruction*>(U)));
     if (!CS.isCallee(I))
-      return true;
+      return PutOffender ? (*PutOffender = U, true) : true;
   }
   return false;
 }





More information about the llvm-branch-commits mailing list