@@ -237,6 +237,7 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
237
237
}
238
238
239
239
public:
240
+ LLVM_READONLY
240
241
Decl *getAsDeclOrDeclExtensionContext () {
241
242
return ParentAndKind.getInt () == ASTHierarchy::Decl ?
242
243
reinterpret_cast <Decl*>(this + 1 ) : nullptr ;
@@ -262,40 +263,50 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
262
263
}
263
264
264
265
// / isModuleContext - Return true if this is a subclass of Module.
266
+ LLVM_READONLY
265
267
bool isModuleContext () const ; // see swift/AST/Module.h
266
268
267
269
// / \returns true if this is a context with module-wide scope, e.g. a module
268
270
// / or a source file.
271
+ LLVM_READONLY
269
272
bool isModuleScopeContext () const ; // see swift/AST/Module.h
270
273
271
274
// / \returns true if this is a type context, e.g., a struct, a class, an
272
275
// / enum, a protocol, or an extension.
276
+ LLVM_READONLY
273
277
bool isTypeContext () const ;
274
278
275
279
// / \brief Determine whether this is an extension context.
280
+ LLVM_READONLY
276
281
bool isExtensionContext () const ; // see swift/AST/Decl.h
277
282
278
283
// / If this DeclContext is a NominalType declaration or an
279
284
// / extension thereof, return the NominalTypeDecl.
285
+ LLVM_READONLY
280
286
NominalTypeDecl *getAsNominalTypeOrNominalTypeExtensionContext () const ;
281
287
282
288
// / If this DeclContext is a class, or an extension on a class, return the
283
289
// / ClassDecl, otherwise return null.
290
+ LLVM_READONLY
284
291
ClassDecl *getAsClassOrClassExtensionContext () const ;
285
292
286
293
// / If this DeclContext is an enum, or an extension on an enum, return the
287
294
// / EnumDecl, otherwise return null.
295
+ LLVM_READONLY
288
296
EnumDecl *getAsEnumOrEnumExtensionContext () const ;
289
297
290
298
// / If this DeclContext is a struct, or an extension on a struct, return the
291
299
// / StructDecl, otherwise return null.
300
+ LLVM_READONLY
292
301
StructDecl *getAsStructOrStructExtensionContext () const ;
293
302
294
303
// / If this DeclContext is a protocol, or an extension on a
295
304
// / protocol, return the ProtocolDecl, otherwise return null.
305
+ LLVM_READONLY
296
306
ProtocolDecl *getAsProtocolOrProtocolExtensionContext () const ;
297
307
298
308
// / If this DeclContext is a protocol extension, return the extended protocol.
309
+ LLVM_READONLY
299
310
ProtocolDecl *getAsProtocolExtensionContext () const ;
300
311
301
312
// / \brief Retrieve the generic parameter 'Self' from a protocol or
@@ -351,6 +362,7 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
351
362
352
363
// / Returns this or the first local parent context, or nullptr if it is not
353
364
// / contained in one.
365
+ LLVM_READONLY
354
366
DeclContext *getLocalContext ();
355
367
const DeclContext *getLocalContext () const {
356
368
return const_cast <DeclContext*>(this )->getLocalContext ();
@@ -363,6 +375,7 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
363
375
// / destructors).
364
376
// /
365
377
// / \returns the innermost method, or null if there is no such method.
378
+ LLVM_READONLY
366
379
AbstractFunctionDecl *getInnermostMethodContext ();
367
380
const AbstractFunctionDecl *getInnermostMethodContext () const {
368
381
return const_cast <DeclContext*>(this )->getInnermostMethodContext ();
@@ -373,6 +386,7 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
373
386
// / This routine looks through closure, initializer, and local function
374
387
// / contexts to find the innermost type context -- nominal type or
375
388
// / extension.
389
+ LLVM_READONLY
376
390
DeclContext *getInnermostTypeContext ();
377
391
const DeclContext *getInnermostTypeContext () const {
378
392
return const_cast <DeclContext *>(this )->getInnermostTypeContext ();
@@ -382,6 +396,7 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
382
396
// /
383
397
// / This routine looks through contexts to find the innermost
384
398
// / declaration context that is itself a declaration.
399
+ LLVM_READONLY
385
400
Decl *getInnermostDeclarationDeclContext ();
386
401
const Decl *getInnermostDeclarationDeclContext () const {
387
402
return
@@ -409,15 +424,18 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
409
424
}
410
425
411
426
// / Returns the module context that contains this context.
427
+ LLVM_READONLY
412
428
ModuleDecl *getParentModule () const ;
413
429
414
430
// / Returns the module scope context that contains this context.
415
431
// /
416
432
// / This is either a \c Module or a \c FileUnit.
433
+ LLVM_READONLY
417
434
DeclContext *getModuleScopeContext () const ;
418
435
419
436
// / Returns the source file that contains this context, or null if this
420
437
// / is not within a source file.
438
+ LLVM_READONLY
421
439
SourceFile *getParentSourceFile () const ;
422
440
423
441
// / Determine whether this declaration context is generic, meaning that it or
@@ -476,6 +494,7 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
476
494
477
495
// / Return the ASTContext for a specified DeclContext by
478
496
// / walking up to the enclosing module and returning its ASTContext.
497
+ LLVM_READONLY
479
498
ASTContext &getASTContext () const ;
480
499
481
500
// / Retrieve the set of protocols whose conformances will be
0 commit comments