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