[cfe-dev] forEachSwitchCase() matcher acting wierd,imho
Farzad Sadeghi via cfe-dev
cfe-dev at lists.llvm.org
Sun Nov 13 00:03:35 PST 2016
thank you both. this worked:
switchStmt(hasDescendant(compoundStmt(hasDescendant(switchCase(unless(hasDescendant(breakStmt())))))))
On 11/13/16, Malcolm Parsons <malcolm.parsons at gmail.com> wrote:
> On 12 November 2016 at 11:52, Farzad Sadeghi via cfe-dev
> <cfe-dev at lists.llvm.org> wrote:
>> for this matcher:
>> switchStmt(forEachSwitchCase(hasDescendant(breakStmt().bind("bubu"))))
>
>> now,my question is, shouldn't clang-query just not match anything,
>> since each switchCase clearly does not have a descendant breakStmt or
>> am I misunderstanding something?
>
> forEachSwichCase allows the matcher to match multiple times if there
> are multiple switch cases that match.
> It doesn't prevent a match if there is a switch case that doesn't match.
>
> To match switch statements where all switch cases have a break
> statement you should be able to use
> switchStmt(unless(has(compoundStmt(has(switchCase(unless(hasDescendant(breakStmt())))))))).
>
> --
> Malcolm Parsons
>
--
Farzad Sadeghi
More information about the cfe-dev
mailing list