diff options
author | Yaron Keren <yaron.keren@gmail.com> | 2014-05-01 12:33:26 +0000 |
---|---|---|
committer | Yaron Keren <yaron.keren@gmail.com> | 2014-05-01 12:33:26 +0000 |
commit | adcf88eeda3e08ad0dd506adb6d0ad6401863f5b (patch) | |
tree | c29277be85e3c1aa054a6546a13241e22d696146 /llvm/docs/ProgrammersManual.rst | |
parent | 05017b1f8c5bc5e957c4392a3b4742e4e76ea8b9 (diff) | |
download | bcm5719-llvm-adcf88eeda3e08ad0dd506adb6d0ad6401863f5b.tar.gz bcm5719-llvm-adcf88eeda3e08ad0dd506adb6d0ad6401863f5b.zip |
Update post-r203364 http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140303/207915.html
and ranged for loops.
http://reviews.llvm.org/D3582
llvm-svn: 207755
Diffstat (limited to 'llvm/docs/ProgrammersManual.rst')
-rw-r--r-- | llvm/docs/ProgrammersManual.rst | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/docs/ProgrammersManual.rst b/llvm/docs/ProgrammersManual.rst index 9f388cc63f5..d545cb2b347 100644 --- a/llvm/docs/ProgrammersManual.rst +++ b/llvm/docs/ProgrammersManual.rst @@ -1738,16 +1738,12 @@ chain of ``F``: Function *F = ...; - for (Value::use_iterator i = F->use_begin(), e = F->use_end(); i != e; ++i) - if (Instruction *Inst = dyn_cast<Instruction>(*i)) { + for (User *U : GV->users()) { + if (Instruction *Inst = dyn_cast<Instruction>(U)) { errs() << "F is used in instruction:\n"; errs() << *Inst << "\n"; } -Note that dereferencing a ``Value::use_iterator`` is not a very cheap operation. -Instead of performing ``*i`` above several times, consider doing it only once in -the loop body and reusing its result. - Alternatively, it's common to have an instance of the ``User`` Class (`doxygen <http://llvm.org/doxygen/classllvm_1_1User.html>`__) and need to know what ``Value``\ s are used by it. The list of all ``Value``\ s used by a ``User`` is @@ -1759,8 +1755,8 @@ instruction uses (that is, the operands of the particular ``Instruction``): Instruction *pi = ...; - for (User::op_iterator i = pi->op_begin(), e = pi->op_end(); i != e; ++i) { - Value *v = *i; + for (Use& U : pi->operands()) { + Value *v = U.get(); // ... } |