File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -36,9 +36,10 @@ class ProfileCounterRef final {
36
36
public:
37
37
enum class Kind : uint8_t {
38
38
// / References an ASTNode.
39
- // TODO: This is the currently the only kind, but it will be expanded in
40
- // the future for e.g top-level entry and error branches.
41
- Node
39
+ Node,
40
+
41
+ // / References the error branch for an apply or access.
42
+ ErrorBranch
42
43
};
43
44
44
45
private:
@@ -56,6 +57,12 @@ class ProfileCounterRef final {
56
57
return ProfileCounterRef (node, Kind::Node);
57
58
}
58
59
60
+ // / A profile counter that is associated with the error branch of a particular
61
+ // / error-throwing AST node.
62
+ static ProfileCounterRef errorBranchOf (ASTNode node) {
63
+ return ProfileCounterRef (node, Kind::ErrorBranch);
64
+ }
65
+
59
66
// / Retrieve the corresponding location of the counter.
60
67
SILLocation getLocation () const ;
61
68
Original file line number Diff line number Diff line change @@ -173,7 +173,15 @@ SILLocation ProfileCounterRef::getLocation() const {
173
173
174
174
void ProfileCounterRef::dumpSimple (raw_ostream &OS) const {
175
175
switch (RefKind) {
176
- case Kind::Node: {
176
+ case Kind::Node:
177
+ break ;
178
+ case Kind::ErrorBranch:
179
+ OS << " error branch of: " ;
180
+ break ;
181
+ }
182
+ switch (RefKind) {
183
+ case Kind::Node:
184
+ case Kind::ErrorBranch: {
177
185
OS << Node.getOpaqueValue () << " " ;
178
186
if (auto *D = Node.dyn_cast <Decl *>()) {
179
187
OS << Decl::getKindName (D->getKind ());
@@ -190,6 +198,11 @@ void ProfileCounterRef::dump(raw_ostream &OS) const {
190
198
switch (RefKind) {
191
199
case Kind::Node:
192
200
Node.dump (OS);
201
+ break ;
202
+ case Kind::ErrorBranch:
203
+ OS << " error branch of:\n " ;
204
+ Node.dump (OS.indent (2 ));
205
+ break ;
193
206
}
194
207
}
195
208
You can’t perform that action at this time.
0 commit comments