[PATCH] D64925: [IR] Add getArg() method to Function class
Teresa Johnson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 1 08:32:44 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL367576: [IR] Add getArg() method to Function class (authored by tejohnson, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D64925?vs=211751&id=212825#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64925/new/
https://reviews.llvm.org/D64925
Files:
llvm/trunk/include/llvm/IR/Function.h
llvm/trunk/unittests/IR/FunctionTest.cpp
Index: llvm/trunk/unittests/IR/FunctionTest.cpp
===================================================================
--- llvm/trunk/unittests/IR/FunctionTest.cpp
+++ llvm/trunk/unittests/IR/FunctionTest.cpp
@@ -33,6 +33,14 @@
// 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) {
Index: llvm/trunk/include/llvm/IR/Function.h
===================================================================
--- llvm/trunk/include/llvm/IR/Function.h
+++ llvm/trunk/include/llvm/IR/Function.h
@@ -710,6 +710,12 @@
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());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64925.212825.patch
Type: text/x-patch
Size: 1130 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190801/0aaade5b/attachment.bin>
More information about the llvm-commits
mailing list