llvm.org GIT mirror llvm / de6fa5f
Add hasByValAttr() and hasNoAliasAttr() methods to the Argument class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46314 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 12 years ago
2 changed file(s) with 44 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
3838 /// Argument ctor - If Function argument is specified, this argument is
3939 /// inserted at the end of the argument list for the function.
4040 ///
41 explicit Argument(const Type *Ty,
42 const std::string &Name = "",
41 explicit Argument(const Type *Ty, const std::string &Name = "",
4342 Function *F = 0);
4443
4544 inline const Function *getParent() const { return Parent; }
4645 inline Function *getParent() { return Parent; }
4746
47 /// getArgNo - Return the index of this formal argument in its containing
48 /// function. For example in "void foo(int a, float b)" a is 0 and b is 1.
49 unsigned getArgNo() const;
50
51 /// hasByValAttr - Return true if this argument has the byval attribute on it
52 /// in its containing function.
53 bool hasByValAttr() const;
54
55 /// hasNoAliasAttr - Return true if this argument has the noalias attribute on
56 /// it in its containing function.
57 bool hasNoAliasAttr() const;
58
4859 virtual void print(std::ostream &OS) const;
4960 void print(std::ostream *OS) const {
5061 if (OS) print(*OS);
7373 if (getParent())
7474 LeakDetector::removeGarbageObject(this);
7575 }
76
77 /// getArgNo - Return the index of this formal argument in its containing
78 /// function. For example in "void foo(int a, float b)" a is 0 and b is 1.
79 unsigned Argument::getArgNo() const {
80 const Function *F = getParent();
81 assert(F && "Argument is not in a function");
82
83 Function::const_arg_iterator AI = F->arg_begin();
84 unsigned ArgIdx = 0;
85 for (; &*AI != this; ++AI)
86 ++ArgIdx;
87
88 return ArgIdx;
89 }
90
91 /// hasByValAttr - Return true if this argument has the byval attribute on it
92 /// in its containing function.
93 bool Argument::hasByValAttr() const {
94 if (!isa(getType())) return false;
95 return getParent()->paramHasAttr(getArgNo()+1, ParamAttr::ByVal);
96 }
97
98 /// hasNoAliasAttr - Return true if this argument has the noalias attribute on
99 /// it in its containing function.
100 bool Argument::hasNoAliasAttr() const {
101 if (!isa(getType())) return false;
102 return getParent()->paramHasAttr(getArgNo()+1, ParamAttr::NoAlias);
103 }
104
105
106
76107
77108 //===----------------------------------------------------------------------===//
78109 // Helper Methods in Function