Fix for PR1801
[llvm-complete.git] / include / llvm / Argument.h
blobc995043616c0d00054a695aa637695c9e303fed7
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 declares the Argument class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_ARGUMENT_H
15 #define LLVM_ARGUMENT_H
17 #include "llvm/Value.h"
19 namespace llvm {
21 template<typename ValueSubClass, typename ItemParentClass>
22 class SymbolTableListTraits;
24 /// A class to represent an incoming formal argument to a Function. An argument
25 /// is a very simple Value. It is essentially a named (optional) type. When used
26 /// in the body of a function, it represents the value of the actual argument
27 /// the function was called with.
28 /// @brief LLVM Argument representation
29 class Argument : public Value { // Defined in the Function.cpp file
30 Function *Parent;
32 Argument *Prev, *Next; // Next and Prev links for our intrusive linked list
33 void setNext(Argument *N) { Next = N; }
34 void setPrev(Argument *N) { Prev = N; }
35 friend class SymbolTableListTraits<Argument, Function>;
36 void setParent(Function *parent);
38 public:
39 /// Argument ctor - If Function argument is specified, this argument is
40 /// inserted at the end of the argument list for the function.
41 ///
42 explicit Argument(const Type *Ty,
43 const std::string &Name = "",
44 Function *F = 0);
46 inline const Function *getParent() const { return Parent; }
47 inline Function *getParent() { return Parent; }
49 virtual void print(std::ostream &OS) const;
50 void print(std::ostream *OS) const {
51 if (OS) print(*OS);
54 /// classof - Methods for support type inquiry through isa, cast, and
55 /// dyn_cast:
56 ///
57 static inline bool classof(const Argument *) { return true; }
58 static inline bool classof(const Value *V) {
59 return V->getValueID() == ArgumentVal;
62 private:
63 // getNext/Prev - Return the next or previous argument in the list.
64 Argument *getNext() { return Next; }
65 const Argument *getNext() const { return Next; }
66 Argument *getPrev() { return Prev; }
67 const Argument *getPrev() const { return Prev; }
70 } // End llvm namespace
72 #endif