[cfe-dev] forEachSwitchCase() matcher acting wierd,imho

Farzad Sadeghi via cfe-dev cfe-dev at lists.llvm.org
Sat Nov 12 03:52:32 PST 2016


here's the tst function:
---------------------------------------------------------------
void testFunc (void)
{
        int level = 10;
        switch (level)
        {
                case 1:
                        {level++;
                        break;}
                 case 2:
                        {level = 10;}
                case 3:
                        {level = 1U;}
        }
}
-----------------------------------------------------------
for this matcher:
switchStmt(forEachSwitchCase(hasDescendant(breakStmt().bind("bubu"))))
clang-query returns this:
Match #1:

/home/bloodstalker/devi/hell1/test4.c:9:18: note: "bubu" binds here
                        break;}
                        ^~~~~
/home/bloodstalker/devi/hell1/test4.c:5:9: note: "root" binds here
        switch (level)
        ^~~~~~~~~~~~~~
1 match.

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?

-- 
Farzad Sadeghi



More information about the cfe-dev mailing list