20
20
#include " swift/AST/Decl.h"
21
21
#include " swift/Basic/SourceLoc.h"
22
22
#include " llvm/ADT/SmallVector.h"
23
+ #include " llvm/Support/Casting.h"
24
+
23
25
24
26
namespace swift {
25
27
class CaseStmt ;
@@ -38,25 +40,31 @@ class SwiftASTManipulatorBase {
38
40
public:
39
41
class VariableMetadata {
40
42
public:
41
- VariableMetadata () {}
42
- virtual ~VariableMetadata () {}
43
- virtual unsigned GetType () = 0;
43
+ VariableMetadata () = default ;
44
+ virtual ~VariableMetadata () = default ;
45
+ virtual unsigned GetType () const = 0;
44
46
};
45
47
46
48
class VariableMetadataResult
47
49
: public SwiftASTManipulatorBase::VariableMetadata {
48
50
public:
49
51
virtual ~VariableMetadataResult ();
50
52
constexpr static unsigned Type () { return ' Resu' ; }
51
- unsigned GetType () override { return Type (); }
53
+ unsigned GetType () const override { return Type (); }
54
+ static bool classof (const VariableMetadata *VM) {
55
+ return VM->GetType () == Type ();
56
+ }
52
57
};
53
58
54
59
class VariableMetadataError
55
60
: public SwiftASTManipulatorBase::VariableMetadata {
56
61
public:
57
62
virtual ~VariableMetadataError ();
58
63
constexpr static unsigned Type () { return ' Erro' ; }
59
- unsigned GetType () override { return Type (); }
64
+ unsigned GetType () const override { return Type (); }
65
+ static bool classof (const VariableMetadata *VM) {
66
+ return VM->GetType () == Type ();
67
+ }
60
68
};
61
69
62
70
class VariableMetadataPersistent
@@ -67,7 +75,10 @@ class SwiftASTManipulatorBase {
67
75
: m_persistent_variable_sp(persistent_variable_sp) {}
68
76
69
77
static constexpr unsigned Type () { return ' Pers' ; }
70
- unsigned GetType () override { return Type (); }
78
+ unsigned GetType () const override { return Type (); }
79
+ static bool classof (const VariableMetadata *VM) {
80
+ return VM->GetType () == Type ();
81
+ }
71
82
lldb::ExpressionVariableSP m_persistent_variable_sp;
72
83
};
73
84
@@ -78,7 +89,10 @@ class SwiftASTManipulatorBase {
78
89
: m_variable_sp(variable_sp) {}
79
90
80
91
static constexpr unsigned Type () { return ' Vari' ; }
81
- unsigned GetType () override { return Type (); }
92
+ unsigned GetType () const override { return Type (); }
93
+ static bool classof (const VariableMetadata *VM) {
94
+ return VM->GetType () == Type ();
95
+ }
82
96
lldb::VariableSP m_variable_sp;
83
97
};
84
98
@@ -107,10 +121,6 @@ class SwiftASTManipulatorBase {
107
121
: m_type(type), m_name(name), m_var_introducer(introducer),
108
122
m_is_capture_list (is_capture_list), m_metadata(metadata) {}
109
123
110
- template <class T > bool MetadataIs () const {
111
- return (m_metadata && m_metadata->GetType () == T::Type ());
112
- }
113
-
114
124
void Print (Stream &stream) const ;
115
125
116
126
void SetType (CompilerType new_type) { m_type = new_type; }
0 commit comments