mirror of
https://github.com/github/codeql.git
synced 2026-04-24 08:15:14 +02:00
Swift: update extractor
This commit is contained in:
@@ -77,7 +77,7 @@ MAP(swift::Expr, ExprTag)
|
||||
MAP(swift::DeclRefExpr, DeclRefExprTag)
|
||||
MAP(swift::SuperRefExpr, SuperRefExprTag)
|
||||
MAP(swift::TypeExpr, TypeExprTag)
|
||||
MAP(swift::OtherConstructorDeclRefExpr, OtherConstructorDeclRefExprTag)
|
||||
MAP(swift::OtherConstructorDeclRefExpr, OtherInitializerRefExprTag)
|
||||
MAP(swift::DotSyntaxBaseIgnoredExpr, DotSyntaxBaseIgnoredExprTag)
|
||||
MAP(swift::OverloadSetRefExpr, OverloadedDeclRefExprTag) // collapsed with its only derived class OverloadedDeclRefExpr
|
||||
MAP(swift::OverloadedDeclRefExpr, OverloadedDeclRefExprTag)
|
||||
@@ -108,13 +108,13 @@ MAP(swift::Expr, ExprTag)
|
||||
MAP(swift::KeyPathApplicationExpr, KeyPathApplicationExprTag)
|
||||
MAP(swift::TupleElementExpr, TupleElementExprTag)
|
||||
MAP(swift::CaptureListExpr, CaptureListExprTag)
|
||||
MAP(swift::AbstractClosureExpr, AbstractClosureExprTag)
|
||||
MAP(swift::ClosureExpr, ClosureExprTag)
|
||||
MAP(swift::AbstractClosureExpr, ClosureExprTag)
|
||||
MAP(swift::ClosureExpr, ExplicitClosureExprTag)
|
||||
MAP(swift::AutoClosureExpr, AutoClosureExprTag)
|
||||
MAP(swift::InOutExpr, InOutExprTag)
|
||||
MAP(swift::VarargExpansionExpr, VarargExpansionExprTag)
|
||||
MAP(swift::DynamicTypeExpr, DynamicTypeExprTag)
|
||||
MAP(swift::RebindSelfInConstructorExpr, RebindSelfInConstructorExprTag)
|
||||
MAP(swift::RebindSelfInConstructorExpr, RebindSelfInInitializerExprTag)
|
||||
MAP(swift::OpaqueValueExpr, OpaqueValueExprTag)
|
||||
MAP(swift::PropertyWrapperValuePlaceholderExpr, PropertyWrapperValuePlaceholderExprTag)
|
||||
MAP(swift::AppliedPropertyWrapperExpr, AppliedPropertyWrapperExprTag)
|
||||
@@ -131,7 +131,7 @@ MAP(swift::Expr, ExprTag)
|
||||
MAP(swift::BinaryExpr, BinaryExprTag)
|
||||
MAP(swift::SelfApplyExpr, SelfApplyExprTag)
|
||||
MAP(swift::DotSyntaxCallExpr, DotSyntaxCallExprTag)
|
||||
MAP(swift::ConstructorRefCallExpr, ConstructorRefCallExprTag)
|
||||
MAP(swift::ConstructorRefCallExpr, InitializerRefCallExprTag)
|
||||
MAP(swift::ImplicitConversionExpr, ImplicitConversionExprTag)
|
||||
MAP(swift::LoadExpr, LoadExprTag)
|
||||
MAP(swift::DestructureTupleExpr, DestructureTupleExprTag)
|
||||
@@ -178,7 +178,7 @@ MAP(swift::Expr, ExprTag)
|
||||
MAP(swift::AssignExpr, AssignExprTag)
|
||||
MAP(swift::CodeCompletionExpr, void) // only generated for code editing
|
||||
MAP(swift::UnresolvedPatternExpr, UnresolvedPatternExprTag)
|
||||
MAP(swift::LazyInitializerExpr, LazyInitializerExprTag)
|
||||
MAP(swift::LazyInitializerExpr, LazyInitializationExprTag)
|
||||
MAP(swift::EditorPlaceholderExpr, void) // only generated for code editing
|
||||
MAP(swift::ObjCSelectorExpr, ObjCSelectorExprTag)
|
||||
MAP(swift::KeyPathExpr, KeyPathExprTag)
|
||||
@@ -207,12 +207,12 @@ MAP(swift::Decl, DeclTag)
|
||||
MAP_CONCRETE(swift::VarDecl, ConcreteVarDeclTag)
|
||||
MAP(swift::ParamDecl, ParamDeclTag)
|
||||
MAP(swift::SubscriptDecl, SubscriptDeclTag)
|
||||
MAP(swift::AbstractFunctionDecl, AbstractFunctionDeclTag)
|
||||
MAP(swift::ConstructorDecl, ConstructorDeclTag)
|
||||
MAP(swift::DestructorDecl, DestructorDeclTag)
|
||||
MAP(swift::FuncDecl, FuncDeclTag)
|
||||
MAP_CONCRETE(swift::FuncDecl, ConcreteFuncDeclTag)
|
||||
MAP(swift::AccessorDecl, AccessorDeclTag)
|
||||
MAP(swift::AbstractFunctionDecl, FunctionTag)
|
||||
MAP(swift::ConstructorDecl, InitializerTag)
|
||||
MAP(swift::DestructorDecl, DeinitializerTag)
|
||||
MAP(swift::FuncDecl, AccessorOrNamedFunctionTag)
|
||||
MAP_CONCRETE(swift::FuncDecl, NamedFunctionTag)
|
||||
MAP(swift::AccessorDecl, AccessorTag)
|
||||
MAP(swift::EnumElementDecl, EnumElementDeclTag)
|
||||
MAP(swift::ExtensionDecl, ExtensionDeclTag)
|
||||
MAP(swift::TopLevelCodeDecl, TopLevelCodeDeclTag)
|
||||
|
||||
@@ -24,22 +24,21 @@ std::string constructName(const swift::DeclName& declName) {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
codeql::ConcreteFuncDecl DeclTranslator::translateFuncDecl(const swift::FuncDecl& decl) {
|
||||
codeql::NamedFunction DeclTranslator::translateFuncDecl(const swift::FuncDecl& decl) {
|
||||
auto entry = createEntry(decl);
|
||||
fillAbstractFunctionDecl(decl, entry);
|
||||
fillFunction(decl, entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
codeql::ConstructorDecl DeclTranslator::translateConstructorDecl(
|
||||
const swift::ConstructorDecl& decl) {
|
||||
codeql::Initializer DeclTranslator::translateConstructorDecl(const swift::ConstructorDecl& decl) {
|
||||
auto entry = createEntry(decl);
|
||||
fillAbstractFunctionDecl(decl, entry);
|
||||
fillFunction(decl, entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
codeql::DestructorDecl DeclTranslator::translateDestructorDecl(const swift::DestructorDecl& decl) {
|
||||
codeql::Deinitializer DeclTranslator::translateDestructorDecl(const swift::DestructorDecl& decl) {
|
||||
auto entry = createEntry(decl);
|
||||
fillAbstractFunctionDecl(decl, entry);
|
||||
fillFunction(decl, entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
@@ -173,7 +172,7 @@ codeql::TypeAliasDecl DeclTranslator::translateTypeAliasDecl(const swift::TypeAl
|
||||
return entry;
|
||||
}
|
||||
|
||||
codeql::AccessorDecl DeclTranslator::translateAccessorDecl(const swift::AccessorDecl& decl) {
|
||||
codeql::Accessor DeclTranslator::translateAccessorDecl(const swift::AccessorDecl& decl) {
|
||||
auto entry = createEntry(decl);
|
||||
switch (decl.getAccessorKind()) {
|
||||
case swift::AccessorKind::Get:
|
||||
@@ -201,7 +200,7 @@ codeql::AccessorDecl DeclTranslator::translateAccessorDecl(const swift::Accessor
|
||||
entry.is_unsafe_mutable_address = true;
|
||||
break;
|
||||
}
|
||||
fillAbstractFunctionDecl(decl, entry);
|
||||
fillFunction(decl, entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
@@ -251,8 +250,8 @@ codeql::ModuleDecl DeclTranslator::translateModuleDecl(const swift::ModuleDecl&
|
||||
return entry;
|
||||
}
|
||||
|
||||
void DeclTranslator::fillAbstractFunctionDecl(const swift::AbstractFunctionDecl& decl,
|
||||
codeql::AbstractFunctionDecl& entry) {
|
||||
void DeclTranslator::fillFunction(const swift::AbstractFunctionDecl& decl,
|
||||
codeql::Function& entry) {
|
||||
assert(decl.hasParameterList() && "Expect functions to have a parameter list");
|
||||
entry.name = !decl.hasName() ? "(unnamed function decl)" : constructName(decl.getName());
|
||||
entry.body = dispatcher.fetchOptionalLabel(decl.getBody());
|
||||
@@ -328,7 +327,7 @@ void DeclTranslator::fillValueDecl(const swift::ValueDecl& decl, codeql::ValueDe
|
||||
|
||||
void DeclTranslator::fillAbstractStorageDecl(const swift::AbstractStorageDecl& decl,
|
||||
codeql::AbstractStorageDecl& entry) {
|
||||
entry.accessor_decls = dispatcher.fetchRepeatedLabels(decl.getAllAccessors());
|
||||
entry.accessors = dispatcher.fetchRepeatedLabels(decl.getAllAccessors());
|
||||
fillValueDecl(decl, entry);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ class DeclTranslator : public AstTranslatorBase<DeclTranslator> {
|
||||
public:
|
||||
using AstTranslatorBase<DeclTranslator>::AstTranslatorBase;
|
||||
|
||||
codeql::ConcreteFuncDecl translateFuncDecl(const swift::FuncDecl& decl);
|
||||
codeql::ConstructorDecl translateConstructorDecl(const swift::ConstructorDecl& decl);
|
||||
codeql::DestructorDecl translateDestructorDecl(const swift::DestructorDecl& decl);
|
||||
codeql::NamedFunction translateFuncDecl(const swift::FuncDecl& decl);
|
||||
codeql::Initializer translateConstructorDecl(const swift::ConstructorDecl& decl);
|
||||
codeql::Deinitializer translateDestructorDecl(const swift::DestructorDecl& decl);
|
||||
codeql::PrefixOperatorDecl translatePrefixOperatorDecl(const swift::PrefixOperatorDecl& decl);
|
||||
codeql::PostfixOperatorDecl translatePostfixOperatorDecl(const swift::PostfixOperatorDecl& decl);
|
||||
codeql::InfixOperatorDecl translateInfixOperatorDecl(const swift::InfixOperatorDecl& decl);
|
||||
@@ -37,7 +37,7 @@ class DeclTranslator : public AstTranslatorBase<DeclTranslator> {
|
||||
const swift::GenericTypeParamDecl& decl);
|
||||
codeql::AssociatedTypeDecl translateAssociatedTypeDecl(const swift::AssociatedTypeDecl& decl);
|
||||
codeql::TypeAliasDecl translateTypeAliasDecl(const swift::TypeAliasDecl& decl);
|
||||
codeql::AccessorDecl translateAccessorDecl(const swift::AccessorDecl& decl);
|
||||
codeql::Accessor translateAccessorDecl(const swift::AccessorDecl& decl);
|
||||
codeql::SubscriptDecl translateSubscriptDecl(const swift::SubscriptDecl& decl);
|
||||
codeql::ExtensionDecl translateExtensionDecl(const swift::ExtensionDecl& decl);
|
||||
codeql::ImportDecl translateImportDecl(const swift::ImportDecl& decl);
|
||||
@@ -49,8 +49,7 @@ class DeclTranslator : public AstTranslatorBase<DeclTranslator> {
|
||||
codeql::CapturedDecl translateCapturedValue(const swift::CapturedValue& capture);
|
||||
|
||||
private:
|
||||
void fillAbstractFunctionDecl(const swift::AbstractFunctionDecl& decl,
|
||||
codeql::AbstractFunctionDecl& entry);
|
||||
void fillFunction(const swift::AbstractFunctionDecl& decl, codeql::Function& entry);
|
||||
void fillOperatorDecl(const swift::OperatorDecl& decl, codeql::OperatorDecl& entry);
|
||||
void fillTypeDecl(const swift::TypeDecl& decl, codeql::TypeDecl& entry);
|
||||
void fillIterableDeclContext(const swift::IterableDeclContext& decl, codeql::Decl& entry);
|
||||
|
||||
@@ -211,7 +211,7 @@ codeql::OptionalEvaluationExpr ExprTranslator::translateOptionalEvaluationExpr(
|
||||
return entry;
|
||||
}
|
||||
|
||||
codeql::RebindSelfInConstructorExpr ExprTranslator::translateRebindSelfInConstructorExpr(
|
||||
codeql::RebindSelfInInitializerExpr ExprTranslator::translateRebindSelfInConstructorExpr(
|
||||
const swift::RebindSelfInConstructorExpr& expr) {
|
||||
auto entry = createExprEntry(expr);
|
||||
entry.sub_expr = dispatcher.fetchLabel(expr.getSubExpr());
|
||||
@@ -300,7 +300,7 @@ codeql::OptionalTryExpr ExprTranslator::translateOptionalTryExpr(
|
||||
return entry;
|
||||
}
|
||||
|
||||
codeql::ConstructorRefCallExpr ExprTranslator::translateConstructorRefCallExpr(
|
||||
codeql::InitializerRefCallExpr ExprTranslator::translateConstructorRefCallExpr(
|
||||
const swift::ConstructorRefCallExpr& expr) {
|
||||
auto entry = createExprEntry(expr);
|
||||
fillSelfApplyExpr(expr, entry);
|
||||
@@ -313,16 +313,16 @@ codeql::DiscardAssignmentExpr ExprTranslator::translateDiscardAssignmentExpr(
|
||||
return entry;
|
||||
}
|
||||
|
||||
codeql::ClosureExpr ExprTranslator::translateClosureExpr(const swift::ClosureExpr& expr) {
|
||||
codeql::ExplicitClosureExpr ExprTranslator::translateClosureExpr(const swift::ClosureExpr& expr) {
|
||||
auto entry = createExprEntry(expr);
|
||||
fillAbstractClosureExpr(expr, entry);
|
||||
fillClosureExpr(expr, entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
codeql::AutoClosureExpr ExprTranslator::translateAutoClosureExpr(
|
||||
const swift::AutoClosureExpr& expr) {
|
||||
auto entry = createExprEntry(expr);
|
||||
fillAbstractClosureExpr(expr, entry);
|
||||
fillClosureExpr(expr, entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ codeql::KeyPathExpr ExprTranslator::translateKeyPathExpr(const swift::KeyPathExp
|
||||
return entry;
|
||||
}
|
||||
|
||||
codeql::LazyInitializerExpr ExprTranslator::translateLazyInitializerExpr(
|
||||
codeql::LazyInitializationExpr ExprTranslator::translateLazyInitializerExpr(
|
||||
const swift::LazyInitializerExpr& expr) {
|
||||
auto entry = createExprEntry(expr);
|
||||
entry.sub_expr = dispatcher.fetchLabel(expr.getSubExpr());
|
||||
@@ -427,10 +427,10 @@ codeql::KeyPathApplicationExpr ExprTranslator::translateKeyPathApplicationExpr(
|
||||
return entry;
|
||||
}
|
||||
|
||||
codeql::OtherConstructorDeclRefExpr ExprTranslator::translateOtherConstructorDeclRefExpr(
|
||||
codeql::OtherInitializerRefExpr ExprTranslator::translateOtherConstructorDeclRefExpr(
|
||||
const swift::OtherConstructorDeclRefExpr& expr) {
|
||||
auto entry = createExprEntry(expr);
|
||||
entry.constructor_decl = dispatcher.fetchLabel(expr.getDecl());
|
||||
entry.initializer = dispatcher.fetchLabel(expr.getDecl());
|
||||
return entry;
|
||||
}
|
||||
|
||||
@@ -472,8 +472,8 @@ codeql::ErrorExpr ExprTranslator::translateErrorExpr(const swift::ErrorExpr& exp
|
||||
return entry;
|
||||
}
|
||||
|
||||
void ExprTranslator::fillAbstractClosureExpr(const swift::AbstractClosureExpr& expr,
|
||||
codeql::AbstractClosureExpr& entry) {
|
||||
void ExprTranslator::fillClosureExpr(const swift::AbstractClosureExpr& expr,
|
||||
codeql::ClosureExpr& entry) {
|
||||
assert(expr.getParameters() && "AbstractClosureExpr has getParameters()");
|
||||
entry.params = dispatcher.fetchRepeatedLabels(*expr.getParameters());
|
||||
entry.body = dispatcher.fetchLabel(expr.getBody());
|
||||
|
||||
@@ -39,7 +39,7 @@ class ExprTranslator : public AstTranslatorBase<ExprTranslator> {
|
||||
codeql::OpenExistentialExpr translateOpenExistentialExpr(const swift::OpenExistentialExpr& expr);
|
||||
codeql::OptionalEvaluationExpr translateOptionalEvaluationExpr(
|
||||
const swift::OptionalEvaluationExpr& expr);
|
||||
codeql::RebindSelfInConstructorExpr translateRebindSelfInConstructorExpr(
|
||||
codeql::RebindSelfInInitializerExpr translateRebindSelfInConstructorExpr(
|
||||
const swift::RebindSelfInConstructorExpr& expr);
|
||||
codeql::SuperRefExpr translateSuperRefExpr(const swift::SuperRefExpr& expr);
|
||||
codeql::DotSyntaxCallExpr translateDotSyntaxCallExpr(const swift::DotSyntaxCallExpr& expr);
|
||||
@@ -69,11 +69,11 @@ class ExprTranslator : public AstTranslatorBase<ExprTranslator> {
|
||||
codeql::TryExpr translateTryExpr(const swift::TryExpr& expr);
|
||||
codeql::ForceTryExpr translateForceTryExpr(const swift::ForceTryExpr& expr);
|
||||
codeql::OptionalTryExpr translateOptionalTryExpr(const swift::OptionalTryExpr& expr);
|
||||
codeql::ConstructorRefCallExpr translateConstructorRefCallExpr(
|
||||
codeql::InitializerRefCallExpr translateConstructorRefCallExpr(
|
||||
const swift::ConstructorRefCallExpr& expr);
|
||||
codeql::DiscardAssignmentExpr translateDiscardAssignmentExpr(
|
||||
const swift::DiscardAssignmentExpr& expr);
|
||||
codeql::ClosureExpr translateClosureExpr(const swift::ClosureExpr& expr);
|
||||
codeql::ExplicitClosureExpr translateClosureExpr(const swift::ClosureExpr& expr);
|
||||
codeql::AutoClosureExpr translateAutoClosureExpr(const swift::AutoClosureExpr& expr);
|
||||
codeql::CoerceExpr translateCoerceExpr(const swift::CoerceExpr& expr);
|
||||
codeql::ConditionalCheckedCastExpr translateConditionalCheckedCastExpr(
|
||||
@@ -85,13 +85,14 @@ class ExprTranslator : public AstTranslatorBase<ExprTranslator> {
|
||||
codeql::DictionaryExpr translateDictionaryExpr(const swift::DictionaryExpr& expr);
|
||||
codeql::MemberRefExpr translateMemberRefExpr(const swift::MemberRefExpr& expr);
|
||||
codeql::KeyPathExpr translateKeyPathExpr(const swift::KeyPathExpr& expr);
|
||||
codeql::LazyInitializerExpr translateLazyInitializerExpr(const swift::LazyInitializerExpr& expr);
|
||||
codeql::LazyInitializationExpr translateLazyInitializerExpr(
|
||||
const swift::LazyInitializerExpr& expr);
|
||||
codeql::ForceValueExpr translateForceValueExpr(const swift::ForceValueExpr& expr);
|
||||
codeql::IfExpr translateIfExpr(const swift::IfExpr& expr);
|
||||
codeql::KeyPathDotExpr translateKeyPathDotExpr(const swift::KeyPathDotExpr& expr);
|
||||
codeql::KeyPathApplicationExpr translateKeyPathApplicationExpr(
|
||||
const swift::KeyPathApplicationExpr& expr);
|
||||
codeql::OtherConstructorDeclRefExpr translateOtherConstructorDeclRefExpr(
|
||||
codeql::OtherInitializerRefExpr translateOtherConstructorDeclRefExpr(
|
||||
const swift::OtherConstructorDeclRefExpr& expr);
|
||||
codeql::UnresolvedDeclRefExpr translateUnresolvedDeclRefExpr(
|
||||
const swift::UnresolvedDeclRefExpr& expr);
|
||||
@@ -118,8 +119,7 @@ class ExprTranslator : public AstTranslatorBase<ExprTranslator> {
|
||||
codeql::RegexLiteralExpr translateRegexLiteralExpr(const swift::RegexLiteralExpr& expr);
|
||||
|
||||
private:
|
||||
void fillAbstractClosureExpr(const swift::AbstractClosureExpr& expr,
|
||||
codeql::AbstractClosureExpr& entry);
|
||||
void fillClosureExpr(const swift::AbstractClosureExpr& expr, codeql::ClosureExpr& entry);
|
||||
TrapLabel<ArgumentTag> emitArgument(const swift::Argument& arg);
|
||||
TrapLabel<KeyPathComponentTag> emitKeyPathComponent(const swift::KeyPathExpr::Component& expr);
|
||||
void fillExplicitCastExpr(const swift::ExplicitCastExpr& expr, codeql::ExplicitCastExpr& entry);
|
||||
|
||||
Reference in New Issue
Block a user