@@ -137,13 +137,16 @@ RawComment Decl::getRawComment(bool SerializedOK) const {
137
137
138
138
// Check the cache in ASTContext.
139
139
auto &Context = getASTContext ();
140
- if (Optional<RawComment> RC = Context.getRawComment (this ))
141
- return RC.getValue ();
140
+ if (Optional<std::pair<RawComment, bool >> RC = Context.getRawComment (this )) {
141
+ auto P = RC.getValue ();
142
+ if (!SerializedOK || P.second )
143
+ return P.first ;
144
+ }
142
145
143
146
// Check the declaration itself.
144
147
if (auto *Attr = getAttrs ().getAttribute <RawDocCommentAttr>()) {
145
148
RawComment Result = toRawComment (Context, Attr->getCommentRange ());
146
- Context.setRawComment (this , Result);
149
+ Context.setRawComment (this , Result, true );
147
150
return Result;
148
151
}
149
152
@@ -172,15 +175,15 @@ RawComment Decl::getRawComment(bool SerializedOK) const {
172
175
auto RC = RawComment (Context.AllocateCopy (llvm::makeArrayRef (SRCs)));
173
176
174
177
if (!RC.isEmpty ()) {
175
- Context.setRawComment (this , RC);
178
+ Context.setRawComment (this , RC, true );
176
179
return RC;
177
180
}
178
181
}
179
182
}
180
183
}
181
184
182
185
if (Optional<CommentInfo> C = Unit->getCommentForDecl (this )) {
183
- Context.setRawComment (this , C->Raw );
186
+ Context.setRawComment (this , C->Raw , false );
184
187
return C->Raw ;
185
188
}
186
189
0 commit comments