Add new method
[oota-llvm.git] / include / llvm / Argument.h
1 //===-- llvm/Argument.h - Definition of the Argument class ------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the Argument class, which represents an incoming formal
11 // argument to a Function.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_ARGUMENT_H
16 #define LLVM_ARGUMENT_H
17
18 #include "llvm/Value.h"
19
20 class Argument : public Value {  // Defined in the Function.cpp file
21   Function *Parent;
22
23   Argument *Prev, *Next; // Next and Prev links for our intrusive linked list
24   void setNext(Argument *N) { Next = N; }
25   void setPrev(Argument *N) { Prev = N; }
26   friend class SymbolTableListTraits<Argument, Function, Function,
27                                      ilist_traits<Argument> >;
28   void setParent(Function *parent);
29
30 public:
31   /// Argument ctor - If Function argument is specified, this argument is
32   /// inserted at the end of the argument list for the function.
33   ///
34   Argument(const Type *Ty, const std::string &Name = "", Function *F = 0);
35
36   /// setName - Specialize setName to handle symbol table majik...
37   virtual void setName(const std::string &name, SymbolTable *ST = 0);
38
39   inline const Function *getParent() const { return Parent; }
40   inline       Function *getParent()       { return Parent; }
41  
42   // getNext/Prev - Return the next or previous argument in the list.
43         Argument *getNext()       { return Next; }
44   const Argument *getNext() const { return Next; }
45         Argument *getPrev()       { return Prev; }
46   const Argument *getPrev() const { return Prev; }
47
48   virtual void print(std::ostream &OS) const;
49
50   /// classof - Methods for support type inquiry through isa, cast, and
51   /// dyn_cast:
52   ///
53   static inline bool classof(const Argument *) { return true; }
54   static inline bool classof(const Value *V) {
55     return V->getValueType() == ArgumentVal;
56   }
57 };
58
59 #endif