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 {
7878 waitingForNewLabel = e;
7979 visit (e);
8080 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 >) {
8282 attachLocation (e, *l);
8383 }
8484 return *l;
@@ -285,8 +285,9 @@ class SwiftDispatcher {
285285 return realPath.str ().str ();
286286 }
287287
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
290291 virtual void visit (swift::Decl* decl) = 0;
291292 virtual void visit (const swift::IfConfigClause* clause) = 0;
292293 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
667667 dispatcher_.emit (LookupExprMembersTrap{label, declLabel});
668668 }
669669}
670+
670671codeql::UnresolvedPatternExpr ExprVisitor::translateUnresolvedPatternExpr (
671672 swift::UnresolvedPatternExpr& expr) {
672673 auto entry = dispatcher_.createEntry (expr);
673674 entry.sub_pattern = dispatcher_.fetchLabel (expr.getSubPattern ());
674675 return entry;
675676}
676-
677677} // namespace codeql
Original file line number Diff line number Diff line change @@ -84,10 +84,12 @@ class ExprVisitor : public AstVisitorBase<ExprVisitor> {
8484 codeql::BridgeFromObjCExpr translateBridgeFromObjCExpr (const swift::BridgeFromObjCExpr& expr);
8585 codeql::DotSelfExpr translateDotSelfExpr (const swift::DotSelfExpr& expr);
8686 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*`
8990 // * `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`
9193 codeql::UnresolvedPatternExpr translateUnresolvedPatternExpr (swift::UnresolvedPatternExpr& expr);
9294
9395 private:
Original file line number Diff line number Diff line change 11#include " swift/extractor/visitors/TypeVisitor.h"
2+
23namespace codeql {
34void TypeVisitor::visit (swift::TypeBase* type) {
45 TypeVisitorBase<TypeVisitor>::visit (type);
@@ -367,6 +368,7 @@ codeql::BuiltinVectorType TypeVisitor::translateBuiltinVectorType(
367368 const swift::BuiltinVectorType& type) {
368369 return createTypeEntry (type);
369370}
371+
370372codeql::OpenedArchetypeType TypeVisitor::translateOpenedArchetypeType (
371373 const swift::OpenedArchetypeType& type) {
372374 auto entry = createTypeEntry (type);
You can’t perform that action at this time.
0 commit comments