@@ -44,17 +44,17 @@ AvailabilityScope::AvailabilityScope(ASTContext &Ctx, IntroNode Node,
44
44
const AvailabilityContext Info)
45
45
: Node(Node), SrcRange(SrcRange), AvailabilityInfo(Info) {
46
46
if (Parent) {
47
- assert (SrcRange.isValid ());
47
+ ASSERT (SrcRange.isValid ());
48
48
Parent->addChild (this , Ctx);
49
- assert (Info.isContainedIn (Parent->getAvailabilityContext ()));
49
+ DEBUG_ASSERT (Info.isContainedIn (Parent->getAvailabilityContext ()));
50
50
}
51
51
Ctx.addDestructorCleanup (Children);
52
52
}
53
53
54
54
AvailabilityScope *
55
55
AvailabilityScope::createForSourceFile (SourceFile *SF,
56
56
const AvailabilityContext Info) {
57
- assert (SF);
57
+ ASSERT (SF);
58
58
59
59
ASTContext &Ctx = SF->getASTContext ();
60
60
@@ -93,25 +93,25 @@ AvailabilityScope::createForSourceFile(SourceFile *SF,
93
93
AvailabilityScope *AvailabilityScope::createForDecl (
94
94
ASTContext &Ctx, Decl *D, AvailabilityScope *Parent,
95
95
const AvailabilityContext Info, SourceRange SrcRange) {
96
- assert (D);
97
- assert (Parent);
96
+ ASSERT (D);
97
+ ASSERT (Parent);
98
98
return new (Ctx) AvailabilityScope (Ctx, D, Parent, SrcRange, Info);
99
99
}
100
100
101
101
AvailabilityScope *AvailabilityScope::createForDeclImplicit (
102
102
ASTContext &Ctx, Decl *D, AvailabilityScope *Parent,
103
103
const AvailabilityContext Info, SourceRange SrcRange) {
104
- assert (D);
105
- assert (Parent);
104
+ ASSERT (D);
105
+ ASSERT (Parent);
106
106
return new (Ctx) AvailabilityScope (Ctx, IntroNode (D, Reason::DeclImplicit),
107
107
Parent, SrcRange, Info);
108
108
}
109
109
110
110
AvailabilityScope *AvailabilityScope::createForIfStmtThen (
111
111
ASTContext &Ctx, IfStmt *S, const DeclContext *DC,
112
112
AvailabilityScope *Parent, const AvailabilityContext Info) {
113
- assert (S);
114
- assert (Parent);
113
+ ASSERT (S);
114
+ ASSERT (Parent);
115
115
return new (Ctx)
116
116
AvailabilityScope (Ctx, IntroNode (S, DC, /* IsThen=*/ true ), Parent,
117
117
S->getThenStmt ()->getSourceRange (), Info);
@@ -120,8 +120,8 @@ AvailabilityScope *AvailabilityScope::createForIfStmtThen(
120
120
AvailabilityScope *AvailabilityScope::createForIfStmtElse (
121
121
ASTContext &Ctx, IfStmt *S, const DeclContext *DC,
122
122
AvailabilityScope *Parent, const AvailabilityContext Info) {
123
- assert (S);
124
- assert (Parent);
123
+ ASSERT (S);
124
+ ASSERT (Parent);
125
125
return new (Ctx)
126
126
AvailabilityScope (Ctx, IntroNode (S, DC, /* IsThen=*/ false ), Parent,
127
127
S->getElseStmt ()->getSourceRange (), Info);
@@ -131,8 +131,8 @@ AvailabilityScope *AvailabilityScope::createForConditionFollowingQuery(
131
131
ASTContext &Ctx, PoundAvailableInfo *PAI,
132
132
const StmtConditionElement &LastElement, const DeclContext *DC,
133
133
AvailabilityScope *Parent, const AvailabilityContext Info) {
134
- assert (PAI);
135
- assert (Parent);
134
+ ASSERT (PAI);
135
+ ASSERT (Parent);
136
136
SourceRange Range (PAI->getEndLoc (), LastElement.getEndLoc ());
137
137
return new (Ctx)
138
138
AvailabilityScope (Ctx, IntroNode (PAI, DC), Parent, Range, Info);
@@ -142,9 +142,9 @@ AvailabilityScope *AvailabilityScope::createForGuardStmtFallthrough(
142
142
ASTContext &Ctx, GuardStmt *RS, BraceStmt *ContainingBraceStmt,
143
143
const DeclContext *DC, AvailabilityScope *Parent,
144
144
const AvailabilityContext Info) {
145
- assert (RS);
146
- assert (ContainingBraceStmt);
147
- assert (Parent);
145
+ ASSERT (RS);
146
+ ASSERT (ContainingBraceStmt);
147
+ ASSERT (Parent);
148
148
SourceRange Range (RS->getEndLoc (), ContainingBraceStmt->getEndLoc ());
149
149
return new (Ctx) AvailabilityScope (
150
150
Ctx, IntroNode (RS, DC, /* IsFallthrough=*/ true ), Parent, Range, Info);
@@ -153,8 +153,8 @@ AvailabilityScope *AvailabilityScope::createForGuardStmtFallthrough(
153
153
AvailabilityScope *AvailabilityScope::createForGuardStmtElse (
154
154
ASTContext &Ctx, GuardStmt *RS, const DeclContext *DC,
155
155
AvailabilityScope *Parent, const AvailabilityContext Info) {
156
- assert (RS);
157
- assert (Parent);
156
+ ASSERT (RS);
157
+ ASSERT (Parent);
158
158
return new (Ctx)
159
159
AvailabilityScope (Ctx, IntroNode (RS, DC, /* IsFallthrough=*/ false ), Parent,
160
160
RS->getBody ()->getSourceRange (), Info);
@@ -163,14 +163,15 @@ AvailabilityScope *AvailabilityScope::createForGuardStmtElse(
163
163
AvailabilityScope *AvailabilityScope::createForWhileStmtBody (
164
164
ASTContext &Ctx, WhileStmt *S, const DeclContext *DC,
165
165
AvailabilityScope *Parent, const AvailabilityContext Info) {
166
- assert (S);
167
- assert (Parent);
166
+ ASSERT (S);
167
+ ASSERT (Parent);
168
168
return new (Ctx) AvailabilityScope (Ctx, IntroNode (S, DC), Parent,
169
169
S->getBody ()->getSourceRange (), Info);
170
170
}
171
171
172
172
void AvailabilityScope::addChild (AvailabilityScope *Child, ASTContext &Ctx) {
173
- assert (Child->getSourceRange ().isValid ());
173
+ bool validSourceRange = Child->getSourceRange ().isValid ();
174
+ ASSERT (validSourceRange);
174
175
175
176
// Handle the first child.
176
177
if (Children.empty ()) {
@@ -200,14 +201,14 @@ void AvailabilityScope::addChild(AvailabilityScope *Child, ASTContext &Ctx) {
200
201
201
202
AvailabilityScope *
202
203
AvailabilityScope::findMostRefinedSubContext (SourceLoc Loc, ASTContext &Ctx) {
203
- assert (Loc.isValid ());
204
+ DEBUG_ASSERT (Loc.isValid ());
204
205
205
206
if (SrcRange.isValid () && !Ctx.SourceMgr .containsTokenLoc (SrcRange, Loc))
206
207
return nullptr ;
207
208
208
209
(void )evaluateOrDefault (Ctx.evaluator ,
209
210
ExpandChildAvailabilityScopesRequest{this }, {});
210
- assert (!getNeedsExpansion ());
211
+ DEBUG_ASSERT (!getNeedsExpansion ());
211
212
212
213
// Do a binary search to find the first child with a source range that
213
214
// ends after the given location.
0 commit comments