Skip to content

Commit 941485d

Browse files
authored
Merge pull request #9130 from jketema/cpp17-init
C++: Handle C++17 if and switch initializers
2 parents 8c8440a + 723f3b0 commit 941485d

File tree

33 files changed

+14595
-4658
lines changed

33 files changed

+14595
-4658
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Element extends @element {
2+
string toString() { none() }
3+
}
4+
5+
class Expr extends @expr {
6+
string toString() { none() }
7+
}
8+
9+
class Stmt extends @stmt {
10+
string toString() { none() }
11+
}
12+
13+
predicate isStmtWithInitializer(Stmt stmt) {
14+
exists(int kind | stmts(stmt, kind, _) | kind = 2 or kind = 11 or kind = 35)
15+
}
16+
17+
from Expr child, int index, int index_new, Element parent
18+
where
19+
exprparents(child, index, parent) and
20+
if isStmtWithInitializer(parent) then index_new = index - 1 else index_new = index
21+
select child, index_new, parent

0 commit comments

Comments
 (0)