1 //===-- llvm/Argument.h - Definition of the Argument class ------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the Argument class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_IR_ARGUMENT_H
15 #define LLVM_IR_ARGUMENT_H
17 #include "llvm/ADT/Twine.h"
18 #include "llvm/ADT/ilist_node.h"
19 #include "llvm/IR/Attributes.h"
20 #include "llvm/IR/Value.h"
24 template<typename ValueSubClass, typename ItemParentClass>
25 class SymbolTableListTraits;
27 /// A class to represent an incoming formal argument to a Function. An argument
28 /// is a very simple Value. It is essentially a named (optional) type. When used
29 /// in the body of a function, it represents the value of the actual argument
30 /// the function was called with.
31 /// @brief LLVM Argument representation
32 class Argument : public Value, public ilist_node<Argument> {
33 virtual void anchor();
36 friend class SymbolTableListTraits<Argument, Function>;
37 void setParent(Function *parent);
40 /// Argument ctor - If Function argument is specified, this argument is
41 /// inserted at the end of the argument list for the function.
43 explicit Argument(Type *Ty, const Twine &Name = "", Function *F = 0);
45 inline const Function *getParent() const { return Parent; }
46 inline Function *getParent() { return Parent; }
48 /// getArgNo - Return the index of this formal argument in its containing
49 /// function. For example in "void foo(int a, float b)" a is 0 and b is 1.
50 unsigned getArgNo() const;
52 /// hasByValAttr - Return true if this argument has the byval attribute on it
53 /// in its containing function.
54 bool hasByValAttr() const;
56 /// getParamAlignment - If this is a byval argument, return its alignment.
57 unsigned getParamAlignment() const;
59 /// hasNestAttr - Return true if this argument has the nest attribute on
60 /// it in its containing function.
61 bool hasNestAttr() const;
63 /// hasNoAliasAttr - Return true if this argument has the noalias attribute on
64 /// it in its containing function.
65 bool hasNoAliasAttr() const;
67 /// hasNoCaptureAttr - Return true if this argument has the nocapture
68 /// attribute on it in its containing function.
69 bool hasNoCaptureAttr() const;
71 /// hasStructRetAttr - Return true if this argument has the sret attribute on
72 /// it in its containing function.
73 bool hasStructRetAttr() const;
75 /// addAttr - Add a Attribute to an argument
76 void addAttr(Attribute);
78 /// removeAttr - Remove a Attribute from an argument
79 void removeAttr(Attribute);
81 /// classof - Methods for support type inquiry through isa, cast, and
84 static inline bool classof(const Value *V) {
85 return V->getValueID() == ArgumentVal;
89 } // End llvm namespace