-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17138 from jketema/generic
C++: Support C11 `_Generic` expressions
- Loading branch information
Showing
22 changed files
with
11,314 additions
and
1,127 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
cpp/downgrades/0fea0ee7026c7c3f7d6faef4df4bf67847b67d71/downgrades.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Approach: replace conversion expressions of kind 389 (= @c11_generic) by | ||
* conversion expressions of kind 12 (= @parexpr), i.e., a `ParenthesisExpr`, | ||
* and drop the relation which its child expressions, which are just syntactic | ||
* sugar. Parenthesis expressions are equally benign as C11 _Generic expressions, | ||
* and behave similarly in the context of the IR. | ||
*/ | ||
|
||
class Expr extends @expr { | ||
string toString() { none() } | ||
} | ||
|
||
class Location extends @location { | ||
string toString() { none() } | ||
} | ||
|
||
class ExprParent extends @exprparent { | ||
string toString() { none() } | ||
} | ||
|
||
query predicate new_exprs(Expr expr, int new_kind, Location loc) { | ||
exists(int kind | exprs(expr, kind, loc) | if kind = 389 then new_kind = 12 else new_kind = kind) | ||
} | ||
|
||
query predicate new_exprparents(Expr expr, int index, ExprParent expr_parent) { | ||
exprparents(expr, index, expr_parent) and | ||
( | ||
not expr_parent instanceof @expr | ||
or | ||
exists(int kind | exprs(expr_parent.(Expr), kind, _) | kind != 389) | ||
) | ||
} |
Oops, something went wrong.