[cfe-dev] Using Libtooling to find for loop break statements

Phil King via cfe-dev cfe-dev at lists.llvm.org
Wed Aug 12 08:16:24 PDT 2020


Hi,

I am trying to find all of the break statements that can cause termination of for loops. The following gives me all the break statements under a “for” node, but I cannot see how to filter out those that cannot terminate the current loop (e.g., they may terminate a case statement, be enclosed within a nested loop, etc.):

forStmt( forEachDescentant( breakStmt().bind( “myBreaks” ) ) ).bind( “myFors” )

How should I go about filtering out the unwanted breaks?

Sent from my iPhone


More information about the cfe-dev mailing list