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