LLVM API Documentation

Argument.h

Go to the documentation of this file.
00001 //===-- llvm/Argument.h - Definition of the Argument class ------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file declares the Argument class. 
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_ARGUMENT_H
00015 #define LLVM_ARGUMENT_H
00016 
00017 #include "llvm/Value.h"
00018 #include "llvm/Attributes.h"
00019 #include "llvm/ADT/ilist_node.h"
00020 
00021 namespace llvm {
00022 
00023 template<typename ValueSubClass, typename ItemParentClass>
00024   class SymbolTableListTraits;
00025 
00026 /// A class to represent an incoming formal argument to a Function. An argument
00027 /// is a very simple Value. It is essentially a named (optional) type. When used
00028 /// in the body of a function, it represents the value of the actual argument
00029 /// the function was called with.
00030 /// @brief LLVM Argument representation  
00031 class Argument : public Value, public ilist_node<Argument> {
00032   Function *Parent;
00033 
00034   friend class SymbolTableListTraits<Argument, Function>;
00035   void setParent(Function *parent);
00036 
00037 public:
00038   /// Argument ctor - If Function argument is specified, this argument is
00039   /// inserted at the end of the argument list for the function.
00040   ///
00041   explicit Argument(const Type *Ty, const Twine &Name = "", Function *F = 0);
00042 
00043   inline const Function *getParent() const { return Parent; }
00044   inline       Function *getParent()       { return Parent; }
00045 
00046   /// getArgNo - Return the index of this formal argument in its containing
00047   /// function.  For example in "void foo(int a, float b)" a is 0 and b is 1. 
00048   unsigned getArgNo() const;
00049   
00050   /// hasByValAttr - Return true if this argument has the byval attribute on it
00051   /// in its containing function.
00052   bool hasByValAttr() const;
00053 
00054   /// hasNoAliasAttr - Return true if this argument has the noalias attribute on
00055   /// it in its containing function.
00056   bool hasNoAliasAttr() const;
00057   
00058   /// hasNoCaptureAttr - Return true if this argument has the nocapture
00059   /// attribute on it in its containing function.
00060   bool hasNoCaptureAttr() const;
00061   
00062   /// hasSRetAttr - Return true if this argument has the sret attribute on it in
00063   /// its containing function.
00064   bool hasStructRetAttr() const;
00065 
00066   /// addAttr - Add a Attribute to an argument
00067   void addAttr(Attributes);
00068   
00069   /// removeAttr - Remove a Attribute from an argument
00070   void removeAttr(Attributes);
00071 
00072   /// classof - Methods for support type inquiry through isa, cast, and
00073   /// dyn_cast:
00074   ///
00075   static inline bool classof(const Argument *) { return true; }
00076   static inline bool classof(const Value *V) {
00077     return V->getValueID() == ArgumentVal;
00078   }
00079 };
00080 
00081 } // End llvm namespace
00082 
00083 #endif