mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-04-02 15:51:54 +00:00
[IR] Add getArg() method to Function class
Adds a method which, when called with function.getArg(i), returns an Argument* to the i'th argument. Patch by Henry Wildermuth Differential Revision: https://reviews.llvm.org/D64925 llvm-svn: 367576
This commit is contained in:
parent
8a6da2044e
commit
7f907de47e
@ -710,6 +710,12 @@ public:
|
||||
return Arguments + NumArgs;
|
||||
}
|
||||
|
||||
Argument* getArg(unsigned i) const {
|
||||
assert (i < NumArgs && "getArg() out of range!");
|
||||
CheckLazyArguments();
|
||||
return Arguments + i;
|
||||
}
|
||||
|
||||
iterator_range<arg_iterator> args() {
|
||||
return make_range(arg_begin(), arg_end());
|
||||
}
|
||||
|
@ -33,6 +33,14 @@ TEST(FunctionTest, hasLazyArguments) {
|
||||
// The argument list should be populated at first access.
|
||||
(void)F->arg_begin();
|
||||
EXPECT_FALSE(F->hasLazyArguments());
|
||||
|
||||
// Checking that getArg gets the arguments from F1 in the correct order.
|
||||
unsigned i = 0;
|
||||
for (Argument &A : F->args()) {
|
||||
EXPECT_EQ(&A, F->getArg(i));
|
||||
++i;
|
||||
}
|
||||
EXPECT_FALSE(F->hasLazyArguments());
|
||||
}
|
||||
|
||||
TEST(FunctionTest, stealArgumentListFrom) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user