Make the GraphWriter be more consistent about the string
[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 is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the Argument class. 
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_ARGUMENT_H
15 #define LLVM_ARGUMENT_H
16
17 #include "llvm/Value.h"
18 #include "llvm/ParameterAttributes.h"
19
20 namespace llvm {
21
22 template<typename ValueSubClass, typename ItemParentClass>
23   class SymbolTableListTraits;
24
25 /// A class to represent an incoming formal argument to a Function. An argument
26 /// is a very simple Value. It is essentially a named (optional) type. When used
27 /// in the body of a function, it represents the value of the actual argument
28 /// the function was called with.
29 /// @brief LLVM Argument representation  
30 class Argument : public Value {  // Defined in the Function.cpp file
31   Function *Parent;
32
33   Argument *Prev, *Next; // Next and Prev links for our intrusive linked list
34   void setNext(Argument *N) { Next = N; }
35   void setPrev(Argument *N) { Prev = N; }
36   friend class SymbolTableListTraits<Argument, Function>;
37   void setParent(Function *parent);
38
39 public:
40   /// Argument ctor - If Function argument is specified, this argument is
41   /// inserted at the end of the argument list for the function.
42   ///
43   explicit Argument(const Type *Ty, const std::string &Name = "",
44                     Function *F = 0);
45
46   inline const Function *getParent() const { return Parent; }
47   inline       Function *getParent()       { return Parent; }
48
49   /// getArgNo - Return the index of this formal argument in its containing
50   /// function.  For example in "void foo(int a, float b)" a is 0 and b is 1. 
51   unsigned getArgNo() const;
52   
53   /// hasByValAttr - Return true if this argument has the byval attribute on it
54   /// in its containing function.
55   bool hasByValAttr() const;
56
57   /// hasNoAliasAttr - Return true if this argument has the noalias attribute on
58   /// it in its containing function.
59   bool hasNoAliasAttr() const;
60   
61   /// hasSRetAttr - Return true if this argument has the sret attribute on it in
62   /// its containing function.
63   bool hasStructRetAttr() const;
64
65   /// addAttr - Add a ParamAttr to an argument
66   void addAttr(ParameterAttributes);
67   
68   /// removeAttr - Remove a ParamAttr from an argument
69   void removeAttr(ParameterAttributes);
70
71   virtual void print(std::ostream &OS) const;
72   void print(std::ostream *OS) const {
73     if (OS) print(*OS);
74   }
75
76   /// classof - Methods for support type inquiry through isa, cast, and
77   /// dyn_cast:
78   ///
79   static inline bool classof(const Argument *) { return true; }
80   static inline bool classof(const Value *V) {
81     return V->getValueID() == ArgumentVal;
82   }
83   
84 private:
85   // getNext/Prev - Return the next or previous argument in the list.
86   Argument *getNext()       { return Next; }
87   const Argument *getNext() const { return Next; }
88   Argument *getPrev()       { return Prev; }
89   const Argument *getPrev() const { return Prev; }
90 };
91
92 } // End llvm namespace
93
94 #endif