 |
|
 |
|
| Files: |
1 |
|
Branches Taken: |
68.4% |
106 / 155 |
| Generated: |
2010-02-10 01:31 |
|
Branches Executed: |
72.3% |
112 / 155 |
| |
|
Line Coverage: |
97.6% |
200 / 205 |
| |
 |
|
 |
 |
|
 |
|
| Programs: |
171 |
|
Runs |
337155 |
| |
 |
|
 |
1 : //===-- DeclBase.h - Base Classes for representing declarations -*- C++ -*-===//
2 : //
3 : // The LLVM Compiler Infrastructure
4 : //
5 : // This file is distributed under the University of Illinois Open Source
6 : // License. See LICENSE.TXT for details.
7 : //
8 : //===----------------------------------------------------------------------===//
9 : //
10 : // This file defines the Decl and DeclContext interfaces.
11 : //
12 : //===----------------------------------------------------------------------===//
13 :
14 : #ifndef LLVM_CLANG_AST_DECLBASE_H
15 : #define LLVM_CLANG_AST_DECLBASE_H
16 :
17 : #include "clang/AST/Attr.h"
18 : #include "clang/AST/Type.h"
19 : #include "clang/Basic/Specifiers.h"
20 : #include "llvm/Support/PrettyStackTrace.h"
21 : #include "llvm/ADT/PointerUnion.h"
22 :
23 : namespace clang {
24 : class DeclContext;
25 : class TranslationUnitDecl;
26 : class NamespaceDecl;
27 : class UsingDirectiveDecl;
28 : class NamedDecl;
29 : class FunctionDecl;
30 : class CXXRecordDecl;
31 : class EnumDecl;
32 : class ObjCMethodDecl;
33 : class ObjCContainerDecl;
34 : class ObjCInterfaceDecl;
35 : class ObjCCategoryDecl;
36 : class ObjCProtocolDecl;
37 : class ObjCImplementationDecl;
38 : class ObjCCategoryImplDecl;
39 : class ObjCImplDecl;
40 : class LinkageSpecDecl;
41 : class BlockDecl;
42 : class DeclarationName;
43 : class CompoundStmt;
44 : }
45 :
46 : namespace llvm {
47 : // DeclContext* is only 4-byte aligned on 32-bit systems.
48 : template<>
49 : class PointerLikeTypeTraits<clang::DeclContext*> {
50 : typedef clang::DeclContext* PT;
51 : public:
52 210560: static inline void *getAsVoidPointer(PT P) { return P; }
53 1928151: static inline PT getFromVoidPointer(void *P) {
54 1928151: return static_cast<PT>(P);
55 : }
56 : enum { NumLowBitsAvailable = 2 };
57 : };
58 : }
59 :
60 : namespace clang {
61 :
62 : /// Decl - This represents one declaration (or definition), e.g. a variable,
63 : /// typedef, function, struct, etc.
64 : ///
65 : class Decl {
66 : public:
67 : /// \brief Lists the kind of concrete classes of Decl.
68 : enum Kind {
69 : #define DECL(Derived, Base) Derived,
70 : #define DECL_RANGE(CommonBase, Start, End) \
71 : CommonBase##First = Start, CommonBase##Last = End,
72 : #define LAST_DECL_RANGE(CommonBase, Start, End) \
73 : CommonBase##First = Start, CommonBase##Last = End
74 : #include "clang/AST/DeclNodes.def"
75 : };
76 :
77 : /// IdentifierNamespace - According to C99 6.2.3, there are four
78 : /// namespaces, labels, tags, members and ordinary
79 : /// identifiers. These are meant as bitmasks, so that searches in
80 : /// C++ can look into the "tag" namespace during ordinary lookup. We
81 : /// use additional namespaces for Objective-C entities. We also put
82 : /// C++ friend declarations (of previously-undeclared entities) in
83 : /// shadow namespaces, and 'using' declarations (as opposed to their
84 : /// implicit shadow declarations) can be found in their own
85 : /// namespace.
86 : enum IdentifierNamespace {
87 : IDNS_Label = 0x1,
88 : IDNS_Tag = 0x2,
89 : IDNS_Member = 0x4,
90 : IDNS_Ordinary = 0x8,
91 : IDNS_ObjCProtocol = 0x10,
92 : IDNS_ObjCImplementation = 0x20,
93 : IDNS_ObjCCategoryName = 0x40,
94 : IDNS_OrdinaryFriend = 0x80,
95 : IDNS_TagFriend = 0x100,
96 : IDNS_Using = 0x200
97 : };
98 :
99 : /// ObjCDeclQualifier - Qualifier used on types in method declarations
100 : /// for remote messaging. They are meant for the arguments though and
101 : /// applied to the Decls (ObjCMethodDecl and ParmVarDecl).
102 : enum ObjCDeclQualifier {
103 : OBJC_TQ_None = 0x0,
104 : OBJC_TQ_In = 0x1,
105 : OBJC_TQ_Inout = 0x2,
106 : OBJC_TQ_Out = 0x4,
107 : OBJC_TQ_Bycopy = 0x8,
108 : OBJC_TQ_Byref = 0x10,
109 : OBJC_TQ_Oneway = 0x20
110 : };
111 :
112 : private:
113 : /// NextDeclInContext - The next declaration within the same lexical
114 : /// DeclContext. These pointers form the linked list that is
115 : /// traversed via DeclContext's decls_begin()/decls_end().
116 : Decl *NextDeclInContext;
117 :
118 : friend class DeclContext;
119 :
120 : struct MultipleDC {
121 : DeclContext *SemanticDC;
122 : DeclContext *LexicalDC;
123 : };
124 :
125 :
126 : /// DeclCtx - Holds either a DeclContext* or a MultipleDC*.
127 : /// For declarations that don't contain C++ scope specifiers, it contains
128 : /// the DeclContext where the Decl was declared.
129 : /// For declarations with C++ scope specifiers, it contains a MultipleDC*
130 : /// with the context where it semantically belongs (SemanticDC) and the
131 : /// context where it was lexically declared (LexicalDC).
132 : /// e.g.:
133 : ///
134 : /// namespace A {
135 : /// void f(); // SemanticDC == LexicalDC == 'namespace A'
136 : /// }
137 : /// void A::f(); // SemanticDC == namespace 'A'
138 : /// // LexicalDC == global namespace
139 : llvm::PointerUnion<DeclContext*, MultipleDC*> DeclCtx;
140 :
141 1980119: inline bool isInSemaDC() const { return DeclCtx.is<DeclContext*>(); }
142 20922: inline bool isOutOfSemaDC() const { return DeclCtx.is<MultipleDC*>(); }
143 50830: inline MultipleDC *getMultipleDC() const {
144 50830: return DeclCtx.get<MultipleDC*>();
145 : }
146 1927534: inline DeclContext *getSemanticDC() const {
147 1927534: return DeclCtx.get<DeclContext*>();
148 : }
149 :
150 : /// Loc - The location that this decl.
151 : SourceLocation Loc;
152 :
153 : /// DeclKind - This indicates which class this is.
154 : Kind DeclKind : 8;
155 :
156 : /// InvalidDecl - This indicates a semantic error occurred.
157 : unsigned int InvalidDecl : 1;
158 :
159 : /// HasAttrs - This indicates whether the decl has attributes or not.
160 : unsigned int HasAttrs : 1;
161 :
162 : /// Implicit - Whether this declaration was implicitly generated by
163 : /// the implementation rather than explicitly written by the user.
164 : bool Implicit : 1;
165 :
166 : /// \brief Whether this declaration was "used", meaning that a definition is
167 : /// required.
168 : bool Used : 1;
169 :
170 : protected:
171 : /// Access - Used by C++ decls for the access specifier.
172 : // NOTE: VC++ treats enums as signed, avoid using the AccessSpecifier enum
173 : unsigned Access : 2;
174 : friend class CXXClassMemberWrapper;
175 :
176 : // PCHLevel - the "level" of precompiled header/AST file from which this
177 : // declaration was built.
178 : unsigned PCHLevel : 2;
179 :
180 : /// IdentifierNamespace - This specifies what IDNS_* namespace this lives in.
181 : unsigned IdentifierNamespace : 16;
182 :
183 : private:
184 : #ifndef NDEBUG
185 : void CheckAccessDeclContext() const;
186 : #else
187 : void CheckAccessDeclContext() const { }
188 : #endif
189 :
190 : protected:
191 :
192 120408: Decl(Kind DK, DeclContext *DC, SourceLocation L)
193 : : NextDeclInContext(0), DeclCtx(DC),
194 : Loc(L), DeclKind(DK), InvalidDecl(0),
195 : HasAttrs(false), Implicit(false), Used(false),
196 : Access(AS_none), PCHLevel(0),
197 120408: IdentifierNamespace(getIdentifierNamespaceForKind(DK)) {
6: branch 1 taken
120402: branch 2 taken
198 120408: if (Decl::CollectingStats()) addDeclKind(DK);
199 120408: }
200 :
201 : virtual ~Decl();
202 :
203 : public:
204 :
205 : /// \brief Source range that this declaration covers.
206 89917: virtual SourceRange getSourceRange() const {
207 89917: return SourceRange(getLocation(), getLocation());
208 : }
209 55: SourceLocation getLocStart() const { return getSourceRange().getBegin(); }
210 17624: SourceLocation getLocEnd() const { return getSourceRange().getEnd(); }
211 :
212 412429: SourceLocation getLocation() const { return Loc; }
213 678: void setLocation(SourceLocation L) { Loc = L; }
214 :
215 6580735: Kind getKind() const { return DeclKind; }
216 : const char *getDeclKindName() const;
217 :
218 523252: Decl *getNextDeclInContext() { return NextDeclInContext; }
219 : const Decl *getNextDeclInContext() const { return NextDeclInContext; }
220 :
221 1760553: DeclContext *getDeclContext() {
1713908: branch 1 taken
46645: branch 2 taken
222 1760553: if (isInSemaDC())
223 1713908: return getSemanticDC();
224 46645: return getMultipleDC()->SemanticDC;
225 : }
226 787426: const DeclContext *getDeclContext() const {
227 787426: return const_cast<Decl*>(this)->getDeclContext();
228 : }
229 :
230 : TranslationUnitDecl *getTranslationUnitDecl();
231 319650: const TranslationUnitDecl *getTranslationUnitDecl() const {
232 319650: return const_cast<Decl*>(this)->getTranslationUnitDecl();
233 : }
234 :
235 : bool isInAnonymousNamespace() const;
236 :
237 : ASTContext &getASTContext() const;
238 :
239 38849: void setAccess(AccessSpecifier AS) {
240 38849: Access = AS;
241 38849: CheckAccessDeclContext();
242 38849: }
243 :
244 110437: AccessSpecifier getAccess() const {
245 110437: CheckAccessDeclContext();
246 110437: return AccessSpecifier(Access);
247 : }
248 :
249 4078: bool hasAttrs() const { return HasAttrs; }
250 : void addAttr(Attr *attr);
251 461968: const Attr *getAttrs() const {
0: branch 1 not taken
0: branch 1 not taken
252 461968: if (!HasAttrs) return 0; // common case, no attributes.
253 25273: return getAttrsImpl(); // Uncommon case, out of line hash lookup.
254 : }
255 : void swapAttrs(Decl *D);
256 : void invalidateAttrs();
257 :
258 460545: template<typename T> const T *getAttr() const {
5385: branch 2 taken
131442: branch 3 taken
12041: branch 6 taken
109297: branch 7 taken
3385: branch 10 taken
25128: branch 11 taken
1414: branch 14 taken
15786: branch 15 taken
441: branch 18 taken
38342: branch 19 taken
300: branch 22 taken
5431: branch 23 taken
2345: branch 26 taken
67953: branch 27 taken
2847: branch 30 taken
12977: branch 31 taken
375: branch 34 taken
6799: branch 35 taken
0: branch 38 not taken
14: branch 39 taken
86: branch 42 taken
2764: branch 43 taken
90: branch 46 taken
2771: branch 47 taken
333: branch 50 taken
15614: branch 51 taken
25: branch 54 taken
1433: branch 55 taken
141: branch 58 taken
9153: branch 59 taken
259 491548: for (const Attr *attr = getAttrs(); attr; attr = attr->getNext())
918: branch 1 taken
4467: branch 2 taken
11276: branch 5 taken
543: branch 11 taken
1432: branch 13 taken
161: branch 14 taken
601: branch 16 taken
4: branch 17 taken
311: branch 19 taken
2300: branch 20 taken
30: branch 22 taken
6: branch 23 taken
2841: branch 25 taken
14: branch 26 taken
361: branch 28 taken
0: branch 29 not taken
0: branch 29 not taken
13: branch 31 taken
73: branch 32 taken
6: branch 34 taken
84: branch 35 taken
65: branch 37 taken
268: branch 38 taken
25: branch 40 taken
0: branch 41 not taken
13: branch 43 taken
128: branch 44 taken
260 33250: if (const T *V = dyn_cast<T>(attr))
261 2247: return V;
262 458298: return 0;
263 : }
264 :
265 198250: template<typename T> bool hasAttr() const {
266 198250: return getAttr<T>() != 0;
267 : }
268 :
269 : /// setInvalidDecl - Indicates the Decl had a semantic error. This
270 : /// allows for graceful error recovery.
271 1638: void setInvalidDecl(bool Invalid = true) { InvalidDecl = Invalid; }
272 244009: bool isInvalidDecl() const { return (bool) InvalidDecl; }
273 :
274 : /// isImplicit - Indicates whether the declaration was implicitly
275 : /// generated by the implementation. If false, this declaration
276 : /// was written explicitly in the source code.
277 34836: bool isImplicit() const { return Implicit; }
278 34214: void setImplicit(bool I = true) { Implicit = I; }
279 :
280 : /// \brief Whether this declaration was used, meaning that a definition
281 : /// is required.
282 94891: bool isUsed() const { return Used; }
283 29711: void setUsed(bool U = true) { Used = U; }
284 :
285 : /// \brief Retrieve the level of precompiled header from which this
286 : /// declaration was generated.
287 : ///
288 : /// The PCH level of a declaration describes where the declaration originated
289 : /// from. A PCH level of 0 indicates that the declaration was not from a
290 : /// precompiled header. A PCH level of 1 indicates that the declaration was
291 : /// from a top-level precompiled header; 2 indicates that the declaration
292 : /// comes from a precompiled header on which the top-level precompiled header
293 : /// depends, and so on.
294 2187: unsigned getPCHLevel() const { return PCHLevel; }
295 :
296 : /// \brief The maximum PCH level that any declaration may have.
297 : static const unsigned MaxPCHLevel = 3;
298 :
299 : /// \brief Set the PCH level of this declaration.
300 517: void setPCHLevel(unsigned Level) {
0: branch 0 not taken
517: branch 1 taken
301 517: assert(Level < MaxPCHLevel && "PCH level exceeds the maximum");
302 517: PCHLevel = Level;
303 517: }
304 :
305 116735: unsigned getIdentifierNamespace() const {
306 116735: return IdentifierNamespace;
307 : }
308 97143: bool isInIdentifierNamespace(unsigned NS) const {
309 97143: return getIdentifierNamespace() & NS;
310 : }
311 : static unsigned getIdentifierNamespaceForKind(Kind DK);
312 :
313 :
314 : /// getLexicalDeclContext - The declaration context where this Decl was
315 : /// lexically declared (LexicalDC). May be different from
316 : /// getDeclContext() (SemanticDC).
317 : /// e.g.:
318 : ///
319 : /// namespace A {
320 : /// void f(); // SemanticDC == LexicalDC == 'namespace A'
321 : /// }
322 : /// void A::f(); // SemanticDC == namespace 'A'
323 : /// // LexicalDC == global namespace
324 217810: DeclContext *getLexicalDeclContext() {
213626: branch 1 taken
4184: branch 2 taken
325 217810: if (isInSemaDC())
326 213626: return getSemanticDC();
327 4184: return getMultipleDC()->LexicalDC;
328 : }
329 51804: const DeclContext *getLexicalDeclContext() const {
330 51804: return const_cast<Decl*>(this)->getLexicalDeclContext();
331 : }
332 :
333 24808: bool isOutOfLine() const {
334 24808: return getLexicalDeclContext() != getDeclContext();
335 : }
336 :
337 : /// setDeclContext - Set both the semantic and lexical DeclContext
338 : /// to DC.
339 : void setDeclContext(DeclContext *DC);
340 :
341 : void setLexicalDeclContext(DeclContext *DC);
342 :
343 : // isDefinedOutsideFunctionOrMethod - This predicate returns true if this
344 : // scoped decl is defined outside the current function or method. This is
345 : // roughly global variables and functions, but also handles enums (which could
346 : // be defined inside or outside a function etc).
347 : bool isDefinedOutsideFunctionOrMethod() const;
348 :
349 : /// \brief Retrieves the "canonical" declaration of the given declaration.
350 748: virtual Decl *getCanonicalDecl() { return this; }
351 17728: const Decl *getCanonicalDecl() const {
352 17728: return const_cast<Decl*>(this)->getCanonicalDecl();
353 : }
354 :
355 : /// \brief Whether this particular Decl is a canonical one.
356 151: bool isCanonicalDecl() const { return getCanonicalDecl() == this; }
357 :
358 : protected:
359 : /// \brief Returns the next redeclaration or itself if this is the only decl.
360 : ///
361 : /// Decl subclasses that can be redeclared should override this method so that
362 : /// Decl::redecl_iterator can iterate over them.
363 0: virtual Decl *getNextRedeclaration() { return this; }
364 :
365 : public:
366 : /// \brief Iterates through all the redeclarations of the same decl.
367 : class redecl_iterator {
368 : /// Current - The current declaration.
369 : Decl *Current;
370 : Decl *Starter;
371 :
372 : public:
373 : typedef Decl* value_type;
374 : typedef Decl* reference;
375 : typedef Decl* pointer;
376 : typedef std::forward_iterator_tag iterator_category;
377 : typedef std::ptrdiff_t difference_type;
378 :
379 : redecl_iterator() : Current(0) { }
380 : explicit redecl_iterator(Decl *C) : Current(C), Starter(C) { }
381 :
382 : reference operator*() const { return Current; }
383 : pointer operator->() const { return Current; }
384 :
385 : redecl_iterator& operator++() {
386 : assert(Current && "Advancing while iterator has reached end");
387 : // Get either previous decl or latest decl.
388 : Decl *Next = Current->getNextRedeclaration();
389 : assert(Next && "Should return next redeclaration or itself, never null!");
390 : Current = (Next != Starter ? Next : 0);
391 : return *this;
392 : }
393 :
394 : redecl_iterator operator++(int) {
395 : redecl_iterator tmp(*this);
396 : ++(*this);
397 : return tmp;
398 : }
399 :
400 : friend bool operator==(redecl_iterator x, redecl_iterator y) {
401 : return x.Current == y.Current;
402 : }
403 : friend bool operator!=(redecl_iterator x, redecl_iterator y) {
404 : return x.Current != y.Current;
405 : }
406 : };
407 :
408 : /// \brief Returns iterator for all the redeclarations of the same decl.
409 : /// It will iterate at least once (when this decl is the only one).
410 : redecl_iterator redecls_begin() const {
411 : return redecl_iterator(const_cast<Decl*>(this));
412 : }
413 : redecl_iterator redecls_end() const { return redecl_iterator(); }
414 :
415 : /// getBody - If this Decl represents a declaration for a body of code,
416 : /// such as a function or method definition, this method returns the
417 : /// top-level Stmt* of that body. Otherwise this method returns null.
418 0: virtual Stmt* getBody() const { return 0; }
419 :
420 : /// getCompoundBody - Returns getBody(), dyn_casted to a CompoundStmt.
421 : CompoundStmt* getCompoundBody() const;
422 :
423 : /// getBodyRBrace - Gets the right brace of the body, if a body exists.
424 : /// This works whether the body is a CompoundStmt or a CXXTryStmt.
425 : SourceLocation getBodyRBrace() const;
426 :
427 : // global temp stats (until we have a per-module visitor)
428 : static void addDeclKind(Kind k);
429 : static bool CollectingStats(bool Enable = false);
430 : static void PrintStats();
431 :
432 : /// isTemplateParameter - Determines whether this declaration is a
433 : /// template parameter.
434 : bool isTemplateParameter() const;
435 :
436 : /// isTemplateParameter - Determines whether this declaration is a
437 : /// template parameter pack.
438 : bool isTemplateParameterPack() const;
439 :
440 : /// \brief Whether this declaration is a function or function template.
441 : bool isFunctionOrFunctionTemplate() const;
442 :
443 : /// \brief Changes the namespace of this declaration to reflect that it's
444 : /// the object of a friend declaration.
445 : ///
446 : /// These declarations appear in the lexical context of the friending
447 : /// class, but in the semantic context of the actual entity. This property
448 : /// applies only to a specific decl object; other redeclarations of the
449 : /// same entity may not (and probably don't) share this property.
450 72: void setObjectOfFriendDecl(bool PreviouslyDeclared) {
451 72: unsigned OldNS = IdentifierNamespace;
452 : assert((OldNS == IDNS_Tag || OldNS == IDNS_Ordinary ||
453 : OldNS == (IDNS_Tag | IDNS_Ordinary))
59: branch 0 taken
13: branch 1 taken
30: branch 2 taken
29: branch 3 taken
0: branch 4 not taken
30: branch 5 taken
454 72: && "unsupported namespace for undeclared friend");
46: branch 0 taken
26: branch 1 taken
455 72: if (!PreviouslyDeclared) IdentifierNamespace = 0;
456 :
13: branch 0 taken
59: branch 1 taken
457 72: if (OldNS == IDNS_Tag)
458 13: IdentifierNamespace |= IDNS_TagFriend;
459 : else
460 59: IdentifierNamespace |= IDNS_OrdinaryFriend;
461 72: }
462 :
463 : enum FriendObjectKind {
464 : FOK_None, // not a friend object
465 : FOK_Declared, // a friend of a previously-declared entity
466 : FOK_Undeclared // a friend of a previously-undeclared entity
467 : };
468 :
469 : /// \brief Determines whether this declaration is the object of a
470 : /// friend declaration and, if so, what kind.
471 : ///
472 : /// There is currently no direct way to find the associated FriendDecl.
473 3684: FriendObjectKind getFriendObjectKind() const {
474 : unsigned mask
475 3684: = (IdentifierNamespace & (IDNS_TagFriend | IDNS_OrdinaryFriend));
3597: branch 0 taken
87: branch 1 taken
476 3684: if (!mask) return FOK_None;
477 : return (IdentifierNamespace & (IDNS_Tag | IDNS_Ordinary) ?
39: branch 0 taken
48: branch 1 taken
478 87: FOK_Declared : FOK_Undeclared);
479 : }
480 :
481 : // Implement isa/cast/dyncast/etc.
482 : static bool classof(const Decl *) { return true; }
483 535429: static bool classofKind(Kind K) { return true; }
484 : static DeclContext *castToDeclContext(const Decl *);
485 : static Decl *castFromDeclContext(const DeclContext *);
486 :
487 : /// Destroy - Call destructors and release memory.
488 : virtual void Destroy(ASTContext& C);
489 :
490 : void print(llvm::raw_ostream &Out, unsigned Indentation = 0) const;
491 : void print(llvm::raw_ostream &Out, const PrintingPolicy &Policy,
492 : unsigned Indentation = 0) const;
493 : static void printGroup(Decl** Begin, unsigned NumDecls,
494 : llvm::raw_ostream &Out, const PrintingPolicy &Policy,
495 : unsigned Indentation = 0);
496 : void dump() const;
497 :
498 : private:
499 : const Attr *getAttrsImpl() const;
500 :
501 : };
502 :
503 : /// PrettyStackTraceDecl - If a crash occurs, indicate that it happened when
504 : /// doing something to a specific decl.
0: branch 1 not taken
13509: branch 2 taken
0: branch 5 not taken
0: branch 6 not taken
505 13509: class PrettyStackTraceDecl : public llvm::PrettyStackTraceEntry {
506 : const Decl *TheDecl;
507 : SourceLocation Loc;
508 : SourceManager &SM;
509 : const char *Message;
510 : public:
511 : PrettyStackTraceDecl(const Decl *theDecl, SourceLocation L,
512 13509: SourceManager &sm, const char *Msg)
513 13509: : TheDecl(theDecl), Loc(L), SM(sm), Message(Msg) {}
514 :
515 : virtual void print(llvm::raw_ostream &OS) const;
516 : };
517 :
518 :
519 : /// DeclContext - This is used only as base class of specific decl types that
520 : /// can act as declaration contexts. These decls are (only the top classes
521 : /// that directly derive from DeclContext are mentioned, not their subclasses):
522 : ///
523 : /// TranslationUnitDecl
524 : /// NamespaceDecl
525 : /// FunctionDecl
526 : /// TagDecl
527 : /// ObjCMethodDecl
528 : /// ObjCContainerDecl
529 : /// LinkageSpecDecl
530 : /// BlockDecl
531 : ///
532 : class DeclContext {
533 : /// DeclKind - This indicates which class this is.
534 : Decl::Kind DeclKind : 8;
535 :
536 : /// \brief Whether this declaration context also has some external
537 : /// storage that contains additional declarations that are lexically
538 : /// part of this context.
539 : mutable bool ExternalLexicalStorage : 1;
540 :
541 : /// \brief Whether this declaration context also has some external
542 : /// storage that contains additional declarations that are visible
543 : /// in this context.
544 : mutable bool ExternalVisibleStorage : 1;
545 :
546 : /// \brief Pointer to the data structure used to lookup declarations
547 : /// within this context, which is a DenseMap<DeclarationName,
548 : /// StoredDeclsList>.
549 : mutable void* LookupPtr;
550 :
551 : /// FirstDecl - The first declaration stored within this declaration
552 : /// context.
553 : mutable Decl *FirstDecl;
554 :
555 : /// LastDecl - The last declaration stored within this declaration
556 : /// context. FIXME: We could probably cache this value somewhere
557 : /// outside of the DeclContext, to reduce the size of DeclContext by
558 : /// another pointer.
559 : mutable Decl *LastDecl;
560 :
561 : protected:
562 56585: DeclContext(Decl::Kind K)
563 : : DeclKind(K), ExternalLexicalStorage(false),
564 : ExternalVisibleStorage(false), LookupPtr(0), FirstDecl(0),
565 56585: LastDecl(0) { }
566 :
567 : void DestroyDecls(ASTContext &C);
568 :
569 : public:
570 : ~DeclContext();
571 :
572 2865334: Decl::Kind getDeclKind() const {
573 2865334: return DeclKind;
574 : }
575 : const char *getDeclKindName() const;
576 :
577 : /// getParent - Returns the containing DeclContext.
578 441566: DeclContext *getParent() {
579 441566: return cast<Decl>(this)->getDeclContext();
580 : }
581 286515: const DeclContext *getParent() const {
582 286515: return const_cast<DeclContext*>(this)->getParent();
583 : }
584 :
585 : /// getLexicalParent - Returns the containing lexical DeclContext. May be
586 : /// different from getParent, e.g.:
587 : ///
588 : /// namespace A {
589 : /// struct S;
590 : /// }
591 : /// struct A::S {}; // getParent() == namespace 'A'
592 : /// // getLexicalParent() == translation unit
593 : ///
594 41949: DeclContext *getLexicalParent() {
595 41949: return cast<Decl>(this)->getLexicalDeclContext();
596 : }
597 : const DeclContext *getLexicalParent() const {
598 : return const_cast<DeclContext*>(this)->getLexicalParent();
599 : }
600 :
601 : DeclContext *getLookupParent();
602 :
603 : const DeclContext *getLookupParent() const {
604 : return const_cast<DeclContext*>(this)->getLookupParent();
605 : }
606 :
607 41902: ASTContext &getParentASTContext() const {
608 41902: return cast<Decl>(this)->getASTContext();
609 : }
610 :
611 135027: bool isFunctionOrMethod() const {
4132: branch 0 taken
0: branch 1 not taken
612 135027: switch (DeclKind) {
613 : case Decl::Block:
614 : case Decl::ObjCMethod:
615 4132: return true;
616 : default:
0: branch 0 not taken
0: branch 1 not taken
0: branch 2 not taken
0: branch 3 not taken
617 130895: return DeclKind >= Decl::FunctionFirst && DeclKind <= Decl::FunctionLast;
618 : }
619 : }
620 :
621 638986: bool isFileContext() const {
244413: branch 0 taken
394573: branch 1 taken
48594: branch 2 taken
195819: branch 3 taken
622 638986: return DeclKind == Decl::TranslationUnit || DeclKind == Decl::Namespace;
623 : }
624 :
625 510747: bool isTranslationUnit() const {
626 510747: return DeclKind == Decl::TranslationUnit;
627 : }
628 :
629 266760: bool isRecord() const {
183148: branch 1 taken
83612: branch 2 taken
45695: branch 3 taken
137453: branch 3 taken
630 266760: return DeclKind >= Decl::RecordFirst && DeclKind <= Decl::RecordLast;
631 : }
632 :
633 14314: bool isNamespace() const {
634 14314: return DeclKind == Decl::Namespace;
635 : }
636 :
637 : /// \brief Determines whether this context is dependent on a
638 : /// template parameter.
639 : bool isDependentContext() const;
640 :
641 : /// isTransparentContext - Determines whether this context is a
642 : /// "transparent" context, meaning that the members declared in this
643 : /// context are semantically declared in the nearest enclosing
644 : /// non-transparent (opaque) context but are lexically declared in
645 : /// this context. For example, consider the enumerators of an
646 : /// enumeration type:
647 : /// @code
648 : /// enum E {
649 : /// Val1
650 : /// };
651 : /// @endcode
652 : /// Here, E is a transparent context, so its enumerator (Val1) will
653 : /// appear (semantically) that it is in the same context of E.
654 : /// Examples of transparent contexts include: enumerations (except for
655 : /// C++0x scoped enums), C++ linkage specifications, and C++0x
656 : /// inline namespaces.
657 : bool isTransparentContext() const;
658 :
659 : /// \brief Determine whether this declaration context is equivalent
660 : /// to the declaration context DC.
661 3785: bool Equals(DeclContext *DC) {
662 3785: return this->getPrimaryContext() == DC->getPrimaryContext();
663 : }
664 :
665 : /// \brief Determine whether this declaration context encloses the
666 : /// declaration context DC.
667 : bool Encloses(DeclContext *DC);
668 :
669 : /// getPrimaryContext - There may be many different
670 : /// declarations of the same entity (including forward declarations
671 : /// of classes, multiple definitions of namespaces, etc.), each with
672 : /// a different set of declarations. This routine returns the
673 : /// "primary" DeclContext structure, which will contain the
674 : /// information needed to perform name lookup into this context.
675 : DeclContext *getPrimaryContext();
676 :
677 : /// getLookupContext - Retrieve the innermost non-transparent
678 : /// context of this context, which corresponds to the innermost
679 : /// location from which name lookup can find the entities in this
680 : /// context.
681 : DeclContext *getLookupContext();
682 262803: const DeclContext *getLookupContext() const {
683 262803: return const_cast<DeclContext *>(this)->getLookupContext();
684 : }
685 :
686 : /// \brief Retrieve the nearest enclosing namespace context.
687 : DeclContext *getEnclosingNamespaceContext();
688 : const DeclContext *getEnclosingNamespaceContext() const {
689 : return const_cast<DeclContext *>(this)->getEnclosingNamespaceContext();
690 : }
691 :
692 : /// getNextContext - If this is a DeclContext that may have other
693 : /// DeclContexts that are semantically connected but syntactically
694 : /// different, such as C++ namespaces, this routine retrieves the
695 : /// next DeclContext in the link. Iteration through the chain of
696 : /// DeclContexts should begin at the primary DeclContext and
697 : /// continue until this function returns NULL. For example, given:
698 : /// @code
699 : /// namespace N {
700 : /// int x;
701 : /// }
702 : /// namespace N {
703 : /// int y;
704 : /// }
705 : /// @endcode
706 : /// The first occurrence of namespace N will be the primary
707 : /// DeclContext. Its getNextContext will return the second
708 : /// occurrence of namespace N.
709 : DeclContext *getNextContext();
710 :
711 : /// decl_iterator - Iterates through the declarations stored
712 : /// within this context.
713 : class decl_iterator {
714 : /// Current - The current declaration.
715 : Decl *Current;
716 :
717 : public:
718 : typedef Decl* value_type;
719 : typedef Decl* reference;
720 : typedef Decl* pointer;
721 : typedef std::forward_iterator_tag iterator_category;
722 : typedef std::ptrdiff_t difference_type;
723 :
724 88711: decl_iterator() : Current(0) { }
725 85490: explicit decl_iterator(Decl *C) : Current(C) { }
726 :
727 836569: reference operator*() const { return Current; }
728 17065: pointer operator->() const { return Current; }
729 :
730 436053: decl_iterator& operator++() {
731 436053: Current = Current->getNextDeclInContext();
732 436053: return *this;
733 : }
734 :
735 0: decl_iterator operator++(int) {
736 0: decl_iterator tmp(*this);
737 0: ++(*this);
738 : return tmp;
739 : }
740 :
741 1193: friend bool operator==(decl_iterator x, decl_iterator y) {
742 1193: return x.Current == y.Current;
743 : }
744 410300: friend bool operator!=(decl_iterator x, decl_iterator y) {
745 410300: return x.Current != y.Current;
746 : }
747 : };
748 :
749 : /// decls_begin/decls_end - Iterate over the declarations stored in
750 : /// this context.
751 : decl_iterator decls_begin() const;
752 : decl_iterator decls_end() const;
753 : bool decls_empty() const;
754 :
755 : /// specific_decl_iterator - Iterates over a subrange of
756 : /// declarations stored in a DeclContext, providing only those that
757 : /// are of type SpecificDecl (or a class derived from it). This
758 : /// iterator is used, for example, to provide iteration over just
759 : /// the fields within a RecordDecl (with SpecificDecl = FieldDecl).
760 : template<typename SpecificDecl>
761 : class specific_decl_iterator {
762 : /// Current - The current, underlying declaration iterator, which
763 : /// will either be NULL or will point to a declaration of
764 : /// type SpecificDecl.
765 : DeclContext::decl_iterator Current;
766 :
767 : /// SkipToNextDecl - Advances the current position up to the next
768 : /// declaration of type SpecificDecl that also meets the criteria
769 : /// required by Acceptable.
770 135258: void SkipToNextDecl() {
487: branch 11 taken
166: branch 15 taken
190: branch 16 taken
297: branch 17 taken
190: branch 19 taken
463: branch 20 taken
0: branch 24 not taken
0: branch 25 not taken
47589: branch 26 taken
13954: branch 20 taken
9966: branch 23 taken
9966: branch 25 taken
51577: branch 26 taken
0: branch 24 not taken
0: branch 25 not taken
0: branch 26 not taken
0: branch 26 not taken
4: branch 28 taken
2: branch 29 taken
1: branch 32 taken
3: branch 33 taken
1: branch 34 taken
5: branch 35 taken
771 374024: while (*Current && !isa<SpecificDecl>(*Current))
772 103508: ++Current;
773 135258: }
774 :
775 : public:
776 : typedef SpecificDecl* value_type;
777 : typedef SpecificDecl* reference;
778 : typedef SpecificDecl* pointer;
779 : typedef std::iterator_traits<DeclContext::decl_iterator>::difference_type
780 : difference_type;
781 : typedef std::forward_iterator_tag iterator_category;
782 :
783 168: specific_decl_iterator() : Current() { }
784 :
785 : /// specific_decl_iterator - Construct a new iterator over a
786 : /// subset of the declarations the range [C,
787 : /// end-of-declarations). If A is non-NULL, it is a pointer to a
788 : /// member function of SpecificDecl that should return true for
789 : /// all of the SpecificDecl instances that will be in the subset
790 : /// of iterators. For example, if you want Objective-C instance
791 : /// methods, SpecificDecl will be ObjCMethodDecl and A will be
792 : /// &ObjCMethodDecl::isInstanceMethod.
793 71715: explicit specific_decl_iterator(DeclContext::decl_iterator C) : Current(C) {
794 71715: SkipToNextDecl();
795 71715: }
796 :
797 70297: reference operator*() const { return cast<SpecificDecl>(*Current); }
798 4928: pointer operator->() const { return cast<SpecificDecl>(*Current); }
799 :
800 63543: specific_decl_iterator& operator++() {
801 63543: ++Current;
802 63543: SkipToNextDecl();
803 63543: return *this;
804 : }
805 :
806 70: specific_decl_iterator operator++(int) {
807 70: specific_decl_iterator tmp(*this);
808 70: ++(*this);
809 : return tmp;
810 : }
811 :
812 : friend bool
813 1148: operator==(const specific_decl_iterator& x, const specific_decl_iterator& y) {
814 1148: return x.Current == y.Current;
815 : }
816 :
817 : friend bool
818 96825: operator!=(const specific_decl_iterator& x, const specific_decl_iterator& y) {
819 96825: return x.Current != y.Current;
820 : }
821 : };
822 :
823 : /// \brief Iterates over a filtered subrange of declarations stored
824 : /// in a DeclContext.
825 : ///
826 : /// This iterator visits only those declarations that are of type
827 : /// SpecificDecl (or a class derived from it) and that meet some
828 : /// additional run-time criteria. This iterator is used, for
829 : /// example, to provide access to the instance methods within an
830 : /// Objective-C interface (with SpecificDecl = ObjCMethodDecl and
831 : /// Acceptable = ObjCMethodDecl::isInstanceMethod).
832 : template<typename SpecificDecl, bool (SpecificDecl::*Acceptable)() const>
833 : class filtered_decl_iterator {
834 : /// Current - The current, underlying declaration iterator, which
835 : /// will either be NULL or will point to a declaration of
836 : /// type SpecificDecl.
837 : DeclContext::decl_iterator Current;
838 :
839 : /// SkipToNextDecl - Advances the current position up to the next
840 : /// declaration of type SpecificDecl that also meets the criteria
841 : /// required by Acceptable.
842 12664: void SkipToNextDecl() {
0: branch 1 not taken
0: branch 2 not taken
0: branch 5 not taken
0: branch 6 not taken
0: branch 7 not taken
0: branch 8 not taken
0: branch 11 not taken
0: branch 12 not taken
0: branch 14 not taken
0: branch 15 not taken
0: branch 16 not taken
0: branch 17 not taken
0: branch 23 not taken
0: branch 24 not taken
0: branch 25 not taken
0: branch 26 not taken
0: branch 29 not taken
0: branch 30 not taken
0: branch 32 not taken
0: branch 33 not taken
0: branch 34 not taken
0: branch 35 not taken
843 32017: while (*Current &&
844 : (!isa<SpecificDecl>(*Current) ||
845 : (Acceptable && !(cast<SpecificDecl>(*Current)->*Acceptable)())))
846 6689: ++Current;
847 12664: }
848 :
849 : public:
850 : typedef SpecificDecl* value_type;
851 : typedef SpecificDecl* reference;
852 : typedef SpecificDecl* pointer;
853 : typedef std::iterator_traits<DeclContext::decl_iterator>::difference_type
854 : difference_type;
855 : typedef std::forward_iterator_tag iterator_category;
856 :
857 : filtered_decl_iterator() : Current() { }
858 :
859 : /// specific_decl_iterator - Construct a new iterator over a
860 : /// subset of the declarations the range [C,
861 : /// end-of-declarations). If A is non-NULL, it is a pointer to a
862 : /// member function of SpecificDecl that should return true for
863 : /// all of the SpecificDecl instances that will be in the subset
864 : /// of iterators. For example, if you want Objective-C instance
865 : /// methods, SpecificDecl will be ObjCMethodDecl and A will be
866 : /// &ObjCMethodDecl::isInstanceMethod.
867 9242: explicit filtered_decl_iterator(DeclContext::decl_iterator C) : Current(C) {
868 9242: SkipToNextDecl();
869 9242: }
870 :
871 10269: reference operator*() const { return cast<SpecificDecl>(*Current); }
872 : pointer operator->() const { return cast<SpecificDecl>(*Current); }
873 :
874 3422: filtered_decl_iterator& operator++() {
875 3422: ++Current;
876 3422: SkipToNextDecl();
877 3422: return *this;
878 : }
879 :
880 4: filtered_decl_iterator operator++(int) {
881 4: filtered_decl_iterator tmp(*this);
882 4: ++(*this);
883 : return tmp;
884 : }
885 :
886 : friend bool
887 45: operator==(const filtered_decl_iterator& x, const filtered_decl_iterator& y) {
888 45: return x.Current == y.Current;
889 : }
890 :
891 : friend bool
892 8046: operator!=(const filtered_decl_iterator& x, const filtered_decl_iterator& y) {
893 8046: return x.Current != y.Current;
894 : }
895 : };
896 :
897 : /// @brief Add the declaration D into this context.
898 : ///
899 : /// This routine should be invoked when the declaration D has first
900 : /// been declared, to place D into the context where it was
901 : /// (lexically) defined. Every declaration must be added to one
902 : /// (and only one!) context, where it can be visited via
903 : /// [decls_begin(), decls_end()). Once a declaration has been added
904 : /// to its lexical context, the corresponding DeclContext owns the
905 : /// declaration.
906 : ///
907 : /// If D is also a NamedDecl, it will be made visible within its
908 : /// semantic context via makeDeclVisibleInContext.
909 : void addDecl(Decl *D);
910 :
911 : /// @brief Add the declaration D to this context without modifying
912 : /// any lookup tables.
913 : ///
914 : /// This is useful for some operations in dependent contexts where
915 : /// the semantic context might not be dependent; this basically
916 : /// only happens with friends.
917 : void addHiddenDecl(Decl *D);
918 :
919 : /// @brief Removes a declaration from this context.
920 : void removeDecl(Decl *D);
921 :
922 : /// lookup_iterator - An iterator that provides access to the results
923 : /// of looking up a name within this context.
924 : typedef NamedDecl **lookup_iterator;
925 :
926 : /// lookup_const_iterator - An iterator that provides non-mutable
927 : /// access to the results of lookup up a name within this context.
928 : typedef NamedDecl * const * lookup_const_iterator;
929 :
930 : typedef std::pair<lookup_iterator, lookup_iterator> lookup_result;
931 : typedef std::pair<lookup_const_iterator, lookup_const_iterator>
932 : lookup_const_result;
933 :
934 : /// lookup - Find the declarations (if any) with the given Name in
935 : /// this context. Returns a range of iterators that contains all of
936 : /// the declarations with this name, with object, function, member,
937 : /// and enumerator names preceding any tag name. Note that this
938 : /// routine will not look into parent contexts.
939 : lookup_result lookup(DeclarationName Name);
940 : lookup_const_result lookup(DeclarationName Name) const;
941 :
942 : /// @brief Makes a declaration visible within this context.
943 : ///
944 : /// This routine makes the declaration D visible to name lookup
945 : /// within this context and, if this is a transparent context,
946 : /// within its parent contexts up to the first enclosing
947 : /// non-transparent context. Making a declaration visible within a
948 : /// context does not transfer ownership of a declaration, and a
949 : /// declaration can be visible in many contexts that aren't its
950 : /// lexical context.
951 : ///
952 : /// If D is a redeclaration of an existing declaration that is
953 : /// visible from this context, as determined by
954 : /// NamedDecl::declarationReplaces, the previous declaration will be
955 : /// replaced with D.
956 : ///
957 : /// @param Recoverable true if it's okay to not add this decl to
958 : /// the lookup tables because it can be easily recovered by walking
959 : /// the declaration chains.
960 : void makeDeclVisibleInContext(NamedDecl *D, bool Recoverable = true);
961 :
962 : /// udir_iterator - Iterates through the using-directives stored
963 : /// within this context.
964 : typedef UsingDirectiveDecl * const * udir_iterator;
965 :
966 : typedef std::pair<udir_iterator, udir_iterator> udir_iterator_range;
967 :
968 : udir_iterator_range getUsingDirectives() const;
969 :
970 92: udir_iterator using_directives_begin() const {
971 92: return getUsingDirectives().first;
972 : }
973 :
974 92: udir_iterator using_directives_end() const {
975 92: return getUsingDirectives().second;
976 : }
977 :
978 : // Low-level accessors
979 :
980 : /// \brief Retrieve the internal representation of the lookup structure.
981 64: void* getLookupPtr() const { return LookupPtr; }
982 :
983 : /// \brief Whether this DeclContext has external storage containing
984 : /// additional declarations that are lexically in this context.
985 174313: bool hasExternalLexicalStorage() const { return ExternalLexicalStorage; }
986 :
987 : /// \brief State whether this DeclContext has external storage for
988 : /// declarations lexically in this context.
989 110: void setHasExternalLexicalStorage(bool ES = true) {
990 110: ExternalLexicalStorage = ES;
991 110: }
992 :
993 : /// \brief Whether this DeclContext has external storage containing
994 : /// additional declarations that are visible in this context.
995 156634: bool hasExternalVisibleStorage() const { return ExternalVisibleStorage; }
996 :
997 : /// \brief State whether this DeclContext has external storage for
998 : /// declarations visible in this context.
999 110: void setHasExternalVisibleStorage(bool ES = true) {
1000 110: ExternalVisibleStorage = ES;
1001 110: }
1002 :
1003 : static bool classof(const Decl *D);
1004 : static bool classof(const DeclContext *D) { return true; }
1005 : #define DECL_CONTEXT(Name) \
1006 : static bool classof(const Name##Decl *D) { return true; }
1007 : #include "clang/AST/DeclNodes.def"
1008 :
1009 : void dumpDeclContext() const;
1010 :
1011 : private:
1012 : void LoadLexicalDeclsFromExternalStorage() const;
1013 : void LoadVisibleDeclsFromExternalStorage() const;
1014 :
1015 : void buildLookup(DeclContext *DCtx);
1016 : void makeDeclVisibleInContextImpl(NamedDecl *D);
1017 : };
1018 :
1019 3582: inline bool Decl::isTemplateParameter() const {
1020 : return getKind() == TemplateTypeParm || getKind() == NonTypeTemplateParm ||
1021 3582: getKind() == TemplateTemplateParm;
1022 : }
1023 :
1024 :
1025 : // Specialization selected when ToTy is not a known subclass of DeclContext.
1026 : template <class ToTy,
1027 : bool IsKnownSubtype = ::llvm::is_base_of< DeclContext, ToTy>::value>
1028 : struct cast_convert_decl_context {
1029 68257: static const ToTy *doit(const DeclContext *Val) {
1030 68257: return static_cast<const ToTy*>(Decl::castFromDeclContext(Val));
1031 : }
1032 :
1033 486986: static ToTy *doit(DeclContext *Val) {
1034 486986: return static_cast<ToTy*>(Decl::castFromDeclContext(Val));
1035 : }
1036 : };
1037 :
1038 : // Specialization selected when ToTy is a known subclass of DeclContext.
1039 : template <class ToTy>
1040 : struct cast_convert_decl_context<ToTy, true> {
1041 226782: static const ToTy *doit(const DeclContext *Val) {
26: branch 0 taken
0: branch 1 not taken
1042 226782: return static_cast<const ToTy*>(Val);
1043 : }
1044 :
1045 506565: static ToTy *doit(DeclContext *Val) {
4047: branch 0 taken
3812: branch 1 taken
3812: branch 2 taken
3812: branch 3 taken
0: branch 5 not taken
0: branch 6 not taken
0: branch 7 not taken
2730: branch 8 taken
0: branch 9 not taken
1046 506565: return static_cast<ToTy*>(Val);
1047 : }
1048 : };
1049 :
1050 :
1051 : } // end clang.
1052 :
1053 : namespace llvm {
1054 :
1055 : /// isa<T>(DeclContext*)
1056 : template<class ToTy>
1057 : struct isa_impl_wrap<ToTy,
1058 : const ::clang::DeclContext,const ::clang::DeclContext> {
1059 2310023: static bool doit(const ::clang::DeclContext &Val) {
1060 2310023: return ToTy::classofKind(Val.getDeclKind());
1061 : }
1062 : };
1063 : template<class ToTy>
1064 : struct isa_impl_wrap<ToTy, ::clang::DeclContext, ::clang::DeclContext>
1065 : : public isa_impl_wrap<ToTy,
1066 : const ::clang::DeclContext,const ::clang::DeclContext> {};
1067 :
1068 : /// cast<T>(DeclContext*)
1069 : template<class ToTy>
1070 : struct cast_convert_val<ToTy,
1071 : const ::clang::DeclContext,const ::clang::DeclContext> {
1072 : static const ToTy &doit(const ::clang::DeclContext &Val) {
1073 : return *::clang::cast_convert_decl_context<ToTy>::doit(&Val);
1074 : }
1075 : };
1076 : template<class ToTy>
1077 : struct cast_convert_val<ToTy, ::clang::DeclContext, ::clang::DeclContext> {
1078 : static ToTy &doit(::clang::DeclContext &Val) {
1079 : return *::clang::cast_convert_decl_context<ToTy>::doit(&Val);
1080 : }
1081 : };
1082 : template<class ToTy>
1083 : struct cast_convert_val<ToTy,
1084 : const ::clang::DeclContext*, const ::clang::DeclContext*> {
1085 295039: static const ToTy *doit(const ::clang::DeclContext *Val) {
1086 295039: return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
1087 : }
1088 : };
1089 : template<class ToTy>
1090 : struct cast_convert_val<ToTy, ::clang::DeclContext*, ::clang::DeclContext*> {
1091 993551: static ToTy *doit(::clang::DeclContext *Val) {
1092 993551: return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
1093 : }
1094 : };
1095 :
1096 : /// Implement cast_convert_val for Decl -> DeclContext conversions.
1097 : template<class FromTy>
1098 : struct cast_convert_val< ::clang::DeclContext, FromTy, FromTy> {
1099 : static ::clang::DeclContext &doit(const FromTy &Val) {
1100 : return *FromTy::castToDeclContext(&Val);
1101 : }
1102 : };
1103 :
1104 : template<class FromTy>
1105 : struct cast_convert_val< ::clang::DeclContext, FromTy*, FromTy*> {
1106 38894: static ::clang::DeclContext *doit(const FromTy *Val) {
1107 38894: return FromTy::castToDeclContext(Val);
1108 : }
1109 : };
1110 :
1111 : template<class FromTy>
1112 : struct cast_convert_val< const ::clang::DeclContext, FromTy, FromTy> {
1113 : static const ::clang::DeclContext &doit(const FromTy &Val) {
1114 : return *FromTy::castToDeclContext(&Val);
1115 : }
1116 : };
1117 :
1118 : template<class FromTy>
1119 : struct cast_convert_val< const ::clang::DeclContext, FromTy*, FromTy*> {
1120 : static const ::clang::DeclContext *doit(const FromTy *Val) {
1121 : return FromTy::castToDeclContext(Val);
1122 : }
1123 : };
1124 :
1125 : } // end namespace llvm
1126 :
1127 : #endif
Generated: 2010-02-10 01:31 by zcov