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