Swift: extract AppliedPropertyWrapperExpr

This commit is contained in:
Paolo Tranquilli
2022-11-10 12:53:31 +01:00
parent 28c9d6b6b5
commit edfecddca1
20 changed files with 262 additions and 7 deletions

View File

@@ -573,4 +573,25 @@ ExprTranslator::translatePropertyWrapperValuePlaceholderExpr(
return entry;
}
static int translatePropertyWrapperValueKind(swift::AppliedPropertyWrapperExpr::ValueKind kind) {
using K = swift::AppliedPropertyWrapperExpr::ValueKind;
switch (kind) {
case K::WrappedValue:
return 1;
case K::ProjectedValue:
return 2;
default:
return 0;
}
}
codeql::AppliedPropertyWrapperExpr ExprTranslator::translateAppliedPropertyWrapperExpr(
const swift::AppliedPropertyWrapperExpr& expr) {
auto entry = createExprEntry(expr);
entry.kind = translatePropertyWrapperValueKind(expr.getValueKind());
entry.value =
dispatcher.fetchLabel(const_cast<swift::AppliedPropertyWrapperExpr&>(expr).getValue());
entry.param = dispatcher.fetchLabel(expr.getParamDecl());
return entry;
}
} // namespace codeql

View File

@@ -113,6 +113,8 @@ class ExprTranslator : public AstTranslatorBase<ExprTranslator> {
const swift::UnresolvedSpecializeExpr& expr);
codeql::PropertyWrapperValuePlaceholderExpr translatePropertyWrapperValuePlaceholderExpr(
const swift::PropertyWrapperValuePlaceholderExpr& expr);
codeql::AppliedPropertyWrapperExpr translateAppliedPropertyWrapperExpr(
const swift::AppliedPropertyWrapperExpr& expr);
private:
void fillAbstractClosureExpr(const swift::AbstractClosureExpr& expr,