File tree Expand file tree Collapse file tree 4 files changed +12
-7
lines changed Expand file tree Collapse file tree 4 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ class SwiftDispatcher {
78
78
waitingForNewLabel = e;
79
79
visit (e);
80
80
if (auto l = store.get (e)) {
81
- if constexpr (std::is_base_of_v<LocatableTag, TrapTagOf<E> >) {
81
+ if constexpr (! std::is_base_of_v<swift::TypeBase, E >) {
82
82
attachLocation (e, *l);
83
83
}
84
84
return *l;
@@ -285,8 +285,9 @@ class SwiftDispatcher {
285
285
return realPath.str ().str ();
286
286
}
287
287
288
- // TODO: The following methods are supposed to redirect TRAP emission to correpsonding visitors,
289
- // which are to be introduced in follow-up PRs
288
+ // TODO: for const correctness these should consistently be `const` (and maybe const references
289
+ // as we don't expect `nullptr` here. However `swift::ASTVisitor` and `swift::TypeVisitor` do not
290
+ // accept const pointers
290
291
virtual void visit (swift::Decl* decl) = 0;
291
292
virtual void visit (const swift::IfConfigClause* clause) = 0;
292
293
virtual void visit (swift::Stmt* stmt) = 0;
Original file line number Diff line number Diff line change @@ -667,11 +667,11 @@ void ExprVisitor::emitLookupExpr(const swift::LookupExpr* expr, TrapLabel<Lookup
667
667
dispatcher_.emit (LookupExprMembersTrap{label, declLabel});
668
668
}
669
669
}
670
+
670
671
codeql::UnresolvedPatternExpr ExprVisitor::translateUnresolvedPatternExpr (
671
672
swift::UnresolvedPatternExpr& expr) {
672
673
auto entry = dispatcher_.createEntry (expr);
673
674
entry.sub_pattern = dispatcher_.fetchLabel (expr.getSubPattern ());
674
675
return entry;
675
676
}
676
-
677
677
} // namespace codeql
Original file line number Diff line number Diff line change @@ -84,10 +84,12 @@ class ExprVisitor : public AstVisitorBase<ExprVisitor> {
84
84
codeql::BridgeFromObjCExpr translateBridgeFromObjCExpr (const swift::BridgeFromObjCExpr& expr);
85
85
codeql::DotSelfExpr translateDotSelfExpr (const swift::DotSelfExpr& expr);
86
86
codeql::ErrorExpr translateErrorExpr (const swift::ErrorExpr& expr);
87
- // following requires non-const because:
88
- // * `swift::UnresolvedPatternExpr::getSubPattern` gives `const swift::Pattern*` on const refs
87
+ // The following function requires a non-const parameter because:
88
+ // * `swift::UnresolvedPatternExpr::getSubPattern` has a `const`-qualified overload returning
89
+ // `const swift::Pattern*`
89
90
// * `swift::ASTVisitor` only visits non-const pointers
90
- // either we accept this, or we fix constness by providing our own const visiting in VisitorBase
91
+ // either we accept this, or we fix constness, e.g. by providing `visit` on `const` pointers
92
+ // in `VisitorBase`, or by doing a `const_cast` in `SwifDispatcher::fetchLabel`
91
93
codeql::UnresolvedPatternExpr translateUnresolvedPatternExpr (swift::UnresolvedPatternExpr& expr);
92
94
93
95
private:
Original file line number Diff line number Diff line change 1
1
#include " swift/extractor/visitors/TypeVisitor.h"
2
+
2
3
namespace codeql {
3
4
void TypeVisitor::visit (swift::TypeBase* type) {
4
5
TypeVisitorBase<TypeVisitor>::visit (type);
@@ -367,6 +368,7 @@ codeql::BuiltinVectorType TypeVisitor::translateBuiltinVectorType(
367
368
const swift::BuiltinVectorType& type) {
368
369
return createTypeEntry (type);
369
370
}
371
+
370
372
codeql::OpenedArchetypeType TypeVisitor::translateOpenedArchetypeType (
371
373
const swift::OpenedArchetypeType& type) {
372
374
auto entry = createTypeEntry (type);
You can’t perform that action at this time.
0 commit comments