File tree Expand file tree Collapse file tree 15 files changed +81
-10
lines changed Expand file tree Collapse file tree 15 files changed +81
-10
lines changed Original file line number Diff line number Diff line change @@ -174,4 +174,16 @@ void StmtTranslator::fillLabeledConditionalStmt(const swift::LabeledConditionalS
174
174
fillLabeledStmt (stmt, entry);
175
175
}
176
176
177
+ codeql::FailStmt StmtTranslator::translateFailStmt (const swift::FailStmt& stmt) {
178
+ return dispatcher.createEntry (stmt);
179
+ }
180
+
181
+ codeql::PoundAssertStmt StmtTranslator::translatePoundAssertStmt (
182
+ const swift::PoundAssertStmt& stmt) {
183
+ auto entry = dispatcher.createEntry (stmt);
184
+ entry.condition = dispatcher.fetchLabel (stmt.getCondition ());
185
+ entry.message = stmt.getMessage ();
186
+ return entry;
187
+ }
188
+
177
189
} // namespace codeql
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ class StmtTranslator : public AstTranslatorBase<StmtTranslator> {
31
31
codeql::SwitchStmt translateSwitchStmt (const swift::SwitchStmt& stmt);
32
32
codeql::FallthroughStmt translateFallthroughStmt (const swift::FallthroughStmt& stmt);
33
33
codeql::YieldStmt translateYieldStmt (const swift::YieldStmt& stmt);
34
+ codeql::FailStmt translateFailStmt (const swift::FailStmt& stmt);
35
+ codeql::PoundAssertStmt translatePoundAssertStmt (const swift::PoundAssertStmt& stmt);
34
36
35
37
private:
36
38
void fillLabeledStmt (const swift::LabeledStmt& stmt, codeql::LabeledStmt& entry);
Original file line number Diff line number Diff line change @@ -1116,6 +1116,10 @@ module Raw {
1116
1116
1117
1117
class PoundAssertStmt extends @pound_assert_stmt, Stmt {
1118
1118
override string toString ( ) { result = "PoundAssertStmt" }
1119
+
1120
+ Expr getCondition ( ) { pound_assert_stmts ( this , result , _) }
1121
+
1122
+ string getMessage ( ) { pound_assert_stmts ( this , _, result ) }
1119
1123
}
1120
1124
1121
1125
class ReturnStmt extends @return_stmt, Stmt {
Original file line number Diff line number Diff line change 1
1
// generated by codegen/codegen.py
2
2
private import codeql.swift.generated.Synth
3
3
private import codeql.swift.generated.Raw
4
+ import codeql.swift.elements.expr.Expr
4
5
import codeql.swift.elements.stmt.Stmt
5
6
6
7
module Generated {
7
8
class PoundAssertStmt extends Synth:: TPoundAssertStmt , Stmt {
8
9
override string getAPrimaryQlClass ( ) { result = "PoundAssertStmt" }
10
+
11
+ /**
12
+ * Gets the condition of this pound assert statement.
13
+ *
14
+ * This includes nodes from the "hidden" AST. It can be overridden in subclasses to change the
15
+ * behavior of both the `Immediate` and non-`Immediate` versions.
16
+ */
17
+ Expr getImmediateCondition ( ) {
18
+ result =
19
+ Synth:: convertExprFromRaw ( Synth:: convertPoundAssertStmtToRaw ( this )
20
+ .( Raw:: PoundAssertStmt )
21
+ .getCondition ( ) )
22
+ }
23
+
24
+ /**
25
+ * Gets the condition of this pound assert statement.
26
+ */
27
+ final Expr getCondition ( ) { result = getImmediateCondition ( ) .resolve ( ) }
28
+
29
+ /**
30
+ * Gets the message of this pound assert statement.
31
+ */
32
+ string getMessage ( ) {
33
+ result = Synth:: convertPoundAssertStmtToRaw ( this ) .( Raw:: PoundAssertStmt ) .getMessage ( )
34
+ }
9
35
}
10
36
}
Original file line number Diff line number Diff line change @@ -1696,7 +1696,9 @@ labeled_stmt_labels( //dir=stmt
1696
1696
);
1697
1697
1698
1698
pound_assert_stmts( //dir=stmt
1699
- unique int id: @pound_assert_stmt
1699
+ unique int id: @pound_assert_stmt,
1700
+ int condition: @expr_or_none ref,
1701
+ string message: string ref
1700
1702
);
1701
1703
1702
1704
return_stmts( //dir=stmt
Original file line number Diff line number Diff line change
1
+ | fail.swift:2:15:2:22 | fail |
Original file line number Diff line number Diff line change
1
+ // generated by codegen/codegen.py
2
+ import codeql.swift.elements
3
+ import TestUtils
4
+
5
+ from FailStmt x
6
+ where toBeTested ( x ) and not x .isUnknown ( )
7
+ select x
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ struct S {
2
+ init ? ( ) { return nil }
3
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments