Skip to content

Commit 8ffe78c

Browse files
committed
Swift: Support TypeValueExpr and IntegerType
1 parent 1ecc352 commit 8ffe78c

32 files changed

+373
-13
lines changed

swift/extractor/infra/SwiftTagTraits.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ MAP(swift::Expr, ExprTag)
205205
MAP(swift::SingleValueStmtExpr, SingleValueStmtExprTag)
206206
MAP(swift::ExtractFunctionIsolationExpr, ExtractFunctionIsolationExprTag)
207207
MAP(swift::CurrentContextIsolationExpr, CurrentContextIsolationExprTag)
208-
MAP(swift::TypeValueExpr, void) // TODO swift 6.1
208+
MAP(swift::TypeValueExpr, TypeValueExprTag)
209209
MAP(swift::Decl, DeclTag)
210210
MAP(swift::ValueDecl, ValueDeclTag)
211211
MAP(swift::TypeDecl, TypeDeclTag)
@@ -339,7 +339,7 @@ MAP(swift::TypeBase, TypeTag)
339339
MAP(swift::PackElementType, PackElementTypeTag)
340340
MAP(swift::TypeVariableType, void) // created during type checking and only used for constraint checking
341341
MAP(swift::ErrorUnionType, void) // created during type checking and only used for constraint checking
342-
MAP(swift::IntegerType, void) // TODO swift 6.1
342+
MAP(swift::IntegerType, IntegerTypeTag)
343343
MAP(swift::SugarType, SugarTypeTag)
344344
MAP(swift::TypeAliasType, TypeAliasTypeTag)
345345
MAP(swift::SyntaxSugarType, SyntaxSugarTypeTag)

swift/extractor/mangler/SwiftMangler.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ SwiftMangledName SwiftMangler::visitGenericTypeParamType(const swift::GenericTyp
285285
if (type->isParameterPack()) {
286286
ret << "each_";
287287
}
288+
if (type->isValue()) {
289+
ret << "val_";
290+
}
288291
if (auto decl = type->getDecl()) {
289292
ret << fetch(decl);
290293
} else {

swift/extractor/translators/ExprTranslator.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -689,4 +689,10 @@ codeql::CurrentContextIsolationExpr ExprTranslator::translateCurrentContextIsola
689689
return entry;
690690
}
691691

692+
codeql::TypeValueExpr ExprTranslator::translateTypeValueExpr(const swift::TypeValueExpr& expr) {
693+
auto entry = createExprEntry(expr);
694+
entry.type_repr = dispatcher.fetchLabel(expr.getParamTypeRepr());
695+
return entry;
696+
}
697+
692698
} // namespace codeql

swift/extractor/translators/ExprTranslator.h

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class ExprTranslator : public AstTranslatorBase<ExprTranslator> {
129129
const swift::ExtractFunctionIsolationExpr& expr);
130130
codeql::CurrentContextIsolationExpr translateCurrentContextIsolationExpr(
131131
const swift::CurrentContextIsolationExpr& expr);
132+
codeql::TypeValueExpr translateTypeValueExpr(const swift::TypeValueExpr& expr);
132133

133134
private:
134135
void fillClosureExpr(const swift::AbstractClosureExpr& expr, codeql::ClosureExpr& entry);

swift/extractor/translators/TypeTranslator.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -297,4 +297,10 @@ codeql::PackExpansionType TypeTranslator::translatePackExpansionType(
297297
return entry;
298298
}
299299

300+
codeql::IntegerType TypeTranslator::translateIntegerType(const swift::IntegerType& type) {
301+
auto entry = createTypeEntry(type);
302+
entry.value = type.getDigitsText();
303+
return entry;
304+
}
305+
300306
} // namespace codeql

swift/extractor/translators/TypeTranslator.h

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class TypeTranslator : public TypeTranslatorBase<TypeTranslator> {
8282
codeql::PackType translatePackType(const swift::PackType& type);
8383
codeql::PackElementType translatePackElementType(const swift::PackElementType& type);
8484
codeql::PackExpansionType translatePackExpansionType(const swift::PackExpansionType& type);
85+
codeql::IntegerType translateIntegerType(const swift::IntegerType& type);
8586

8687
private:
8788
void fillType(const swift::TypeBase& type, codeql::Type& entry);

swift/ql/.generated.list

+16-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swift/ql/.gitattributes

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swift/ql/lib/codeql/swift/elements.qll

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swift/ql/lib/codeql/swift/elements/expr/TypeValueExpr.qll

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swift/ql/lib/codeql/swift/elements/expr/internal/TypeValueExprConstructor.qll

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swift/ql/lib/codeql/swift/elements/expr/internal/TypeValueExprImpl.qll

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swift/ql/lib/codeql/swift/elements/type/IntegerType.qll

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swift/ql/lib/codeql/swift/elements/type/internal/IntegerTypeConstructor.qll

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swift/ql/lib/codeql/swift/elements/type/internal/IntegerTypeImpl.qll

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swift/ql/lib/codeql/swift/generated/ParentChild.qll

+37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swift/ql/lib/codeql/swift/generated/Raw.qll

+24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)