<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jul 15, 2014 at 10:42 AM, Anja Gerbes <span dir="ltr"><<a href="mailto:anja.gerbes@googlemail.com" target="_blank">anja.gerbes@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hello all,<div><br></div><div>i have a question about finding for-loops.</div>
<div><br></div><div>How i can get the information in which function a for-loop is located.</div><div><br></div><div>How i understand clang it is impossible to get the function name for a for-loop.</div>
<div><br></div><div>I hope you can help me and give me a possibility to get the function name for a for-loop.</div></div></blockquote><div><br></div><div>If you're in Sema, you can look at CurContext. If you're using a RecursiveASTVisitor, you can track which function you're in during your recursive descent. If you're using an ASTMatcher, you can use a hasDescendent matcher to match a range-based for loop within a function and bind both entities, or, failing that, a parent matcher. If all else fails, you can use ASTContext::getParents.</div>
</div></div></div>