File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -1568,6 +1568,8 @@ class GenericContext : private _GenericContext, public DeclContext {
1568
1568
// / Retrieve the position of any where clause for this context's
1569
1569
// / generic parameters.
1570
1570
SourceRange getGenericTrailingWhereClauseSourceRange () const ;
1571
+
1572
+ static bool classof (const Decl *D);
1571
1573
};
1572
1574
static_assert (sizeof (_GenericContext) + sizeof (DeclContext) ==
1573
1575
sizeof (GenericContext), " Please add fields to _GenericContext" );
@@ -9589,6 +9591,16 @@ inline bool DeclContext::classof(const Decl *D) {
9589
9591
}
9590
9592
}
9591
9593
9594
+ inline bool GenericContext::classof (const Decl *D) {
9595
+ switch (D->getKind ()) { //
9596
+ default : return false ;
9597
+ #define DECL (ID, PARENT ) // See previous line
9598
+ #define GENERIC_DECL (ID, PARENT ) \
9599
+ case DeclKind::ID: return true ;
9600
+ #include " swift/AST/DeclNodes.def"
9601
+ }
9602
+ }
9603
+
9592
9604
inline DeclContext *DeclContext::castDeclToDeclContext (const Decl *D) {
9593
9605
// XXX -- ModuleDecl is not defined in Decl.h, but because DeclContexts
9594
9606
// preface decls in memory, any DeclContext type will due.
Original file line number Diff line number Diff line change @@ -1013,6 +1013,20 @@ namespace llvm {
1013
1013
}
1014
1014
};
1015
1015
1016
+ template <class FromTy >
1017
+ struct CastInfo <::swift::GenericContext, FromTy, std::enable_if_t <is_simple_type<FromTy>::value>>
1018
+ : public CastIsPossible<::swift::GenericContext, FromTy>,
1019
+ public DefaultDoCastIfPossible<::swift::GenericContext *, FromTy,
1020
+ CastInfo<::swift::GenericContext, FromTy>> {
1021
+ static inline ::swift::GenericContext *castFailed () { return nullptr ; }
1022
+
1023
+ static inline ::swift::GenericContext *doCast (const FromTy &val) {
1024
+ auto *genCtxt = val->getAsGenericContext ();
1025
+ assert (genCtxt);
1026
+ return const_cast <::swift::GenericContext *>(genCtxt);
1027
+ }
1028
+ };
1029
+
1016
1030
template <class FromTy >
1017
1031
struct CastInfo <::swift::IterableDeclContext, FromTy, std::enable_if_t <is_simple_type<FromTy>::value>>
1018
1032
: public CastIsPossible<::swift::IterableDeclContext, FromTy>,
You can’t perform that action at this time.
0 commit comments