Swift: extract remaining Stmts

`FailStmt` are `return nil` in fallible initializers.

`PoundAssertStmt` are an experimental feature for compile time
assertions.
This commit is contained in:
Paolo Tranquilli
2022-11-08 17:35:00 +01:00
parent 6fb021a5bc
commit 9ee4f8b388
15 changed files with 81 additions and 10 deletions

View File

@@ -174,4 +174,16 @@ void StmtTranslator::fillLabeledConditionalStmt(const swift::LabeledConditionalS
fillLabeledStmt(stmt, entry);
}
codeql::FailStmt StmtTranslator::translateFailStmt(const swift::FailStmt& stmt) {
return dispatcher.createEntry(stmt);
}
codeql::PoundAssertStmt StmtTranslator::translatePoundAssertStmt(
const swift::PoundAssertStmt& stmt) {
auto entry = dispatcher.createEntry(stmt);
entry.condition = dispatcher.fetchLabel(stmt.getCondition());
entry.message = stmt.getMessage();
return entry;
}
} // namespace codeql

View File

@@ -31,6 +31,8 @@ class StmtTranslator : public AstTranslatorBase<StmtTranslator> {
codeql::SwitchStmt translateSwitchStmt(const swift::SwitchStmt& stmt);
codeql::FallthroughStmt translateFallthroughStmt(const swift::FallthroughStmt& stmt);
codeql::YieldStmt translateYieldStmt(const swift::YieldStmt& stmt);
codeql::FailStmt translateFailStmt(const swift::FailStmt& stmt);
codeql::PoundAssertStmt translatePoundAssertStmt(const swift::PoundAssertStmt& stmt);
private:
void fillLabeledStmt(const swift::LabeledStmt& stmt, codeql::LabeledStmt& entry);