clang  17.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"
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  /// This indicates that the scope corresponds to a function, which
47  /// means that labels are set here.
48  FnScope = 0x01,
49 
50  /// This is a while, do, switch, for, etc that can have break
51  /// statements embedded into it.
52  BreakScope = 0x02,
53 
54  /// This is a while, do, for, which can have continue statements
55  /// embedded into it.
56  ContinueScope = 0x04,
57 
58  /// This is a scope that can contain a declaration. Some scopes
59  /// just contain loop constructs but don't contain decls.
60  DeclScope = 0x08,
61 
62  /// The controlling scope in a if/switch/while/for statement.
63  ControlScope = 0x10,
64 
65  /// The scope of a struct/union/class definition.
66  ClassScope = 0x20,
67 
68  /// This is a scope that corresponds to a block/closure object.
69  /// Blocks serve as top-level scopes for some objects like labels, they
70  /// also prevent things like break and continue. BlockScopes always have
71  /// the FnScope and DeclScope flags set as well.
72  BlockScope = 0x40,
73 
74  /// This is a scope that corresponds to the
75  /// template parameters of a C++ template. Template parameter
76  /// scope starts at the 'template' keyword and ends when the
77  /// template declaration ends.
79 
80  /// This is a scope that corresponds to the
81  /// parameters within a function prototype.
83 
84  /// This is a scope that corresponds to the parameters within
85  /// a function prototype for a function declaration (as opposed to any
86  /// other kind of function declarator). Always has FunctionPrototypeScope
87  /// set as well.
89 
90  /// This is a scope that corresponds to the Objective-C
91  /// \@catch statement.
92  AtCatchScope = 0x400,
93 
94  /// This scope corresponds to an Objective-C method body.
95  /// It always has FnScope and DeclScope set as well.
96  ObjCMethodScope = 0x800,
97 
98  /// This is a scope that corresponds to a switch statement.
99  SwitchScope = 0x1000,
100 
101  /// This is the scope of a C++ try statement.
102  TryScope = 0x2000,
103 
104  /// This is the scope for a function-level C++ try or catch scope.
105  FnTryCatchScope = 0x4000,
106 
107  /// This is the scope of OpenMP executable directive.
109 
110  /// This is the scope of some OpenMP loop directive.
112 
113  /// This is the scope of some OpenMP simd directive.
114  /// For example, it is used for 'omp simd', 'omp for simd'.
115  /// This flag is propagated to children scopes.
117 
118  /// This scope corresponds to an enum.
119  EnumScope = 0x40000,
120 
121  /// This scope corresponds to an SEH try.
122  SEHTryScope = 0x80000,
123 
124  /// This scope corresponds to an SEH except.
125  SEHExceptScope = 0x100000,
126 
127  /// We are currently in the filter expression of an SEH except block.
128  SEHFilterScope = 0x200000,
129 
130  /// This is a compound statement scope.
131  CompoundStmtScope = 0x400000,
132 
133  /// We are between inheritance colon and the real class/struct definition
134  /// scope.
136 
137  /// This is the scope of a C++ catch statement.
138  CatchScope = 0x1000000,
139 
140  /// This is a scope in which a condition variable is currently being
141  /// parsed. If such a scope is a ContinueScope, it's invalid to jump to the
142  /// continue block from here.
143  ConditionVarScope = 0x2000000,
144 
145  /// This is a scope of some OpenMP directive with
146  /// order clause which specifies concurrent
148  };
149 
150 private:
151  /// The parent scope for this scope. This is null for the translation-unit
152  /// scope.
153  Scope *AnyParent;
154 
155  /// Flags - This contains a set of ScopeFlags, which indicates how the scope
156  /// interrelates with other control flow statements.
157  unsigned Flags;
158 
159  /// Depth - This is the depth of this scope. The translation-unit scope has
160  /// depth 0.
161  unsigned short Depth;
162 
163  /// Declarations with static linkage are mangled with the number of
164  /// scopes seen as a component.
165  unsigned short MSLastManglingNumber;
166 
167  unsigned short MSCurManglingNumber;
168 
169  /// PrototypeDepth - This is the number of function prototype scopes
170  /// enclosing this scope, including this scope.
171  unsigned short PrototypeDepth;
172 
173  /// PrototypeIndex - This is the number of parameters currently
174  /// declared in this scope.
175  unsigned short PrototypeIndex;
176 
177  /// FnParent - If this scope has a parent scope that is a function body, this
178  /// pointer is non-null and points to it. This is used for label processing.
179  Scope *FnParent;
180  Scope *MSLastManglingParent;
181 
182  /// BreakParent/ContinueParent - This is a direct link to the innermost
183  /// BreakScope/ContinueScope which contains the contents of this scope
184  /// for control flow purposes (and might be this scope itself), or null
185  /// if there is no such scope.
186  Scope *BreakParent, *ContinueParent;
187 
188  /// BlockParent - This is a direct link to the immediately containing
189  /// BlockScope if this scope is not one, or null if there is none.
190  Scope *BlockParent;
191 
192  /// TemplateParamParent - This is a direct link to the
193  /// immediately containing template parameter scope. In the
194  /// case of nested templates, template parameter scopes can have
195  /// other template parameter scopes as parents.
196  Scope *TemplateParamParent;
197 
198  /// DeclsInScope - This keeps track of all declarations in this scope. When
199  /// the declaration is added to the scope, it is set as the current
200  /// declaration for the identifier in the IdentifierTable. When the scope is
201  /// popped, these declarations are removed from the IdentifierTable's notion
202  /// of current declaration. It is up to the current Action implementation to
203  /// implement these semantics.
204  using DeclSetTy = llvm::SmallPtrSet<Decl *, 32>;
205  DeclSetTy DeclsInScope;
206 
207  /// The DeclContext with which this scope is associated. For
208  /// example, the entity of a class scope is the class itself, the
209  /// entity of a function scope is a function, etc.
210  DeclContext *Entity;
211 
212  using UsingDirectivesTy = SmallVector<UsingDirectiveDecl *, 2>;
213  UsingDirectivesTy UsingDirectives;
214 
215  /// Used to determine if errors occurred in this scope.
216  DiagnosticErrorTrap ErrorTrap;
217 
218  /// A single NRVO candidate variable in this scope.
219  /// There are three possible values:
220  /// 1) pointer to VarDecl that denotes NRVO candidate itself.
221  /// 2) nullptr value means that NRVO is not allowed in this scope
222  /// (e.g. return a function parameter).
223  /// 3) std::nullopt value means that there is no NRVO candidate in this scope
224  /// (i.e. there are no return statements in this scope).
225  std::optional<VarDecl *> NRVO;
226 
227  /// Represents return slots for NRVO candidates in the current scope.
228  /// If a variable is present in this set, it means that a return slot is
229  /// available for this variable in the current scope.
231 
232  void setFlags(Scope *Parent, unsigned F);
233 
234 public:
236  : ErrorTrap(Diag) {
238  }
239 
240  /// getFlags - Return the flags for this scope.
241  unsigned getFlags() const { return Flags; }
242 
243  void setFlags(unsigned F) { setFlags(getParent(), F); }
244 
245  /// isBlockScope - Return true if this scope correspond to a closure.
246  bool isBlockScope() const { return Flags & BlockScope; }
247 
248  /// getParent - Return the scope that this is nested in.
249  const Scope *getParent() const { return AnyParent; }
250  Scope *getParent() { return AnyParent; }
251 
252  /// getFnParent - Return the closest scope that is a function body.
253  const Scope *getFnParent() const { return FnParent; }
254  Scope *getFnParent() { return FnParent; }
255 
257  return MSLastManglingParent;
258  }
259  Scope *getMSLastManglingParent() { return MSLastManglingParent; }
260 
261  /// getContinueParent - Return the closest scope that a continue statement
262  /// would be affected by.
264  return ContinueParent;
265  }
266 
267  const Scope *getContinueParent() const {
268  return const_cast<Scope*>(this)->getContinueParent();
269  }
270 
271  // Set whether we're in the scope of a condition variable, where 'continue'
272  // is disallowed despite being a continue scope.
273  void setIsConditionVarScope(bool InConditionVarScope) {
274  Flags = (Flags & ~ConditionVarScope) |
275  (InConditionVarScope ? ConditionVarScope : 0);
276  }
277 
278  bool isConditionVarScope() const {
279  return Flags & ConditionVarScope;
280  }
281 
282  /// getBreakParent - Return the closest scope that a break statement
283  /// would be affected by.
285  return BreakParent;
286  }
287  const Scope *getBreakParent() const {
288  return const_cast<Scope*>(this)->getBreakParent();
289  }
290 
291  Scope *getBlockParent() { return BlockParent; }
292  const Scope *getBlockParent() const { return BlockParent; }
293 
294  Scope *getTemplateParamParent() { return TemplateParamParent; }
295  const Scope *getTemplateParamParent() const { return TemplateParamParent; }
296 
297  /// Returns the depth of this scope. The translation-unit has scope depth 0.
298  unsigned getDepth() const { return Depth; }
299 
300  /// Returns the number of function prototype scopes in this scope
301  /// chain.
302  unsigned getFunctionPrototypeDepth() const {
303  return PrototypeDepth;
304  }
305 
306  /// Return the number of parameters declared in this function
307  /// prototype, increasing it by one for the next call.
309  assert(isFunctionPrototypeScope());
310  return PrototypeIndex++;
311  }
312 
313  using decl_range = llvm::iterator_range<DeclSetTy::iterator>;
314 
315  decl_range decls() const {
316  return decl_range(DeclsInScope.begin(), DeclsInScope.end());
317  }
318 
319  bool decl_empty() const { return DeclsInScope.empty(); }
320 
321  void AddDecl(Decl *D) {
322  if (auto *VD = dyn_cast<VarDecl>(D))
323  if (!isa<ParmVarDecl>(VD))
324  ReturnSlots.insert(VD);
325 
326  DeclsInScope.insert(D);
327  }
328 
329  void RemoveDecl(Decl *D) { DeclsInScope.erase(D); }
330 
332  if (Scope *MSLMP = getMSLastManglingParent()) {
333  MSLMP->MSLastManglingNumber += 1;
334  MSCurManglingNumber += 1;
335  }
336  }
337 
339  if (Scope *MSLMP = getMSLastManglingParent()) {
340  MSLMP->MSLastManglingNumber -= 1;
341  MSCurManglingNumber -= 1;
342  }
343  }
344 
345  unsigned getMSLastManglingNumber() const {
346  if (const Scope *MSLMP = getMSLastManglingParent())
347  return MSLMP->MSLastManglingNumber;
348  return 1;
349  }
350 
351  unsigned getMSCurManglingNumber() const {
352  return MSCurManglingNumber;
353  }
354 
355  /// isDeclScope - Return true if this is the scope that the specified decl is
356  /// declared in.
357  bool isDeclScope(const Decl *D) const { return DeclsInScope.contains(D); }
358 
359  /// Get the entity corresponding to this scope.
361  return isTemplateParamScope() ? nullptr : Entity;
362  }
363 
364  /// Get the DeclContext in which to continue unqualified lookup after a
365  /// lookup in this scope.
366  DeclContext *getLookupEntity() const { return Entity; }
367 
369  assert(!isTemplateParamScope() &&
370  "entity associated with template param scope");
371  Entity = E;
372  }
373  void setLookupEntity(DeclContext *E) { Entity = E; }
374 
375  /// Determine whether any unrecoverable errors have occurred within this
376  /// scope. Note that this may return false even if the scope contains invalid
377  /// declarations or statements, if the errors for those invalid constructs
378  /// were suppressed because some prior invalid construct was referenced.
380  return ErrorTrap.hasUnrecoverableErrorOccurred();
381  }
382 
383  /// isFunctionScope() - Return true if this scope is a function scope.
384  bool isFunctionScope() const { return getFlags() & Scope::FnScope; }
385 
386  /// isClassScope - Return true if this scope is a class/struct/union scope.
387  bool isClassScope() const { return getFlags() & Scope::ClassScope; }
388 
389  /// Determines whether this scope is between inheritance colon and the real
390  /// class/struct definition.
391  bool isClassInheritanceScope() const {
393  }
394 
395  /// isInCXXInlineMethodScope - Return true if this scope is a C++ inline
396  /// method scope or is inside one.
398  if (const Scope *FnS = getFnParent()) {
399  assert(FnS->getParent() && "TUScope not created?");
400  return FnS->getParent()->isClassScope();
401  }
402  return false;
403  }
404 
405  /// isInObjcMethodScope - Return true if this scope is, or is contained in, an
406  /// Objective-C method body. Note that this method is not constant time.
407  bool isInObjcMethodScope() const {
408  for (const Scope *S = this; S; S = S->getParent()) {
409  // If this scope is an objc method scope, then we succeed.
410  if (S->getFlags() & ObjCMethodScope)
411  return true;
412  }
413  return false;
414  }
415 
416  /// isInObjcMethodOuterScope - Return true if this scope is an
417  /// Objective-C method outer most body.
419  if (const Scope *S = this) {
420  // If this scope is an objc method scope, then we succeed.
421  if (S->getFlags() & ObjCMethodScope)
422  return true;
423  }
424  return false;
425  }
426 
427  /// isTemplateParamScope - Return true if this scope is a C++
428  /// template parameter scope.
429  bool isTemplateParamScope() const {
431  }
432 
433  /// isFunctionPrototypeScope - Return true if this scope is a
434  /// function prototype scope.
437  }
438 
439  /// isFunctionDeclarationScope - Return true if this scope is a
440  /// function prototype scope.
443  }
444 
445  /// isAtCatchScope - Return true if this scope is \@catch.
446  bool isAtCatchScope() const {
447  return getFlags() & Scope::AtCatchScope;
448  }
449 
450  /// isCatchScope - Return true if this scope is a C++ catch statement.
451  bool isCatchScope() const { return getFlags() & Scope::CatchScope; }
452 
453  /// isSwitchScope - Return true if this scope is a switch scope.
454  bool isSwitchScope() const {
455  for (const Scope *S = this; S; S = S->getParent()) {
456  if (S->getFlags() & Scope::SwitchScope)
457  return true;
458  else if (S->getFlags() & (Scope::FnScope | Scope::ClassScope |
462  return false;
463  }
464  return false;
465  }
466 
467  /// Determines whether this scope is the OpenMP directive scope
468  bool isOpenMPDirectiveScope() const {
470  }
471 
472  /// Determine whether this scope is some OpenMP loop directive scope
473  /// (for example, 'omp for', 'omp simd').
476  assert(isOpenMPDirectiveScope() &&
477  "OpenMP loop directive scope is not a directive scope");
478  return true;
479  }
480  return false;
481  }
482 
483  /// Determine whether this scope is (or is nested into) some OpenMP
484  /// loop simd directive scope (for example, 'omp simd', 'omp for simd').
487  }
488 
489  /// Determine whether this scope is a loop having OpenMP loop
490  /// directive attached.
491  bool isOpenMPLoopScope() const {
492  const Scope *P = getParent();
493  return P && P->isOpenMPLoopDirectiveScope();
494  }
495 
496  /// Determine whether this scope is some OpenMP directive with
497  /// order clause which specifies concurrent scope.
500  }
501 
502  /// Determine whether this scope is a while/do/for statement, which can have
503  /// continue statements embedded into it.
504  bool isContinueScope() const {
505  return getFlags() & ScopeFlags::ContinueScope;
506  }
507 
508  /// Determine whether this scope is a C++ 'try' block.
509  bool isTryScope() const { return getFlags() & Scope::TryScope; }
510 
511  /// Determine whether this scope is a function-level C++ try or catch scope.
512  bool isFnTryCatchScope() const {
513  return getFlags() & ScopeFlags::FnTryCatchScope;
514  }
515 
516  /// Determine whether this scope is a SEH '__try' block.
517  bool isSEHTryScope() const { return getFlags() & Scope::SEHTryScope; }
518 
519  /// Determine whether this scope is a SEH '__except' block.
520  bool isSEHExceptScope() const { return getFlags() & Scope::SEHExceptScope; }
521 
522  /// Determine whether this scope is a compound statement scope.
523  bool isCompoundStmtScope() const {
525  }
526 
527  /// Determine whether this scope is a controlling scope in a
528  /// if/switch/while/for statement.
529  bool isControlScope() const { return getFlags() & Scope::ControlScope; }
530 
531  /// Returns if rhs has a higher scope depth than this.
532  ///
533  /// The caller is responsible for calling this only if one of the two scopes
534  /// is an ancestor of the other.
535  bool Contains(const Scope& rhs) const { return Depth < rhs.Depth; }
536 
537  /// containedInPrototypeScope - Return true if this or a parent scope
538  /// is a FunctionPrototypeScope.
539  bool containedInPrototypeScope() const;
540 
542  UsingDirectives.push_back(UDir);
543  }
544 
545  using using_directives_range =
546  llvm::iterator_range<UsingDirectivesTy::iterator>;
547 
549  return using_directives_range(UsingDirectives.begin(),
550  UsingDirectives.end());
551  }
552 
553  void updateNRVOCandidate(VarDecl *VD);
554 
555  void applyNRVO();
556 
557  /// Init - This is used by the parser to implement scope caching.
558  void Init(Scope *parent, unsigned flags);
559 
560  /// Sets up the specified scope flags and adjusts the scope state
561  /// variables accordingly.
562  void AddFlags(unsigned Flags);
563 
564  void dumpImpl(raw_ostream &OS) const;
565  void dump() const;
566 };
567 
568 } // namespace clang
569 
570 #endif // LLVM_CLANG_SEMA_SCOPE_H
clang::Scope::isFunctionScope
bool isFunctionScope() const
isFunctionScope() - Return true if this scope is a function scope.
Definition: Scope.h:384
clang::Scope::applyNRVO
void applyNRVO()
Definition: Scope.cpp:160
clang::Scope::getFnParent
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
Definition: Scope.h:253
clang::Scope::setFlags
void setFlags(unsigned F)
Definition: Scope.h:243
llvm
YAML serialization mapping.
Definition: Dominators.h:30
clang::Scope::isClassScope
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
Definition: Scope.h:387
clang::Scope::FunctionPrototypeScope
@ FunctionPrototypeScope
This is a scope that corresponds to the parameters within a function prototype.
Definition: Scope.h:82
clang::Scope::isOpenMPLoopDirectiveScope
bool isOpenMPLoopDirectiveScope() const
Determine whether this scope is some OpenMP loop directive scope (for example, 'omp for',...
Definition: Scope.h:474
clang::Scope::updateNRVOCandidate
void updateNRVOCandidate(VarDecl *VD)
Definition: Scope.cpp:131
clang::Scope::FnScope
@ FnScope
This indicates that the scope corresponds to a function, which means that labels are set here.
Definition: Scope.h:48
clang::Scope::getBlockParent
Scope * getBlockParent()
Definition: Scope.h:291
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1389
Diag
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.
Definition: LiteralSupport.cpp:79
clang::Scope::OpenMPLoopDirectiveScope
@ OpenMPLoopDirectiveScope
This is the scope of some OpenMP loop directive.
Definition: Scope.h:111
clang::UsingDirectiveDecl
Represents C++ using-directive.
Definition: DeclCXX.h:2929
llvm::SmallVector< UsingDirectiveDecl *, 2 >
clang::Scope::isFnTryCatchScope
bool isFnTryCatchScope() const
Determine whether this scope is a function-level C++ try or catch scope.
Definition: Scope.h:512
clang::Scope::BlockScope
@ BlockScope
This is a scope that corresponds to a block/closure object.
Definition: Scope.h:72
clang::DiagnosticsEngine
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:192
clang::Scope::isInObjcMethodOuterScope
bool isInObjcMethodOuterScope() const
isInObjcMethodOuterScope - Return true if this scope is an Objective-C method outer most body.
Definition: Scope.h:418
clang::Scope::getMSCurManglingNumber
unsigned getMSCurManglingNumber() const
Definition: Scope.h:351
clang::Scope::isCompoundStmtScope
bool isCompoundStmtScope() const
Determine whether this scope is a compound statement scope.
Definition: Scope.h:523
clang::Scope::setIsConditionVarScope
void setIsConditionVarScope(bool InConditionVarScope)
Definition: Scope.h:273
clang::Scope::isSwitchScope
bool isSwitchScope() const
isSwitchScope - Return true if this scope is a switch scope.
Definition: Scope.h:454
llvm::SmallPtrSet< Decl *, 32 >
clang::Scope::AddDecl
void AddDecl(Decl *D)
Definition: Scope.h:321
clang::DiagnosticErrorTrap::hasUnrecoverableErrorOccurred
bool hasUnrecoverableErrorOccurred() const
Determine whether any unrecoverable errors have occurred since this object instance was created.
Definition: Diagnostic.h:1089
clang::Scope::getDepth
unsigned getDepth() const
Returns the depth of this scope. The translation-unit has scope depth 0.
Definition: Scope.h:298
clang::Scope::ConditionVarScope
@ ConditionVarScope
This is a scope in which a condition variable is currently being parsed.
Definition: Scope.h:143
clang::Scope::SwitchScope
@ SwitchScope
This is a scope that corresponds to a switch statement.
Definition: Scope.h:99
clang::Scope::setLookupEntity
void setLookupEntity(DeclContext *E)
Definition: Scope.h:373
clang::DiagnosticErrorTrap
RAII class that determines when any errors have occurred between the time the instance was created an...
Definition: Diagnostic.h:1072
clang::Scope::containedInPrototypeScope
bool containedInPrototypeScope() const
containedInPrototypeScope - Return true if this or a parent scope is a FunctionPrototypeScope.
Definition: Scope.cpp:100
clang::Scope::getParent
const Scope * getParent() const
getParent - Return the scope that this is nested in.
Definition: Scope.h:249
clang::Scope::isFunctionPrototypeScope
bool isFunctionPrototypeScope() const
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
Definition: Scope.h:435
Decl.h
clang::Scope::decls
decl_range decls() const
Definition: Scope.h:315
clang::CodeGen::AlignmentSource::Decl
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
clang::Scope::OpenMPDirectiveScope
@ OpenMPDirectiveScope
This is the scope of OpenMP executable directive.
Definition: Scope.h:108
clang::Scope::SEHTryScope
@ SEHTryScope
This scope corresponds to an SEH try.
Definition: Scope.h:122
clang::Scope::decrementMSManglingNumber
void decrementMSManglingNumber()
Definition: Scope.h:338
clang::Scope::getMSLastManglingParent
const Scope * getMSLastManglingParent() const
Definition: Scope.h:256
clang::Scope::getTemplateParamParent
Scope * getTemplateParamParent()
Definition: Scope.h:294
clang::Scope
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:41
clang::Scope::isOpenMPDirectiveScope
bool isOpenMPDirectiveScope() const
Determines whether this scope is the OpenMP directive scope.
Definition: Scope.h:468
clang::Scope::isDeclScope
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
Definition: Scope.h:357
clang::Scope::dumpImpl
void dumpImpl(raw_ostream &OS) const
Definition: Scope.cpp:193
Diagnostic.h
clang::Scope::decl_empty
bool decl_empty() const
Definition: Scope.h:319
clang::Scope::isContinueScope
bool isContinueScope() const
Determine whether this scope is a while/do/for statement, which can have continue statements embedded...
Definition: Scope.h:504
clang::Scope::getParent
Scope * getParent()
Definition: Scope.h:250
clang::Scope::Init
void Init(Scope *parent, unsigned flags)
Init - This is used by the parser to implement scope caching.
Definition: Scope.cpp:90
clang::Scope::CompoundStmtScope
@ CompoundStmtScope
This is a compound statement scope.
Definition: Scope.h:131
clang::Scope::FunctionDeclarationScope
@ FunctionDeclarationScope
This is a scope that corresponds to the parameters within a function prototype for a function declara...
Definition: Scope.h:88
clang::Scope::hasUnrecoverableErrorOccurred
bool hasUnrecoverableErrorOccurred() const
Determine whether any unrecoverable errors have occurred within this scope.
Definition: Scope.h:379
clang::Scope::Scope
Scope(Scope *Parent, unsigned ScopeFlags, DiagnosticsEngine &Diag)
Definition: Scope.h:235
clang::Scope::isAtCatchScope
bool isAtCatchScope() const
isAtCatchScope - Return true if this scope is @catch.
Definition: Scope.h:446
clang::Scope::ContinueScope
@ ContinueScope
This is a while, do, for, which can have continue statements embedded into it.
Definition: Scope.h:56
clang::Scope::getMSLastManglingNumber
unsigned getMSLastManglingNumber() const
Definition: Scope.h:345
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:915
clang::Scope::isOpenMPLoopScope
bool isOpenMPLoopScope() const
Determine whether this scope is a loop having OpenMP loop directive attached.
Definition: Scope.h:491
clang::Scope::isSEHExceptScope
bool isSEHExceptScope() const
Determine whether this scope is a SEH '__except' block.
Definition: Scope.h:520
clang::Scope::getFunctionPrototypeDepth
unsigned getFunctionPrototypeDepth() const
Returns the number of function prototype scopes in this scope chain.
Definition: Scope.h:302
clang::Scope::getLookupEntity
DeclContext * getLookupEntity() const
Get the DeclContext in which to continue unqualified lookup after a lookup in this scope.
Definition: Scope.h:366
clang::Scope::isTemplateParamScope
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
Definition: Scope.h:429
clang::Scope::ControlScope
@ ControlScope
The controlling scope in a if/switch/while/for statement.
Definition: Scope.h:63
clang::Scope::isOpenMPOrderClauseScope
bool isOpenMPOrderClauseScope() const
Determine whether this scope is some OpenMP directive with order clause which specifies concurrent sc...
Definition: Scope.h:498
clang::Scope::EnumScope
@ EnumScope
This scope corresponds to an enum.
Definition: Scope.h:119
clang::Scope::using_directives
using_directives_range using_directives()
Definition: Scope.h:548
clang::Scope::isCatchScope
bool isCatchScope() const
isCatchScope - Return true if this scope is a C++ catch statement.
Definition: Scope.h:451
clang::Scope::getTemplateParamParent
const Scope * getTemplateParamParent() const
Definition: Scope.h:295
clang::Scope::AddFlags
void AddFlags(unsigned Flags)
Sets up the specified scope flags and adjusts the scope state variables accordingly.
Definition: Scope.cpp:110
clang::Scope::incrementMSManglingNumber
void incrementMSManglingNumber()
Definition: Scope.h:331
clang::Scope::getBreakParent
const Scope * getBreakParent() const
Definition: Scope.h:287
clang::Scope::isInCXXInlineMethodScope
bool isInCXXInlineMethodScope() const
isInCXXInlineMethodScope - Return true if this scope is a C++ inline method scope or is inside one.
Definition: Scope.h:397
P
StringRef P
Definition: ASTMatchersInternal.cpp:564
clang::Scope::dump
void dump() const
Definition: Scope.cpp:191
clang::Scope::getFnParent
Scope * getFnParent()
Definition: Scope.h:254
clang::Scope::TemplateParamScope
@ TemplateParamScope
This is a scope that corresponds to the template parameters of a C++ template.
Definition: Scope.h:78
clang::Scope::isInObjcMethodScope
bool isInObjcMethodScope() const
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body.
Definition: Scope.h:407
clang::Scope::getBreakParent
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by.
Definition: Scope.h:284
clang::Scope::AtCatchScope
@ AtCatchScope
This is a scope that corresponds to the Objective-C @catch statement.
Definition: Scope.h:92
clang::Scope::decl_range
llvm::iterator_range< DeclSetTy::iterator > decl_range
Definition: Scope.h:313
clang::Scope::ClassInheritanceScope
@ ClassInheritanceScope
We are between inheritance colon and the real class/struct definition scope.
Definition: Scope.h:135
clang::Scope::ClassScope
@ ClassScope
The scope of a struct/union/class definition.
Definition: Scope.h:66
clang::Scope::getFlags
unsigned getFlags() const
getFlags - Return the flags for this scope.
Definition: Scope.h:241
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
clang::Scope::isSEHTryScope
bool isSEHTryScope() const
Determine whether this scope is a SEH '__try' block.
Definition: Scope.h:517
clang::Scope::SEHExceptScope
@ SEHExceptScope
This scope corresponds to an SEH except.
Definition: Scope.h:125
clang::Scope::isOpenMPSimdDirectiveScope
bool isOpenMPSimdDirectiveScope() const
Determine whether this scope is (or is nested into) some OpenMP loop simd directive scope (for exampl...
Definition: Scope.h:485
clang::Scope::setEntity
void setEntity(DeclContext *E)
Definition: Scope.h:368
clang::Scope::getContinueParent
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by.
Definition: Scope.h:263
clang::Scope::OpenMPOrderClauseScope
@ OpenMPOrderClauseScope
This is a scope of some OpenMP directive with order clause which specifies concurrent.
Definition: Scope.h:147
clang::Scope::getNextFunctionPrototypeIndex
unsigned getNextFunctionPrototypeIndex()
Return the number of parameters declared in this function prototype, increasing it by one for the nex...
Definition: Scope.h:308
clang
Definition: CalledOnceCheck.h:17
clang::Scope::CatchScope
@ CatchScope
This is the scope of a C++ catch statement.
Definition: Scope.h:138
clang::Scope::ScopeFlags
ScopeFlags
ScopeFlags - These are bitfields that are or'd together when creating a scope, which defines the sort...
Definition: Scope.h:45
clang::Scope::getEntity
DeclContext * getEntity() const
Get the entity corresponding to this scope.
Definition: Scope.h:360
clang::Scope::getMSLastManglingParent
Scope * getMSLastManglingParent()
Definition: Scope.h:259
clang::Scope::SEHFilterScope
@ SEHFilterScope
We are currently in the filter expression of an SEH except block.
Definition: Scope.h:128
clang::Scope::isControlScope
bool isControlScope() const
Determine whether this scope is a controlling scope in a if/switch/while/for statement.
Definition: Scope.h:529
clang::Scope::getBlockParent
const Scope * getBlockParent() const
Definition: Scope.h:292
clang::Scope::RemoveDecl
void RemoveDecl(Decl *D)
Definition: Scope.h:329
clang::Scope::ObjCMethodScope
@ ObjCMethodScope
This scope corresponds to an Objective-C method body.
Definition: Scope.h:96
clang::Scope::Contains
bool Contains(const Scope &rhs) const
Returns if rhs has a higher scope depth than this.
Definition: Scope.h:535
Parent
NodeId Parent
Definition: ASTDiff.cpp:191
clang::Scope::isBlockScope
bool isBlockScope() const
isBlockScope - Return true if this scope correspond to a closure.
Definition: Scope.h:246
clang::Scope::isFunctionDeclarationScope
bool isFunctionDeclarationScope() const
isFunctionDeclarationScope - Return true if this scope is a function prototype scope.
Definition: Scope.h:441
clang::Scope::TryScope
@ TryScope
This is the scope of a C++ try statement.
Definition: Scope.h:102
clang::Scope::DeclScope
@ DeclScope
This is a scope that can contain a declaration.
Definition: Scope.h:60
clang::Scope::FnTryCatchScope
@ FnTryCatchScope
This is the scope for a function-level C++ try or catch scope.
Definition: Scope.h:105
clang::Scope::BreakScope
@ BreakScope
This is a while, do, switch, for, etc that can have break statements embedded into it.
Definition: Scope.h:52
clang::Scope::getContinueParent
const Scope * getContinueParent() const
Definition: Scope.h:267
clang::Scope::OpenMPSimdDirectiveScope
@ OpenMPSimdDirectiveScope
This is the scope of some OpenMP simd directive.
Definition: Scope.h:116
clang::Scope::isConditionVarScope
bool isConditionVarScope() const
Definition: Scope.h:278
clang::Scope::isTryScope
bool isTryScope() const
Determine whether this scope is a C++ 'try' block.
Definition: Scope.h:509
clang::Scope::PushUsingDirective
void PushUsingDirective(UsingDirectiveDecl *UDir)
Definition: Scope.h:541
clang::Scope::using_directives_range
llvm::iterator_range< UsingDirectivesTy::iterator > using_directives_range
Definition: Scope.h:546
clang::Scope::isClassInheritanceScope
bool isClassInheritanceScope() const
Determines whether this scope is between inheritance colon and the real class/struct definition.
Definition: Scope.h:391