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