clang 22.0.0git
Scope.h
Go to the documentation of this file.
1//===- Scope.h - Scope interface --------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the Scope interface.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_SEMA_SCOPE_H
14#define LLVM_CLANG_SEMA_SCOPE_H
15
16#include "clang/AST/Decl.h"
18#include "llvm/ADT/PointerIntPair.h"
19#include "llvm/ADT/SmallPtrSet.h"
20#include "llvm/ADT/SmallVector.h"
21#include "llvm/ADT/iterator_range.h"
22#include <cassert>
23#include <optional>
24
25namespace llvm {
26
27class raw_ostream;
28
29} // namespace llvm
30
31namespace clang {
32
33class Decl;
34class DeclContext;
35class UsingDirectiveDecl;
36class VarDecl;
37
38/// Scope - A scope is a transient data structure that is used while parsing the
39/// program. It assists with resolving identifiers to the appropriate
40/// declaration.
41class Scope {
42public:
43 /// ScopeFlags - These are bitfields that are or'd together when creating a
44 /// scope, which defines the sorts of things the scope contains.
46 // A bitfield value representing no scopes.
48
49 /// This indicates that the scope corresponds to a function, which
50 /// means that labels are set here.
51 FnScope = 0x01,
52
53 /// This is a while, do, switch, for, etc that can have break
54 /// statements embedded into it.
55 BreakScope = 0x02,
56
57 /// This is a while, do, for, which can have continue statements
58 /// embedded into it.
60
61 /// This is a scope that can contain a declaration. Some scopes
62 /// just contain loop constructs but don't contain decls.
63 DeclScope = 0x08,
64
65 /// The controlling scope in a if/switch/while/for statement.
67
68 /// The scope of a struct/union/class definition.
69 ClassScope = 0x20,
70
71 /// This is a scope that corresponds to a block/closure object.
72 /// Blocks serve as top-level scopes for some objects like labels, they
73 /// also prevent things like break and continue. BlockScopes always have
74 /// the FnScope and DeclScope flags set as well.
75 BlockScope = 0x40,
76
77 /// This is a scope that corresponds to the
78 /// template parameters of a C++ template. Template parameter
79 /// scope starts at the 'template' keyword and ends when the
80 /// template declaration ends.
82
83 /// This is a scope that corresponds to the
84 /// parameters within a function prototype.
86
87 /// This is a scope that corresponds to the parameters within
88 /// a function prototype for a function declaration (as opposed to any
89 /// other kind of function declarator). Always has FunctionPrototypeScope
90 /// set as well.
92
93 /// This is a scope that corresponds to the Objective-C
94 /// \@catch statement.
95 AtCatchScope = 0x400,
96
97 /// This scope corresponds to an Objective-C method body.
98 /// It always has FnScope and DeclScope set as well.
100
101 /// This is a scope that corresponds to a switch statement.
102 SwitchScope = 0x1000,
103
104 /// This is the scope of a C++ try statement.
105 TryScope = 0x2000,
106
107 /// This is the scope for a function-level C++ try or catch scope.
109
110 /// This is the scope of OpenMP executable directive.
112
113 /// This is the scope of some OpenMP loop directive.
115
116 /// This is the scope of some OpenMP simd directive.
117 /// For example, it is used for 'omp simd', 'omp for simd'.
118 /// This flag is propagated to children scopes.
120
121 /// This scope corresponds to an enum.
122 EnumScope = 0x40000,
123
124 /// This scope corresponds to an SEH try.
125 SEHTryScope = 0x80000,
126
127 /// This scope corresponds to an SEH except.
128 SEHExceptScope = 0x100000,
129
130 /// We are currently in the filter expression of an SEH except block.
131 SEHFilterScope = 0x200000,
132
133 /// This is a compound statement scope.
135
136 /// We are between inheritance colon and the real class/struct definition
137 /// scope.
139
140 /// This is the scope of a C++ catch statement.
141 CatchScope = 0x1000000,
142
143 /// This is a scope in which a condition variable is currently being
144 /// parsed. If such a scope is a ContinueScope, it's invalid to jump to the
145 /// continue block from here.
146 ConditionVarScope = 0x2000000,
147
148 /// This is a scope of some OpenMP directive with
149 /// order clause which specifies concurrent
151 /// This is the scope for a lambda, after the lambda introducer.
152 /// Lambdas need two FunctionPrototypeScope scopes (because there is a
153 /// template scope in between), the outer scope does not increase the
154 /// depth of recursion.
155 LambdaScope = 0x8000000,
156 /// This is the scope of an OpenACC Compute Construct, which restricts
157 /// jumping into/out of it. We also use this to represent 'combined'
158 /// constructs, since they have the same behavior.
160
161 /// This is the scope of an OpenACC Loop/Combined construct, which is used
162 /// to determine whether a 'cache' construct variable reference is legal.
164
165 /// This is a scope of type alias declaration.
166 TypeAliasScope = 0x40000000,
167
168 /// This is a scope of friend declaration.
169 FriendScope = 0x80000000,
170 };
171
172private:
173 /// The parent scope for this scope. This is null for the translation-unit
174 /// scope.
175 Scope *AnyParent;
176
177 /// Flags - This contains a set of ScopeFlags, which indicates how the scope
178 /// interrelates with other control flow statements.
179 unsigned Flags;
180
181 /// Depth - This is the depth of this scope. The translation-unit scope has
182 /// depth 0.
183 unsigned short Depth;
184
185 /// Declarations with static linkage are mangled with the number of
186 /// scopes seen as a component.
187 unsigned short MSLastManglingNumber;
188
189 unsigned short MSCurManglingNumber;
190
191 /// PrototypeDepth - This is the number of function prototype scopes
192 /// enclosing this scope, including this scope.
193 unsigned short PrototypeDepth;
194
195 /// PrototypeIndex - This is the number of parameters currently
196 /// declared in this scope.
197 unsigned short PrototypeIndex;
198
199 /// FnParent - If this scope has a parent scope that is a function body, this
200 /// pointer is non-null and points to it. This is used for label processing.
201 Scope *FnParent;
202 Scope *MSLastManglingParent;
203
204 /// BreakParent/ContinueParent - This is a direct link to the innermost
205 /// BreakScope/ContinueScope which contains the contents of this scope
206 /// for control flow purposes (and might be this scope itself), or null
207 /// if there is no such scope.
208 Scope *BreakParent, *ContinueParent;
209
210 /// BlockParent - This is a direct link to the immediately containing
211 /// BlockScope if this scope is not one, or null if there is none.
212 Scope *BlockParent;
213
214 /// TemplateParamParent - This is a direct link to the
215 /// immediately containing template parameter scope. In the
216 /// case of nested templates, template parameter scopes can have
217 /// other template parameter scopes as parents.
218 Scope *TemplateParamParent;
219
220 /// DeclScopeParent - This is a direct link to the immediately containing
221 /// DeclScope, i.e. scope which can contain declarations.
222 Scope *DeclParent;
223
224 /// DeclsInScope - This keeps track of all declarations in this scope. When
225 /// the declaration is added to the scope, it is set as the current
226 /// declaration for the identifier in the IdentifierTable. When the scope is
227 /// popped, these declarations are removed from the IdentifierTable's notion
228 /// of current declaration. It is up to the current Action implementation to
229 /// implement these semantics.
230 using DeclSetTy = llvm::SmallPtrSet<Decl *, 32>;
231 DeclSetTy DeclsInScope;
232
233 /// The DeclContext with which this scope is associated. For
234 /// example, the entity of a class scope is the class itself, the
235 /// entity of a function scope is a function, etc.
236 DeclContext *Entity;
237
238 using UsingDirectivesTy = SmallVector<UsingDirectiveDecl *, 2>;
239 UsingDirectivesTy UsingDirectives;
240
241 /// Used to determine if errors occurred in this scope.
242 DiagnosticErrorTrap ErrorTrap;
243
244 /// A single NRVO candidate variable in this scope.
245 /// There are three possible values:
246 /// 1) pointer to VarDecl that denotes NRVO candidate itself.
247 /// 2) nullptr value means that NRVO is not allowed in this scope
248 /// (e.g. return a function parameter).
249 /// 3) std::nullopt value means that there is no NRVO candidate in this scope
250 /// (i.e. there are no return statements in this scope).
251 std::optional<VarDecl *> NRVO;
252
253 /// Represents return slots for NRVO candidates in the current scope.
254 /// If a variable is present in this set, it means that a return slot is
255 /// available for this variable in the current scope.
257
258 /// If this scope belongs to a loop or switch statement, the label that
259 /// directly precedes it, if any.
260 LabelDecl *PrecedingLabel;
261
262 void setFlags(Scope *Parent, unsigned F);
263
264public:
266 : ErrorTrap(Diag) {
268 }
269
270 /// getFlags - Return the flags for this scope.
271 unsigned getFlags() const { return Flags; }
272
273 void setFlags(unsigned F) { setFlags(getParent(), F); }
274
275 /// Get the label that precedes this scope.
276 LabelDecl *getPrecedingLabel() const { return PrecedingLabel; }
278 assert((Flags & BreakScope || Flags & ContinueScope) &&
279 "not a loop or switch");
280 PrecedingLabel = LD;
281 }
282
283 /// isBlockScope - Return true if this scope correspond to a closure.
284 bool isBlockScope() const { return Flags & BlockScope; }
285
286 /// getParent - Return the scope that this is nested in.
287 const Scope *getParent() const { return AnyParent; }
288 Scope *getParent() { return AnyParent; }
289
290 /// getFnParent - Return the closest scope that is a function body.
291 const Scope *getFnParent() const { return FnParent; }
292 Scope *getFnParent() { return FnParent; }
293
295 return MSLastManglingParent;
296 }
297 Scope *getMSLastManglingParent() { return MSLastManglingParent; }
298
299 /// getContinueParent - Return the closest scope that a continue statement
300 /// would be affected by.
302 return ContinueParent;
303 }
304
305 const Scope *getContinueParent() const {
306 return const_cast<Scope*>(this)->getContinueParent();
307 }
308
309 // Set whether we're in the scope of a condition variable, where 'continue'
310 // is disallowed despite being a continue scope.
311 void setIsConditionVarScope(bool InConditionVarScope) {
312 Flags = (Flags & ~ConditionVarScope) |
313 (InConditionVarScope ? ConditionVarScope : NoScope);
314 }
315
316 bool isConditionVarScope() const {
317 return Flags & ConditionVarScope;
318 }
319
320 /// getBreakParent - Return the closest scope that a break statement
321 /// would be affected by.
323 return BreakParent;
324 }
325 const Scope *getBreakParent() const {
326 return const_cast<Scope*>(this)->getBreakParent();
327 }
328
329 Scope *getBlockParent() { return BlockParent; }
330 const Scope *getBlockParent() const { return BlockParent; }
331
332 Scope *getTemplateParamParent() { return TemplateParamParent; }
333 const Scope *getTemplateParamParent() const { return TemplateParamParent; }
334
335 Scope *getDeclParent() { return DeclParent; }
336 const Scope *getDeclParent() const { return DeclParent; }
337
338 /// Returns the depth of this scope. The translation-unit has scope depth 0.
339 unsigned getDepth() const { return Depth; }
340
341 /// Returns the number of function prototype scopes in this scope
342 /// chain.
343 unsigned getFunctionPrototypeDepth() const {
344 return PrototypeDepth;
345 }
346
347 /// Return the number of parameters declared in this function
348 /// prototype, increasing it by one for the next call.
350 assert(isFunctionPrototypeScope());
351 return PrototypeIndex++;
352 }
353
354 using decl_range = llvm::iterator_range<DeclSetTy::iterator>;
355
357 return decl_range(DeclsInScope.begin(), DeclsInScope.end());
358 }
359
360 bool decl_empty() const { return DeclsInScope.empty(); }
361
362 void AddDecl(Decl *D) {
363 if (auto *VD = dyn_cast<VarDecl>(D))
364 if (!isa<ParmVarDecl>(VD))
365 ReturnSlots.insert(VD);
366
367 DeclsInScope.insert(D);
368 }
369
370 void RemoveDecl(Decl *D) { DeclsInScope.erase(D); }
371
373 if (Scope *MSLMP = getMSLastManglingParent()) {
374 MSLMP->MSLastManglingNumber += 1;
375 MSCurManglingNumber += 1;
376 }
377 }
378
380 if (Scope *MSLMP = getMSLastManglingParent()) {
381 MSLMP->MSLastManglingNumber -= 1;
382 MSCurManglingNumber -= 1;
383 }
384 }
385
386 unsigned getMSLastManglingNumber() const {
387 if (const Scope *MSLMP = getMSLastManglingParent())
388 return MSLMP->MSLastManglingNumber;
389 return 1;
390 }
391
392 unsigned getMSCurManglingNumber() const {
393 return MSCurManglingNumber;
394 }
395
396 /// isDeclScope - Return true if this is the scope that the specified decl is
397 /// declared in.
398 bool isDeclScope(const Decl *D) const { return DeclsInScope.contains(D); }
399
400 /// Get the entity corresponding to this scope.
402 return isTemplateParamScope() ? nullptr : Entity;
403 }
404
405 /// Get the DeclContext in which to continue unqualified lookup after a
406 /// lookup in this scope.
407 DeclContext *getLookupEntity() const { return Entity; }
408
410 assert(!isTemplateParamScope() &&
411 "entity associated with template param scope");
412 Entity = E;
413 }
414 void setLookupEntity(DeclContext *E) { Entity = E; }
415
416 /// Determine whether any unrecoverable errors have occurred within this
417 /// scope. Note that this may return false even if the scope contains invalid
418 /// declarations or statements, if the errors for those invalid constructs
419 /// were suppressed because some prior invalid construct was referenced.
421 return ErrorTrap.hasUnrecoverableErrorOccurred();
422 }
423
424 /// isFunctionScope() - Return true if this scope is a function scope.
425 bool isFunctionScope() const { return getFlags() & Scope::FnScope; }
426
427 /// isClassScope - Return true if this scope is a class/struct/union scope.
428 bool isClassScope() const { return getFlags() & Scope::ClassScope; }
429
430 /// Determines whether this scope is between inheritance colon and the real
431 /// class/struct definition.
434 }
435
436 /// isInCXXInlineMethodScope - Return true if this scope is a C++ inline
437 /// method scope or is inside one.
439 if (const Scope *FnS = getFnParent()) {
440 assert(FnS->getParent() && "TUScope not created?");
441 return FnS->getParent()->isClassScope();
442 }
443 return false;
444 }
445
446 /// isInObjcMethodScope - Return true if this scope is, or is contained, in an
447 /// C function body.
448 bool isInCFunctionScope() const {
449 for (const Scope *S = this; S; S = S->getParent()) {
450 if (S->isFunctionScope())
451 return true;
452 }
453
454 return false;
455 }
456
457 /// isInObjcMethodScope - Return true if this scope is, or is contained in, an
458 /// Objective-C method body. Note that this method is not constant time.
459 bool isInObjcMethodScope() const {
460 for (const Scope *S = this; S; S = S->getParent()) {
461 // If this scope is an objc method scope, then we succeed.
462 if (S->getFlags() & ObjCMethodScope)
463 return true;
464 }
465 return false;
466 }
467
468 /// isInObjcMethodOuterScope - Return true if this scope is an
469 /// Objective-C method outer most body.
471 if (const Scope *S = this) {
472 // If this scope is an objc method scope, then we succeed.
473 if (S->getFlags() & ObjCMethodScope)
474 return true;
475 }
476 return false;
477 }
478
479 /// isTemplateParamScope - Return true if this scope is a C++
480 /// template parameter scope.
481 bool isTemplateParamScope() const {
483 }
484
485 /// isFunctionPrototypeScope - Return true if this scope is a
486 /// function prototype scope.
489 }
490
491 /// isFunctionDeclarationScope - Return true if this scope is a
492 /// function prototype scope.
495 }
496
497 /// isAtCatchScope - Return true if this scope is \@catch.
498 bool isAtCatchScope() const {
499 return getFlags() & Scope::AtCatchScope;
500 }
501
502 /// isCatchScope - Return true if this scope is a C++ catch statement.
503 bool isCatchScope() const { return getFlags() & Scope::CatchScope; }
504
505 /// isSwitchScope - Return true if this scope is a switch scope.
506 bool isSwitchScope() const {
507 for (const Scope *S = this; S; S = S->getParent()) {
508 if (S->getFlags() & Scope::SwitchScope)
509 return true;
510 else if (S->getFlags() & (Scope::FnScope | Scope::ClassScope |
514 return false;
515 }
516 return false;
517 }
518
519 /// Return true if this scope is a loop.
520 bool isLoopScope() const {
521 // 'switch' is the only loop that is not a 'break' scope as well, so we can
522 // just check BreakScope and not SwitchScope.
523 return (getFlags() & Scope::BreakScope) &&
525 }
526
527 /// Determines whether this scope is the OpenMP directive scope
530 }
531
532 /// Determine whether this scope is some OpenMP loop directive scope
533 /// (for example, 'omp for', 'omp simd').
536 assert(isOpenMPDirectiveScope() &&
537 "OpenMP loop directive scope is not a directive scope");
538 return true;
539 }
540 return false;
541 }
542
543 /// Determine whether this scope is (or is nested into) some OpenMP
544 /// loop simd directive scope (for example, 'omp simd', 'omp for simd').
547 }
548
549 /// Determine whether this scope is a loop having OpenMP loop
550 /// directive attached.
551 bool isOpenMPLoopScope() const {
552 const Scope *P = getParent();
553 return P && P->isOpenMPLoopDirectiveScope();
554 }
555
556 /// Determine whether this scope is some OpenMP directive with
557 /// order clause which specifies concurrent scope.
560 }
561
562 /// Determine whether this scope is the statement associated with an OpenACC
563 /// Compute construct directive.
566 }
567
570 }
571
572 /// Determine if this scope (or its parents) are a compute construct. If the
573 /// argument is provided, the search will stop at any of the specified scopes.
574 /// Otherwise, it will stop only at the normal 'no longer search' scopes.
576 for (const Scope *S = this; S; S = S->getParent()) {
577 if (S->isOpenACCComputeConstructScope())
578 return true;
579
580 if (S->getFlags() & Flags)
581 return false;
582
583 else if (S->getFlags() &
587 return false;
588 }
589 return false;
590 }
591
592 /// Determine whether this scope is a while/do/for statement, which can have
593 /// continue statements embedded into it.
594 bool isContinueScope() const {
596 }
597
598 /// Determine whether this is a scope which can have 'break' or 'continue'
599 /// statements embedded into it.
601 return getFlags() & (ContinueScope | BreakScope);
602 }
603
604 /// Determine whether this scope is a C++ 'try' block.
605 bool isTryScope() const { return getFlags() & Scope::TryScope; }
606
607 /// Determine whether this scope is a function-level C++ try or catch scope.
608 bool isFnTryCatchScope() const {
610 }
611
612 /// Determine whether this scope is a SEH '__try' block.
613 bool isSEHTryScope() const { return getFlags() & Scope::SEHTryScope; }
614
615 /// Determine whether this scope is a SEH '__except' block.
617
618 /// Determine whether this scope is a compound statement scope.
619 bool isCompoundStmtScope() const {
621 }
622
623 /// Determine whether this scope is a controlling scope in a
624 /// if/switch/while/for statement.
625 bool isControlScope() const { return getFlags() & Scope::ControlScope; }
626
627 /// Determine whether this scope is a type alias scope.
629
630 /// Determine whether this scope is a friend scope.
631 bool isFriendScope() const { return getFlags() & Scope::FriendScope; }
632
633 /// Returns if rhs has a higher scope depth than this.
634 ///
635 /// The caller is responsible for calling this only if one of the two scopes
636 /// is an ancestor of the other.
637 bool Contains(const Scope& rhs) const { return Depth < rhs.Depth; }
638
639 /// containedInPrototypeScope - Return true if this or a parent scope
640 /// is a FunctionPrototypeScope.
641 bool containedInPrototypeScope() const;
642
644 UsingDirectives.push_back(UDir);
645 }
646
648 llvm::iterator_range<UsingDirectivesTy::iterator>;
649
651 return using_directives_range(UsingDirectives.begin(),
652 UsingDirectives.end());
653 }
654
656
657 void applyNRVO();
658
659 /// Init - This is used by the parser to implement scope caching.
660 void Init(Scope *parent, unsigned flags);
661
662 /// Sets up the specified scope flags and adjusts the scope state
663 /// variables accordingly.
664 void AddFlags(unsigned Flags);
665
666 void dumpImpl(raw_ostream &OS) const;
667 void dump() const;
668};
669
670} // namespace clang
671
672#endif // LLVM_CLANG_SEMA_SCOPE_H
NodeId Parent
Definition: ASTDiff.cpp:191
StringRef P
Defines the Diagnostic-related interfaces.
const Decl * D
Expr * E
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1449
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
RAII class that determines when any errors have occurred between the time the instance was created an...
Definition: Diagnostic.h:1076
bool hasUnrecoverableErrorOccurred() const
Determine whether any unrecoverable errors have occurred since this object instance was created.
Definition: Diagnostic.h:1094
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:231
Represents the declaration of a label.
Definition: Decl.h:523
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:41
bool isFriendScope() const
Determine whether this scope is a friend scope.
Definition: Scope.h:631
Scope * getMSLastManglingParent()
Definition: Scope.h:297
void setEntity(DeclContext *E)
Definition: Scope.h:409
void AddFlags(unsigned Flags)
Sets up the specified scope flags and adjusts the scope state variables accordingly.
Definition: Scope.cpp:116
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
Definition: Scope.h:428
bool isBlockScope() const
isBlockScope - Return true if this scope correspond to a closure.
Definition: Scope.h:284
unsigned getDepth() const
Returns the depth of this scope. The translation-unit has scope depth 0.
Definition: Scope.h:339
unsigned getNextFunctionPrototypeIndex()
Return the number of parameters declared in this function prototype, increasing it by one for the nex...
Definition: Scope.h:349
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
Definition: Scope.h:291
void AddDecl(Decl *D)
Definition: Scope.h:362
bool isSEHExceptScope() const
Determine whether this scope is a SEH '__except' block.
Definition: Scope.h:616
llvm::iterator_range< DeclSetTy::iterator > decl_range
Definition: Scope.h:354
bool isInObjcMethodOuterScope() const
isInObjcMethodOuterScope - Return true if this scope is an Objective-C method outer most body.
Definition: Scope.h:470
bool isAtCatchScope() const
isAtCatchScope - Return true if this scope is @catch.
Definition: Scope.h:498
bool isCatchScope() const
isCatchScope - Return true if this scope is a C++ catch statement.
Definition: Scope.h:503
void setFlags(unsigned F)
Definition: Scope.h:273
void setPrecedingLabel(LabelDecl *LD)
Definition: Scope.h:277
bool isOpenACCLoopConstructScope() const
Definition: Scope.h:568
bool isInObjcMethodScope() const
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body.
Definition: Scope.h:459
void incrementMSManglingNumber()
Definition: Scope.h:372
const Scope * getBreakParent() const
Definition: Scope.h:325
bool isInCXXInlineMethodScope() const
isInCXXInlineMethodScope - Return true if this scope is a C++ inline method scope or is inside one.
Definition: Scope.h:438
bool Contains(const Scope &rhs) const
Returns if rhs has a higher scope depth than this.
Definition: Scope.h:637
LabelDecl * getPrecedingLabel() const
Get the label that precedes this scope.
Definition: Scope.h:276
const Scope * getMSLastManglingParent() const
Definition: Scope.h:294
bool isOpenMPLoopDirectiveScope() const
Determine whether this scope is some OpenMP loop directive scope (for example, 'omp for',...
Definition: Scope.h:534
unsigned getFlags() const
getFlags - Return the flags for this scope.
Definition: Scope.h:271
DeclContext * getLookupEntity() const
Get the DeclContext in which to continue unqualified lookup after a lookup in this scope.
Definition: Scope.h:407
bool isSwitchScope() const
isSwitchScope - Return true if this scope is a switch scope.
Definition: Scope.h:506
bool isTypeAliasScope() const
Determine whether this scope is a type alias scope.
Definition: Scope.h:628
bool isOpenMPDirectiveScope() const
Determines whether this scope is the OpenMP directive scope.
Definition: Scope.h:528
using_directives_range using_directives()
Definition: Scope.h:650
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by.
Definition: Scope.h:301
llvm::iterator_range< UsingDirectivesTy::iterator > using_directives_range
Definition: Scope.h:648
Scope(Scope *Parent, unsigned ScopeFlags, DiagnosticsEngine &Diag)
Definition: Scope.h:265
void setIsConditionVarScope(bool InConditionVarScope)
Definition: Scope.h:311
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
Definition: Scope.h:398
bool isFnTryCatchScope() const
Determine whether this scope is a function-level C++ try or catch scope.
Definition: Scope.h:608
void decrementMSManglingNumber()
Definition: Scope.h:379
bool isControlScope() const
Determine whether this scope is a controlling scope in a if/switch/while/for statement.
Definition: Scope.h:625
void RemoveDecl(Decl *D)
Definition: Scope.h:370
const Scope * getTemplateParamParent() const
Definition: Scope.h:333
void setLookupEntity(DeclContext *E)
Definition: Scope.h:414
unsigned getMSLastManglingNumber() const
Definition: Scope.h:386
void dump() const
Definition: Scope.cpp:197
DeclContext * getEntity() const
Get the entity corresponding to this scope.
Definition: Scope.h:401
Scope * getBlockParent()
Definition: Scope.h:329
unsigned getMSCurManglingNumber() const
Definition: Scope.h:392
bool isLoopScope() const
Return true if this scope is a loop.
Definition: Scope.h:520
bool isSEHTryScope() const
Determine whether this scope is a SEH '__try' block.
Definition: Scope.h:613
bool decl_empty() const
Definition: Scope.h:360
bool isOpenMPSimdDirectiveScope() const
Determine whether this scope is (or is nested into) some OpenMP loop simd directive scope (for exampl...
Definition: Scope.h:545
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
Definition: Scope.h:481
Scope * getFnParent()
Definition: Scope.h:292
unsigned getFunctionPrototypeDepth() const
Returns the number of function prototype scopes in this scope chain.
Definition: Scope.h:343
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by.
Definition: Scope.h:322
Scope * getDeclParent()
Definition: Scope.h:335
bool isCompoundStmtScope() const
Determine whether this scope is a compound statement scope.
Definition: Scope.h:619
bool isInCFunctionScope() const
isInObjcMethodScope - Return true if this scope is, or is contained, in an C function body.
Definition: Scope.h:448
decl_range decls() const
Definition: Scope.h:356
bool isInOpenACCComputeConstructScope(ScopeFlags Flags=NoScope) const
Determine if this scope (or its parents) are a compute construct.
Definition: Scope.h:575
bool isFunctionDeclarationScope() const
isFunctionDeclarationScope - Return true if this scope is a function prototype scope.
Definition: Scope.h:493
bool containedInPrototypeScope() const
containedInPrototypeScope - Return true if this or a parent scope is a FunctionPrototypeScope.
Definition: Scope.cpp:106
bool isOpenMPOrderClauseScope() const
Determine whether this scope is some OpenMP directive with order clause which specifies concurrent sc...
Definition: Scope.h:558
const Scope * getParent() const
getParent - Return the scope that this is nested in.
Definition: Scope.h:287
bool isBreakOrContinueScope() const
Determine whether this is a scope which can have 'break' or 'continue' statements embedded into it.
Definition: Scope.h:600
bool isContinueScope() const
Determine whether this scope is a while/do/for statement, which can have continue statements embedded...
Definition: Scope.h:594
Scope * getParent()
Definition: Scope.h:288
bool isClassInheritanceScope() const
Determines whether this scope is between inheritance colon and the real class/struct definition.
Definition: Scope.h:432
bool isConditionVarScope() const
Definition: Scope.h:316
bool isFunctionPrototypeScope() const
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
Definition: Scope.h:487
bool isTryScope() const
Determine whether this scope is a C++ 'try' block.
Definition: Scope.h:605
void updateNRVOCandidate(VarDecl *VD)
Definition: Scope.cpp:137
const Scope * getBlockParent() const
Definition: Scope.h:330
bool isFunctionScope() const
isFunctionScope() - Return true if this scope is a function scope.
Definition: Scope.h:425
const Scope * getContinueParent() const
Definition: Scope.h:305
bool isOpenACCComputeConstructScope() const
Determine whether this scope is the statement associated with an OpenACC Compute construct directive.
Definition: Scope.h:564
void dumpImpl(raw_ostream &OS) const
Definition: Scope.cpp:199
const Scope * getDeclParent() const
Definition: Scope.h:336
bool hasUnrecoverableErrorOccurred() const
Determine whether any unrecoverable errors have occurred within this scope.
Definition: Scope.h:420
void applyNRVO()
Definition: Scope.cpp:166
bool isOpenMPLoopScope() const
Determine whether this scope is a loop having OpenMP loop directive attached.
Definition: Scope.h:551
Scope * getTemplateParamParent()
Definition: Scope.h:332
ScopeFlags
ScopeFlags - These are bitfields that are or'd together when creating a scope, which defines the sort...
Definition: Scope.h:45
@ OpenMPDirectiveScope
This is the scope of OpenMP executable directive.
Definition: Scope.h:111
@ FunctionPrototypeScope
This is a scope that corresponds to the parameters within a function prototype.
Definition: Scope.h:85
@ OpenMPOrderClauseScope
This is a scope of some OpenMP directive with order clause which specifies concurrent.
Definition: Scope.h:150
@ LambdaScope
This is the scope for a lambda, after the lambda introducer.
Definition: Scope.h:155
@ NoScope
Definition: Scope.h:47
@ OpenACCLoopConstructScope
This is the scope of an OpenACC Loop/Combined construct, which is used to determine whether a 'cache'...
Definition: Scope.h:163
@ BlockScope
This is a scope that corresponds to a block/closure object.
Definition: Scope.h:75
@ SEHTryScope
This scope corresponds to an SEH try.
Definition: Scope.h:125
@ FriendScope
This is a scope of friend declaration.
Definition: Scope.h:169
@ ContinueScope
This is a while, do, for, which can have continue statements embedded into it.
Definition: Scope.h:59
@ OpenACCComputeConstructScope
This is the scope of an OpenACC Compute Construct, which restricts jumping into/out of it.
Definition: Scope.h:159
@ TypeAliasScope
This is a scope of type alias declaration.
Definition: Scope.h:166
@ ControlScope
The controlling scope in a if/switch/while/for statement.
Definition: Scope.h:66
@ ClassInheritanceScope
We are between inheritance colon and the real class/struct definition scope.
Definition: Scope.h:138
@ AtCatchScope
This is a scope that corresponds to the Objective-C @catch statement.
Definition: Scope.h:95
@ TemplateParamScope
This is a scope that corresponds to the template parameters of a C++ template.
Definition: Scope.h:81
@ SEHFilterScope
We are currently in the filter expression of an SEH except block.
Definition: Scope.h:131
@ SwitchScope
This is a scope that corresponds to a switch statement.
Definition: Scope.h:102
@ BreakScope
This is a while, do, switch, for, etc that can have break statements embedded into it.
Definition: Scope.h:55
@ CatchScope
This is the scope of a C++ catch statement.
Definition: Scope.h:141
@ CompoundStmtScope
This is a compound statement scope.
Definition: Scope.h:134
@ FnTryCatchScope
This is the scope for a function-level C++ try or catch scope.
Definition: Scope.h:108
@ SEHExceptScope
This scope corresponds to an SEH except.
Definition: Scope.h:128
@ ClassScope
The scope of a struct/union/class definition.
Definition: Scope.h:69
@ TryScope
This is the scope of a C++ try statement.
Definition: Scope.h:105
@ OpenMPSimdDirectiveScope
This is the scope of some OpenMP simd directive.
Definition: Scope.h:119
@ FunctionDeclarationScope
This is a scope that corresponds to the parameters within a function prototype for a function declara...
Definition: Scope.h:91
@ ConditionVarScope
This is a scope in which a condition variable is currently being parsed.
Definition: Scope.h:146
@ FnScope
This indicates that the scope corresponds to a function, which means that labels are set here.
Definition: Scope.h:51
@ ObjCMethodScope
This scope corresponds to an Objective-C method body.
Definition: Scope.h:99
@ EnumScope
This scope corresponds to an enum.
Definition: Scope.h:122
@ OpenMPLoopDirectiveScope
This is the scope of some OpenMP loop directive.
Definition: Scope.h:114
@ DeclScope
This is a scope that can contain a declaration.
Definition: Scope.h:63
void PushUsingDirective(UsingDirectiveDecl *UDir)
Definition: Scope.h:643
Represents C++ using-directive.
Definition: DeclCXX.h:3090
Represents a variable declaration or definition.
Definition: Decl.h:925
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
Definition: ModuleMapFile.h:36
The JSON file list parser is used to communicate input to InstallAPI.
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30