For-Loop and FunctionName

Hello all,

i have a question about finding for-loops.

How i can get the information in which function a for-loop is located.

How i understand clang it is impossible to get the function name for a for-loop.

I hope you can help me and give me a possibility to get the function name for a for-loop.

Bye Anja

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.