clang 23.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;
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 bit is currently unused.
144 Unused = 0x2000000,
145
146 /// This is a scope of some OpenMP directive with
147 /// order clause which specifies concurrent
149 /// This is the scope for a lambda, after the lambda introducer.
150 /// Lambdas need two FunctionPrototypeScope scopes (because there is a
151 /// template scope in between), the outer scope does not increase the
152 /// depth of recursion.
153 LambdaScope = 0x8000000,
154 /// This is the scope of an OpenACC Compute Construct, which restricts
155 /// jumping into/out of it. We also use this to represent 'combined'
156 /// constructs, since they have the same behavior.
158
159 /// This is the scope of an OpenACC Loop/Combined construct, which is used
160 /// to determine whether a 'cache' construct variable reference is legal.
162
163 /// This is a scope of type alias declaration.
164 TypeAliasScope = 0x40000000,
165
166 /// This is a scope of friend declaration.
167 FriendScope = 0x80000000,
168 };
169
170private:
171 /// The parent scope for this scope. This is null for the translation-unit
172 /// scope.
173 Scope *AnyParent;
174
175 /// Flags - This contains a set of ScopeFlags, which indicates how the scope
176 /// interrelates with other control flow statements.
177 unsigned Flags;
178
179 /// Depth - This is the depth of this scope. The translation-unit scope has
180 /// depth 0.
181 unsigned short Depth;
182
183 /// Declarations with static linkage are mangled with the number of
184 /// scopes seen as a component.
185 unsigned short MSLastManglingNumber;
186
187 unsigned short MSCurManglingNumber;
188
189 /// PrototypeDepth - This is the number of function prototype scopes
190 /// enclosing this scope, including this scope.
191 unsigned short PrototypeDepth;
192
193 /// PrototypeIndex - This is the number of parameters currently
194 /// declared in this scope.
195 unsigned short PrototypeIndex;
196
197 /// FnParent - If this scope has a parent scope that is a function body, this
198 /// pointer is non-null and points to it. This is used for label processing.
199 Scope *FnParent;
200 Scope *MSLastManglingParent;
201
202 /// BreakParent/ContinueParent - This is a direct link to the innermost
203 /// BreakScope/ContinueScope which contains the contents of this scope
204 /// for control flow purposes (and might be this scope itself), or null
205 /// if there is no such scope.
206 Scope *BreakParent, *ContinueParent;
207
208 /// BlockParent - This is a direct link to the immediately containing
209 /// BlockScope if this scope is not one, or null if there is none.
210 Scope *BlockParent;
211
212 /// TemplateParamParent - This is a direct link to the
213 /// immediately containing template parameter scope. In the
214 /// case of nested templates, template parameter scopes can have
215 /// other template parameter scopes as parents.
216 Scope *TemplateParamParent;
217
218 /// DeclScopeParent - This is a direct link to the immediately containing
219 /// DeclScope, i.e. scope which can contain declarations.
220 Scope *DeclParent;
221
222 /// DeclsInScope - This keeps track of all declarations in this scope. When
223 /// the declaration is added to the scope, it is set as the current
224 /// declaration for the identifier in the IdentifierTable. When the scope is
225 /// popped, these declarations are removed from the IdentifierTable's notion
226 /// of current declaration. It is up to the current Action implementation to
227 /// implement these semantics.
228 using DeclSetTy = llvm::SmallPtrSet<Decl *, 32>;
229 DeclSetTy DeclsInScope;
230
231 /// The DeclContext with which this scope is associated. For
232 /// example, the entity of a class scope is the class itself, the
233 /// entity of a function scope is a function, etc.
234 DeclContext *Entity;
235
236 using UsingDirectivesTy = SmallVector<UsingDirectiveDecl *, 2>;
237 UsingDirectivesTy UsingDirectives;
238
239 /// Used to determine if errors occurred in this scope.
240 DiagnosticErrorTrap ErrorTrap;
241
242 /// A single NRVO candidate variable in this scope.
243 /// There are three possible values:
244 /// 1) pointer to VarDecl that denotes NRVO candidate itself.
245 /// 2) nullptr value means that NRVO is not allowed in this scope
246 /// (e.g. return a function parameter).
247 /// 3) std::nullopt value means that there is no NRVO candidate in this scope
248 /// (i.e. there are no return statements in this scope).
249 std::optional<VarDecl *> NRVO;
250
251 /// Represents return slots for NRVO candidates in the current scope.
252 /// If a variable is present in this set, it means that a return slot is
253 /// available for this variable in the current scope.
255
256 /// If this scope belongs to a loop or switch statement, the label that
257 /// directly precedes it, if any.
258 LabelDecl *PrecedingLabel;
259
260 void setFlags(Scope *Parent, unsigned F);
261
262public:
264 : ErrorTrap(Diag) {
265 Init(Parent, ScopeFlags);
266 }
267
268 /// getFlags - Return the flags for this scope.
269 unsigned getFlags() const { return Flags; }
270
271 void setFlags(unsigned F) { setFlags(getParent(), F); }
272
273 /// Get the label that precedes this scope.
274 LabelDecl *getPrecedingLabel() const { return PrecedingLabel; }
275
276 /// isBlockScope - Return true if this scope correspond to a closure.
277 bool isBlockScope() const { return Flags & BlockScope; }
278
279 /// getParent - Return the scope that this is nested in.
280 const Scope *getParent() const { return AnyParent; }
281 Scope *getParent() { return AnyParent; }
282
283 /// getFnParent - Return the closest scope that is a function body.
284 const Scope *getFnParent() const { return FnParent; }
285 Scope *getFnParent() { return FnParent; }
286
288 return MSLastManglingParent;
289 }
290 Scope *getMSLastManglingParent() { return MSLastManglingParent; }
291
292 /// getContinueParent - Return the closest scope that a continue statement
293 /// would be affected by.
295 return ContinueParent;
296 }
297
298 const Scope *getContinueParent() const {
299 return const_cast<Scope*>(this)->getContinueParent();
300 }
301
302 /// getBreakParent - Return the closest scope that a break statement
303 /// would be affected by.
305 return BreakParent;
306 }
307 const Scope *getBreakParent() const {
308 return const_cast<Scope*>(this)->getBreakParent();
309 }
310
311 Scope *getBlockParent() { return BlockParent; }
312 const Scope *getBlockParent() const { return BlockParent; }
313
314 Scope *getTemplateParamParent() { return TemplateParamParent; }
315 const Scope *getTemplateParamParent() const { return TemplateParamParent; }
316
317 Scope *getDeclParent() { return DeclParent; }
318 const Scope *getDeclParent() const { return DeclParent; }
319
320 /// Returns the depth of this scope. The translation-unit has scope depth 0.
321 unsigned getDepth() const { return Depth; }
322
323 /// Returns the number of function prototype scopes in this scope
324 /// chain.
325 unsigned getFunctionPrototypeDepth() const {
326 return PrototypeDepth;
327 }
328
329 /// Return the number of parameters declared in this function
330 /// prototype, increasing it by one for the next call.
332 assert(isFunctionPrototypeScope());
333 return PrototypeIndex++;
334 }
335
336 using decl_range = llvm::iterator_range<DeclSetTy::iterator>;
337
339 return decl_range(DeclsInScope.begin(), DeclsInScope.end());
340 }
341
342 bool decl_empty() const { return DeclsInScope.empty(); }
343
344 void AddDecl(Decl *D) {
345 if (auto *VD = dyn_cast<VarDecl>(D))
346 if (!isa<ParmVarDecl>(VD))
347 ReturnSlots.insert(VD);
348
349 DeclsInScope.insert(D);
350 }
351
352 void RemoveDecl(Decl *D) { DeclsInScope.erase(D); }
353
355 if (Scope *MSLMP = getMSLastManglingParent()) {
356 MSLMP->MSLastManglingNumber += 1;
357 MSCurManglingNumber += 1;
358 }
359 }
360
362 if (Scope *MSLMP = getMSLastManglingParent()) {
363 MSLMP->MSLastManglingNumber -= 1;
364 MSCurManglingNumber -= 1;
365 }
366 }
367
368 unsigned getMSLastManglingNumber() const {
369 if (const Scope *MSLMP = getMSLastManglingParent())
370 return MSLMP->MSLastManglingNumber;
371 return 1;
372 }
373
374 unsigned getMSCurManglingNumber() const {
375 return MSCurManglingNumber;
376 }
377
378 /// isDeclScope - Return true if this is the scope that the specified decl is
379 /// declared in.
380 bool isDeclScope(const Decl *D) const { return DeclsInScope.contains(D); }
381
382 /// Get the entity corresponding to this scope.
384 return isTemplateParamScope() ? nullptr : Entity;
385 }
386
387 /// Get the DeclContext in which to continue unqualified lookup after a
388 /// lookup in this scope.
389 DeclContext *getLookupEntity() const { return Entity; }
390
392 assert(!isTemplateParamScope() &&
393 "entity associated with template param scope");
394 Entity = E;
395 }
396 void setLookupEntity(DeclContext *E) { Entity = E; }
397
398 /// Determine whether any unrecoverable errors have occurred within this
399 /// scope. Note that this may return false even if the scope contains invalid
400 /// declarations or statements, if the errors for those invalid constructs
401 /// were suppressed because some prior invalid construct was referenced.
403 return ErrorTrap.hasUnrecoverableErrorOccurred();
404 }
405
406 /// isFunctionScope() - Return true if this scope is a function scope.
407 bool isFunctionScope() const { return getFlags() & Scope::FnScope; }
408
409 /// isClassScope - Return true if this scope is a class/struct/union scope.
410 bool isClassScope() const { return getFlags() & Scope::ClassScope; }
411
412 /// Determines whether this scope is between inheritance colon and the real
413 /// class/struct definition.
417
418 /// isInCXXInlineMethodScope - Return true if this scope is a C++ inline
419 /// method scope or is inside one.
421 if (const Scope *FnS = getFnParent()) {
422 assert(FnS->getParent() && "TUScope not created?");
423 return FnS->getParent()->isClassScope();
424 }
425 return false;
426 }
427
428 /// isInObjcMethodScope - Return true if this scope is, or is contained, in an
429 /// C function body.
430 bool isInCFunctionScope() const {
431 for (const Scope *S = this; S; S = S->getParent()) {
432 if (S->isFunctionScope())
433 return true;
434 }
435
436 return false;
437 }
438
439 /// isInObjcMethodScope - Return true if this scope is, or is contained in, an
440 /// Objective-C method body. Note that this method is not constant time.
441 bool isInObjcMethodScope() const {
442 for (const Scope *S = this; S; S = S->getParent()) {
443 // If this scope is an objc method scope, then we succeed.
444 if (S->getFlags() & ObjCMethodScope)
445 return true;
446 }
447 return false;
448 }
449
450 /// isInObjcMethodOuterScope - Return true if this scope is an
451 /// Objective-C method outer most body.
453 if (const Scope *S = this) {
454 // If this scope is an objc method scope, then we succeed.
455 if (S->getFlags() & ObjCMethodScope)
456 return true;
457 }
458 return false;
459 }
460
461 /// isTemplateParamScope - Return true if this scope is a C++
462 /// template parameter scope.
463 bool isTemplateParamScope() const {
465 }
466
467 /// isFunctionPrototypeScope - Return true if this scope is a
468 /// function prototype scope.
472
473 /// isFunctionDeclarationScope - Return true if this scope is a
474 /// function prototype scope.
478
479 /// isAtCatchScope - Return true if this scope is \@catch.
480 bool isAtCatchScope() const {
481 return getFlags() & Scope::AtCatchScope;
482 }
483
484 /// isCatchScope - Return true if this scope is a C++ catch statement.
485 bool isCatchScope() const { return getFlags() & Scope::CatchScope; }
486
487 /// isSwitchScope - Return true if this scope is a switch scope.
488 bool isSwitchScope() const {
489 for (const Scope *S = this; S; S = S->getParent()) {
490 if (S->getFlags() & Scope::SwitchScope)
491 return true;
492 else if (S->getFlags() & (Scope::FnScope | Scope::ClassScope |
496 return false;
497 }
498 return false;
499 }
500
501 /// Return true if this scope is a loop.
502 bool isLoopScope() const {
503 // 'switch' is the only loop that is not a 'break' scope as well, so we can
504 // just check BreakScope and not SwitchScope.
505 return (getFlags() & Scope::BreakScope) &&
507 }
508
509 /// Determines whether this scope is the OpenMP directive scope
512 }
513
514 /// Determine whether this scope is some OpenMP loop directive scope
515 /// (for example, 'omp for', 'omp simd').
518 assert(isOpenMPDirectiveScope() &&
519 "OpenMP loop directive scope is not a directive scope");
520 return true;
521 }
522 return false;
523 }
524
525 /// Determine whether this scope is (or is nested into) some OpenMP
526 /// loop simd directive scope (for example, 'omp simd', 'omp for simd').
530
531 /// Determine whether this scope is a loop having OpenMP loop
532 /// directive attached.
533 bool isOpenMPLoopScope() const {
534 const Scope *P = getParent();
535 return P && P->isOpenMPLoopDirectiveScope();
536 }
537
538 /// Determine whether this scope is some OpenMP directive with
539 /// order clause which specifies concurrent scope.
543
544 /// Determine whether this scope is the statement associated with an OpenACC
545 /// Compute construct directive.
549
553
554 /// Determine if this scope (or its parents) are a compute construct. If the
555 /// argument is provided, the search will stop at any of the specified scopes.
556 /// Otherwise, it will stop only at the normal 'no longer search' scopes.
558 for (const Scope *S = this; S; S = S->getParent()) {
559 if (S->isOpenACCComputeConstructScope())
560 return true;
561
562 if (S->getFlags() & Flags)
563 return false;
564
565 else if (S->getFlags() &
569 return false;
570 }
571 return false;
572 }
573
574 /// Determine whether this scope is a while/do/for statement, which can have
575 /// continue statements embedded into it.
576 bool isContinueScope() const {
578 }
579
580 /// Determine whether this is a scope which can have 'break' or 'continue'
581 /// statements embedded into it.
583 return getFlags() & (ContinueScope | BreakScope);
584 }
585
586 /// Determine whether this scope is a C++ 'try' block.
587 bool isTryScope() const { return getFlags() & Scope::TryScope; }
588
589 /// Determine whether this scope is a function-level C++ try or catch scope.
590 bool isFnTryCatchScope() const {
592 }
593
594 /// Determine whether this scope is a SEH '__try' block.
595 bool isSEHTryScope() const { return getFlags() & Scope::SEHTryScope; }
596
597 /// Determine whether this scope is a SEH '__except' block.
599
600 /// Determine whether this scope is a compound statement scope.
601 bool isCompoundStmtScope() const {
603 }
604
605 /// Determine whether this scope is a controlling scope in a
606 /// if/switch/while/for statement.
607 bool isControlScope() const { return getFlags() & Scope::ControlScope; }
608
609 /// Determine whether this scope is a type alias scope.
611
612 /// Determine whether this scope is a friend scope.
613 bool isFriendScope() const { return getFlags() & Scope::FriendScope; }
614
615 /// Returns if rhs has a higher scope depth than this.
616 ///
617 /// The caller is responsible for calling this only if one of the two scopes
618 /// is an ancestor of the other.
619 bool Contains(const Scope& rhs) const { return Depth < rhs.Depth; }
620
621 /// Mark that we're entering the body of a loop (for, while, do).
622 void EnterLoopBody(LabelDecl *PrecedingLabel);
623
624 /// Mark that we're entering the body of a switch statement.
625 void EnterSwitchBody(LabelDecl *PrecedingLabel);
626
627 /// Mark that we're leaving the body of a loop; this is only needed for do
628 /// loops where the condition follows the loop body.
629 void LeaveLoopBody();
630
631 /// containedInPrototypeScope - Return true if this or a parent scope
632 /// is a FunctionPrototypeScope.
633 bool containedInPrototypeScope() const;
634
636 UsingDirectives.push_back(UDir);
637 }
638
640 llvm::iterator_range<UsingDirectivesTy::iterator>;
641
643 return using_directives_range(UsingDirectives.begin(),
644 UsingDirectives.end());
645 }
646
648
649 void applyNRVO();
650
651 /// Init - This is used by the parser to implement scope caching.
652 void Init(Scope *parent, unsigned flags);
653
654 void dumpImpl(raw_ostream &OS) const;
655 void dump() const;
656};
657
658} // namespace clang
659
660#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:1462
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:233
Represents the declaration of a label.
Definition Decl.h:524
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:613
Scope * getMSLastManglingParent()
Definition Scope.h:290
void setEntity(DeclContext *E)
Definition Scope.h:391
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
Definition Scope.h:410
bool isBlockScope() const
isBlockScope - Return true if this scope correspond to a closure.
Definition Scope.h:277
unsigned getDepth() const
Returns the depth of this scope. The translation-unit has scope depth 0.
Definition Scope.h:321
llvm::iterator_range< UsingDirectivesTy::iterator > using_directives_range
Definition Scope.h:639
unsigned getNextFunctionPrototypeIndex()
Return the number of parameters declared in this function prototype, increasing it by one for the nex...
Definition Scope.h:331
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
Definition Scope.h:284
void AddDecl(Decl *D)
Definition Scope.h:344
bool isSEHExceptScope() const
Determine whether this scope is a SEH '__except' block.
Definition Scope.h:598
llvm::iterator_range< DeclSetTy::iterator > decl_range
Definition Scope.h:336
bool isInObjcMethodOuterScope() const
isInObjcMethodOuterScope - Return true if this scope is an Objective-C method outer most body.
Definition Scope.h:452
bool isAtCatchScope() const
isAtCatchScope - Return true if this scope is @catch.
Definition Scope.h:480
bool isCatchScope() const
isCatchScope - Return true if this scope is a C++ catch statement.
Definition Scope.h:485
void EnterSwitchBody(LabelDecl *PrecedingLabel)
Mark that we're entering the body of a switch statement.
Definition Scope.cpp:122
void setFlags(unsigned F)
Definition Scope.h:271
bool isOpenACCLoopConstructScope() const
Definition Scope.h:550
bool isInObjcMethodScope() const
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body.
Definition Scope.h:441
void incrementMSManglingNumber()
Definition Scope.h:354
const Scope * getBreakParent() const
Definition Scope.h:307
bool isInCXXInlineMethodScope() const
isInCXXInlineMethodScope - Return true if this scope is a C++ inline method scope or is inside one.
Definition Scope.h:420
bool Contains(const Scope &rhs) const
Returns if rhs has a higher scope depth than this.
Definition Scope.h:619
LabelDecl * getPrecedingLabel() const
Get the label that precedes this scope.
Definition Scope.h:274
const Scope * getMSLastManglingParent() const
Definition Scope.h:287
bool isOpenMPLoopDirectiveScope() const
Determine whether this scope is some OpenMP loop directive scope (for example, 'omp for',...
Definition Scope.h:516
unsigned getFlags() const
getFlags - Return the flags for this scope.
Definition Scope.h:269
DeclContext * getLookupEntity() const
Get the DeclContext in which to continue unqualified lookup after a lookup in this scope.
Definition Scope.h:389
bool isSwitchScope() const
isSwitchScope - Return true if this scope is a switch scope.
Definition Scope.h:488
bool isTypeAliasScope() const
Determine whether this scope is a type alias scope.
Definition Scope.h:610
bool isOpenMPDirectiveScope() const
Determines whether this scope is the OpenMP directive scope.
Definition Scope.h:510
using_directives_range using_directives()
Definition Scope.h:642
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by.
Definition Scope.h:294
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:263
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
Definition Scope.h:380
bool isFnTryCatchScope() const
Determine whether this scope is a function-level C++ try or catch scope.
Definition Scope.h:590
void decrementMSManglingNumber()
Definition Scope.h:361
bool isControlScope() const
Determine whether this scope is a controlling scope in a if/switch/while/for statement.
Definition Scope.h:607
void RemoveDecl(Decl *D)
Definition Scope.h:352
const Scope * getTemplateParamParent() const
Definition Scope.h:315
void setLookupEntity(DeclContext *E)
Definition Scope.h:396
unsigned getMSLastManglingNumber() const
Definition Scope.h:368
void dump() const
Definition Scope.cpp:202
DeclContext * getEntity() const
Get the entity corresponding to this scope.
Definition Scope.h:383
Scope * getBlockParent()
Definition Scope.h:311
unsigned getMSCurManglingNumber() const
Definition Scope.h:374
bool isLoopScope() const
Return true if this scope is a loop.
Definition Scope.h:502
bool isSEHTryScope() const
Determine whether this scope is a SEH '__try' block.
Definition Scope.h:595
bool decl_empty() const
Definition Scope.h:342
bool isOpenMPSimdDirectiveScope() const
Determine whether this scope is (or is nested into) some OpenMP loop simd directive scope (for exampl...
Definition Scope.h:527
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
Definition Scope.h:463
Scope * getFnParent()
Definition Scope.h:285
unsigned getFunctionPrototypeDepth() const
Returns the number of function prototype scopes in this scope chain.
Definition Scope.h:325
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by.
Definition Scope.h:304
Scope * getDeclParent()
Definition Scope.h:317
bool isCompoundStmtScope() const
Determine whether this scope is a compound statement scope.
Definition Scope.h:601
bool isInCFunctionScope() const
isInObjcMethodScope - Return true if this scope is, or is contained, in an C function body.
Definition Scope.h:430
decl_range decls() const
Definition Scope.h:338
bool isInOpenACCComputeConstructScope(ScopeFlags Flags=NoScope) const
Determine if this scope (or its parents) are a compute construct.
Definition Scope.h:557
void EnterLoopBody(LabelDecl *PrecedingLabel)
Mark that we're entering the body of a loop (for, while, do).
Definition Scope.cpp:116
bool isFunctionDeclarationScope() const
isFunctionDeclarationScope - Return true if this scope is a function prototype scope.
Definition Scope.h:475
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:540
const Scope * getParent() const
getParent - Return the scope that this is nested in.
Definition Scope.h:280
bool isBreakOrContinueScope() const
Determine whether this is a scope which can have 'break' or 'continue' statements embedded into it.
Definition Scope.h:582
bool isContinueScope() const
Determine whether this scope is a while/do/for statement, which can have continue statements embedded...
Definition Scope.h:576
Scope * getParent()
Definition Scope.h:281
bool isClassInheritanceScope() const
Determines whether this scope is between inheritance colon and the real class/struct definition.
Definition Scope.h:414
bool isFunctionPrototypeScope() const
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
Definition Scope.h:469
bool isTryScope() const
Determine whether this scope is a C++ 'try' block.
Definition Scope.h:587
void updateNRVOCandidate(VarDecl *VD)
Definition Scope.cpp:142
const Scope * getBlockParent() const
Definition Scope.h:312
bool isFunctionScope() const
isFunctionScope() - Return true if this scope is a function scope.
Definition Scope.h:407
const Scope * getContinueParent() const
Definition Scope.h:298
bool isOpenACCComputeConstructScope() const
Determine whether this scope is the statement associated with an OpenACC Compute construct directive.
Definition Scope.h:546
void dumpImpl(raw_ostream &OS) const
Definition Scope.cpp:204
const Scope * getDeclParent() const
Definition Scope.h:318
bool hasUnrecoverableErrorOccurred() const
Determine whether any unrecoverable errors have occurred within this scope.
Definition Scope.h:402
void applyNRVO()
Definition Scope.cpp:171
bool isOpenMPLoopScope() const
Determine whether this scope is a loop having OpenMP loop directive attached.
Definition Scope.h:533
Scope * getTemplateParamParent()
Definition Scope.h:314
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:148
@ LambdaScope
This is the scope for a lambda, after the lambda introducer.
Definition Scope.h:153
@ OpenACCLoopConstructScope
This is the scope of an OpenACC Loop/Combined construct, which is used to determine whether a 'cache'...
Definition Scope.h:161
@ 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:167
@ 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:157
@ TypeAliasScope
This is a scope of type alias declaration.
Definition Scope.h:164
@ 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
@ Unused
This bit is currently unused.
Definition Scope.h:144
@ 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:635
Represents C++ using-directive.
Definition DeclCXX.h:3101
Represents a variable declaration or definition.
Definition Decl.h:924
The JSON file list parser is used to communicate input to InstallAPI.
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