Random Number Generator (llvm)
[oota-llvm.git] / include / llvm / IR / Function.h
index 11208bb91740f6c9a7a1c86d8ef659d100e1705f..22444bd3000ef118e0db20bef84f0f4fb7b7f679 100644 (file)
 #ifndef LLVM_IR_FUNCTION_H
 #define LLVM_IR_FUNCTION_H
 
+#include "llvm/ADT/iterator_range.h"
 #include "llvm/IR/Argument.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CallingConv.h"
-#include "llvm/IR/GlobalValue.h"
+#include "llvm/IR/GlobalObject.h"
 #include "llvm/Support/Compiler.h"
 
 namespace llvm {
@@ -67,8 +68,7 @@ private:
   mutable ilist_half_node<Argument> Sentinel;
 };
 
-class Function : public GlobalValue,
-                 public ilist_node<Function> {
+class Function : public GlobalObject, public ilist_node<Function> {
 public:
   typedef iplist<Argument> ArgumentListType;
   typedef iplist<BasicBlock> BasicBlockListType;
@@ -122,11 +122,11 @@ private:
   /// the module.
   ///
   Function(FunctionType *Ty, LinkageTypes Linkage,
-           const Twine &N = "", Module *M = 0);
+           const Twine &N = "", Module *M = nullptr);
 
 public:
   static Function *Create(FunctionType *Ty, LinkageTypes Linkage,
-                          const Twine &N = "", Module *M = 0) {
+                          const Twine &N = "", Module *M = nullptr) {
     return new(0) Function(Ty, Linkage, N, M);
   }
 
@@ -297,7 +297,8 @@ public:
   /// @brief Determine if the function returns a structure through first
   /// pointer argument.
   bool hasStructRetAttr() const {
-    return AttributeSets.hasAttribute(1, Attribute::StructRet);
+    return AttributeSets.hasAttribute(1, Attribute::StructRet) ||
+           AttributeSets.hasAttribute(2, Attribute::StructRet);
   }
 
   /// @brief Determine if the parameter does not alias other parameters.
@@ -404,9 +405,9 @@ public:
   const BasicBlock        &back() const { return BasicBlocks.back();  }
         BasicBlock        &back()       { return BasicBlocks.back();  }
 
-  //===--------------------------------------------------------------------===//
-  // Argument iterator forwarding functions
-  //
+/// @name Function Argument Iteration
+/// @{
+
   arg_iterator arg_begin() {
     CheckLazyArguments();
     return ArgumentList.begin();
@@ -424,6 +425,16 @@ public:
     return ArgumentList.end();
   }
 
+  iterator_range<arg_iterator> args() {
+    return iterator_range<arg_iterator>(arg_begin(), arg_end());
+  }
+
+  iterator_range<const_arg_iterator> args() const {
+    return iterator_range<const_arg_iterator>(arg_begin(), arg_end());
+  }
+
+/// @}
+
   size_t arg_size() const;
   bool arg_empty() const;
 
@@ -472,7 +483,7 @@ public:
   /// other than direct calls or invokes to it, or blockaddress expressions.
   /// Optionally passes back an offending user for diagnostic purposes.
   ///
-  bool hasAddressTaken(const User** = 0) const;
+  bool hasAddressTaken(const User** = nullptr) const;
 
   /// isDefTriviallyDead - Return true if it is trivially safe to remove
   /// this function definition from the module (because it isn't externally
@@ -494,12 +505,12 @@ private:
 
 inline ValueSymbolTable *
 ilist_traits<BasicBlock>::getSymTab(Function *F) {
-  return F ? &F->getValueSymbolTable() : 0;
+  return F ? &F->getValueSymbolTable() : nullptr;
 }
 
 inline ValueSymbolTable *
 ilist_traits<Argument>::getSymTab(Function *F) {
-  return F ? &F->getValueSymbolTable() : 0;
+  return F ? &F->getValueSymbolTable() : nullptr;
 }
 
 } // End llvm namespace