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
174174 fillLabeledStmt (stmt, entry);
175175}
176176
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+
177189} // namespace codeql
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ class StmtTranslator : public AstTranslatorBase<StmtTranslator> {
3131 codeql::SwitchStmt translateSwitchStmt (const swift::SwitchStmt& stmt);
3232 codeql::FallthroughStmt translateFallthroughStmt (const swift::FallthroughStmt& stmt);
3333 codeql::YieldStmt translateYieldStmt (const swift::YieldStmt& stmt);
34+ codeql::FailStmt translateFailStmt (const swift::FailStmt& stmt);
35+ codeql::PoundAssertStmt translatePoundAssertStmt (const swift::PoundAssertStmt& stmt);
3436
3537 private:
3638 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 {
11161116
11171117 class PoundAssertStmt extends @pound_assert_stmt, Stmt {
11181118 override string toString ( ) { result = "PoundAssertStmt" }
1119+
1120+ Expr getCondition ( ) { pound_assert_stmts ( this , result , _) }
1121+
1122+ string getMessage ( ) { pound_assert_stmts ( this , _, result ) }
11191123 }
11201124
11211125 class ReturnStmt extends @return_stmt, Stmt {
Original file line number Diff line number Diff line change 11// generated by codegen/codegen.py
22private import codeql.swift.generated.Synth
33private import codeql.swift.generated.Raw
4+ import codeql.swift.elements.expr.Expr
45import codeql.swift.elements.stmt.Stmt
56
67module Generated {
78 class PoundAssertStmt extends Synth:: TPoundAssertStmt , Stmt {
89 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+ }
935 }
1036}
Original file line number Diff line number Diff line change @@ -1696,7 +1696,9 @@ labeled_stmt_labels( //dir=stmt
16961696);
16971697
16981698pound_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
17001702);
17011703
17021704return_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