Decl.h revision 44b4321feab46299d3f5cfd404680884752a0fcf
1//===--- Decl.h - 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 subclasses.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_AST_DECL_H
15#define LLVM_CLANG_AST_DECL_H
16
17#include "clang/Basic/IdentifierTable.h"
18#include "clang/Basic/OperatorKinds.h"
19#include "clang/AST/DeclarationName.h"
20#include "clang/AST/DeclBase.h"
21#include "clang/Parse/AccessSpecifier.h"
22#include "llvm/ADT/SmallVector.h"
23
24namespace clang {
25class Expr;
26class Stmt;
27class CompoundStmt;
28class StringLiteral;
29
30/// TranslationUnitDecl - The top declaration context.
31/// FIXME: The TranslationUnit class should probably be modified to serve as
32/// the top decl context. It would have ownership of the top decls so that the
33/// AST is self-contained and easily de/serializable.
34class TranslationUnitDecl : public Decl, public DeclContext {
35  TranslationUnitDecl()
36    : Decl(TranslationUnit, SourceLocation()),
37      DeclContext(TranslationUnit) {}
38public:
39  static TranslationUnitDecl *Create(ASTContext &C);
40  // Implement isa/cast/dyncast/etc.
41  static bool classof(const Decl *D) { return D->getKind() == TranslationUnit; }
42  static bool classof(const TranslationUnitDecl *D) { return true; }
43  static DeclContext *castToDeclContext(const TranslationUnitDecl *D) {
44    return static_cast<DeclContext *>(const_cast<TranslationUnitDecl*>(D));
45  }
46  static TranslationUnitDecl *castFromDeclContext(const DeclContext *DC) {
47    return static_cast<TranslationUnitDecl *>(const_cast<DeclContext*>(DC));
48  }
49
50protected:
51  /// EmitImpl - Serialize this TranslationUnitDecl. Called by Decl::Emit.
52  virtual void EmitImpl(llvm::Serializer& S) const;
53
54  /// CreateImpl - Deserialize a TranslationUnitDecl.  Called by Decl::Create.
55  static TranslationUnitDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
56
57  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
58};
59
60/// NamedDecl - This represents a decl with a name.  Many decls have names such
61/// as ObjCMethodDecl, but not @class, etc.
62class NamedDecl : public Decl {
63  /// Name - The name of this declaration, which is typically a normal
64  /// identifier but may also be a special kind of name (C++
65  /// constructor, Objective-C selector, etc.)
66  DeclarationName Name;
67
68protected:
69  NamedDecl(Kind DK, SourceLocation L, DeclarationName N)
70    : Decl(DK, L), Name(N) {}
71
72public:
73  NamedDecl(Kind DK, SourceLocation L, IdentifierInfo *Id)
74    : Decl(DK, L), Name(Id) {}
75
76  /// getIdentifier - Get the identifier that names this declaration,
77  /// if there is one. This will return NULL if this declaration has
78  /// no name (e.g., for an unnamed class) or if the name is a special
79  /// name (C++ constructor, Objective-C selector, etc.).
80  IdentifierInfo *getIdentifier() const { return Name.getAsIdentifierInfo(); }
81
82  /// getNameAsCString - Get the name of identifier for this declaration as a
83  /// C string (const char*).  This requires that the declaration have a name
84  /// and that it be a simple identifier.
85  const char *getNameAsCString() const {
86    assert(getIdentifier() && "Name is not a simple identifier");
87    return getIdentifier()->getName();
88  }
89
90  /// getDeclName - Get the actual, stored name of the declaration,
91  /// which may be a special name.
92  DeclarationName getDeclName() const { return Name; }
93
94  /// getNameAsString - Get a human-readable name for the declaration, even if
95  /// it is one of the special kinds of names (C++ constructor, Objective-C
96  /// selector, etc).  Creating this name requires expensive string
97  /// manipulation, so it should be called only when performance doesn't matter.
98  /// For simple declarations, getNameAsCString() should suffice.
99  std::string getNameAsString() const { return Name.getAsString(); }
100
101  static bool classof(const Decl *D) {
102    return D->getKind() >= NamedFirst && D->getKind() <= NamedLast;
103  }
104  static bool classof(const NamedDecl *D) { return true; }
105
106protected:
107  void EmitInRec(llvm::Serializer& S) const;
108  void ReadInRec(llvm::Deserializer& D, ASTContext& C);
109};
110
111/// ScopedDecl - Represent lexically scoped names, used for all ValueDecl's
112/// and TypeDecl's.
113class ScopedDecl : public NamedDecl {
114  /// NextDeclarator - If this decl was part of a multi-declarator declaration,
115  /// such as "int X, Y, *Z;" this indicates Decl for the next declarator.
116  ScopedDecl *NextDeclarator;
117
118  /// DeclCtx - Holds either a DeclContext* or a MultipleDC*.
119  /// For declarations that don't contain C++ scope specifiers, it contains
120  /// the DeclContext where the ScopedDecl was declared.
121  /// For declarations with C++ scope specifiers, it contains a MultipleDC*
122  /// with the context where it semantically belongs (SemanticDC) and the
123  /// context where it was lexically declared (LexicalDC).
124  /// e.g.:
125  ///
126  ///   namespace A {
127  ///      void f(); // SemanticDC == LexicalDC == 'namespace A'
128  ///   }
129  ///   void A::f(); // SemanticDC == namespace 'A'
130  ///                // LexicalDC == global namespace
131  uintptr_t DeclCtx;
132
133  struct MultipleDC {
134    DeclContext *SemanticDC;
135    DeclContext *LexicalDC;
136  };
137
138  inline bool isInSemaDC() const { return (DeclCtx & 0x1) == 0; }
139  inline bool isOutOfSemaDC() const { return (DeclCtx & 0x1) != 0; }
140  inline MultipleDC *getMultipleDC() const {
141    return reinterpret_cast<MultipleDC*>(DeclCtx & ~0x1);
142  }
143
144protected:
145  ScopedDecl(Kind DK, DeclContext *DC, SourceLocation L,
146             DeclarationName N, ScopedDecl *PrevDecl)
147    : NamedDecl(DK, L, N), NextDeclarator(PrevDecl),
148      DeclCtx(reinterpret_cast<uintptr_t>(DC)) {}
149
150  virtual ~ScopedDecl();
151
152public:
153  const DeclContext *getDeclContext() const {
154    if (isInSemaDC())
155      return reinterpret_cast<DeclContext*>(DeclCtx);
156    return getMultipleDC()->SemanticDC;
157  }
158  DeclContext *getDeclContext() {
159    return const_cast<DeclContext*>(
160                         const_cast<const ScopedDecl*>(this)->getDeclContext());
161  }
162
163  /// getLexicalDeclContext - The declaration context where this ScopedDecl was
164  /// lexically declared (LexicalDC). May be different from
165  /// getDeclContext() (SemanticDC).
166  /// e.g.:
167  ///
168  ///   namespace A {
169  ///      void f(); // SemanticDC == LexicalDC == 'namespace A'
170  ///   }
171  ///   void A::f(); // SemanticDC == namespace 'A'
172  ///                // LexicalDC == global namespace
173  const DeclContext *getLexicalDeclContext() const {
174    if (isInSemaDC())
175      return reinterpret_cast<DeclContext*>(DeclCtx);
176    return getMultipleDC()->LexicalDC;
177  }
178  DeclContext *getLexicalDeclContext() {
179    return const_cast<DeclContext*>(
180                  const_cast<const ScopedDecl*>(this)->getLexicalDeclContext());
181  }
182
183  void setLexicalDeclContext(DeclContext *DC);
184
185  /// getNextDeclarator - If this decl was part of a multi-declarator
186  /// declaration, such as "int X, Y, *Z;" this returns the decl for the next
187  /// declarator.  Otherwise it returns null.
188  ScopedDecl *getNextDeclarator() { return NextDeclarator; }
189  const ScopedDecl *getNextDeclarator() const { return NextDeclarator; }
190  void setNextDeclarator(ScopedDecl *N) { NextDeclarator = N; }
191
192  // isDefinedOutsideFunctionOrMethod - This predicate returns true if this
193  // scoped decl is defined outside the current function or method.  This is
194  // roughly global variables and functions, but also handles enums (which could
195  // be defined inside or outside a function etc).
196  bool isDefinedOutsideFunctionOrMethod() const {
197    if (getDeclContext())
198      return !getDeclContext()->isFunctionOrMethod();
199    else
200      return true;
201  }
202
203  // Implement isa/cast/dyncast/etc.
204  static bool classof(const Decl *D) {
205    return D->getKind() >= ScopedFirst && D->getKind() <= ScopedLast;
206  }
207  static bool classof(const ScopedDecl *D) { return true; }
208
209protected:
210  void EmitInRec(llvm::Serializer& S) const;
211  void ReadInRec(llvm::Deserializer& D, ASTContext& C);
212
213  void EmitOutRec(llvm::Serializer& S) const;
214  void ReadOutRec(llvm::Deserializer& D, ASTContext& C);
215
216  friend void Decl::Destroy(ASTContext& C);
217};
218
219/// NamespaceDecl - Represent a C++ namespace.
220class NamespaceDecl : public ScopedDecl, public DeclContext {
221  SourceLocation LBracLoc, RBracLoc;
222
223  // For extended namespace definitions:
224  //
225  // namespace A { int x; }
226  // namespace A { int y; }
227  //
228  // there will be one NamespaceDecl for each declaration.
229  // NextDeclarator points to the next extended declaration.
230  // OrigNamespace points to the original namespace declaration.
231  // OrigNamespace of the first namespace decl points to itself.
232
233  NamespaceDecl *OrigNamespace;
234
235  NamespaceDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id)
236    : ScopedDecl(Namespace, DC, L, Id, 0), DeclContext(Namespace) {
237      OrigNamespace = this;
238  }
239public:
240  static NamespaceDecl *Create(ASTContext &C, DeclContext *DC,
241                               SourceLocation L, IdentifierInfo *Id);
242
243  virtual void Destroy(ASTContext& C);
244
245  NamespaceDecl *getNextNamespace() {
246    return cast_or_null<NamespaceDecl>(getNextDeclarator());
247  }
248  const NamespaceDecl *getNextNamespace() const {
249    return cast_or_null<NamespaceDecl>(getNextDeclarator());
250  }
251  void setNextNamespace(NamespaceDecl *ND) { setNextDeclarator(ND); }
252
253  NamespaceDecl *getOriginalNamespace() const {
254    return OrigNamespace;
255  }
256  void setOriginalNamespace(NamespaceDecl *ND) { OrigNamespace = ND; }
257
258  SourceRange getSourceRange() const {
259    return SourceRange(LBracLoc, RBracLoc);
260  }
261
262  SourceLocation getLBracLoc() const { return LBracLoc; }
263  SourceLocation getRBracLoc() const { return RBracLoc; }
264  void setLBracLoc(SourceLocation LBrace) { LBracLoc = LBrace; }
265  void setRBracLoc(SourceLocation RBrace) { RBracLoc = RBrace; }
266
267  // Implement isa/cast/dyncast/etc.
268  static bool classof(const Decl *D) { return D->getKind() == Namespace; }
269  static bool classof(const NamespaceDecl *D) { return true; }
270  static DeclContext *castToDeclContext(const NamespaceDecl *D) {
271    return static_cast<DeclContext *>(const_cast<NamespaceDecl*>(D));
272  }
273  static NamespaceDecl *castFromDeclContext(const DeclContext *DC) {
274    return static_cast<NamespaceDecl *>(const_cast<DeclContext*>(DC));
275  }
276
277protected:
278  /// EmitImpl - Serialize this NamespaceDecl. Called by Decl::Emit.
279  virtual void EmitImpl(llvm::Serializer& S) const;
280
281  /// CreateImpl - Deserialize a NamespaceDecl.  Called by Decl::Create.
282  static NamespaceDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
283
284  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
285};
286
287/// ValueDecl - Represent the declaration of a variable (in which case it is
288/// an lvalue) a function (in which case it is a function designator) or
289/// an enum constant.
290class ValueDecl : public ScopedDecl {
291  QualType DeclType;
292
293protected:
294  ValueDecl(Kind DK, DeclContext *DC, SourceLocation L,
295            DeclarationName N, QualType T, ScopedDecl *PrevDecl)
296    : ScopedDecl(DK, DC, L, N, PrevDecl), DeclType(T) {}
297public:
298  QualType getType() const { return DeclType; }
299  void setType(QualType newType) { DeclType = newType; }
300
301  // Implement isa/cast/dyncast/etc.
302  static bool classof(const Decl *D) {
303    return D->getKind() >= ValueFirst && D->getKind() <= ValueLast;
304  }
305  static bool classof(const ValueDecl *D) { return true; }
306
307protected:
308  void EmitInRec(llvm::Serializer& S) const;
309  void ReadInRec(llvm::Deserializer& D, ASTContext& C);
310};
311
312/// VarDecl - An instance of this class is created to represent a variable
313/// declaration or definition.
314class VarDecl : public ValueDecl {
315public:
316  enum StorageClass {
317    None, Auto, Register, Extern, Static, PrivateExtern
318  };
319private:
320  Stmt *Init;
321  // FIXME: This can be packed into the bitfields in Decl.
322  unsigned SClass : 3;
323  bool ThreadSpecified : 1;
324  bool HasCXXDirectInit : 1;
325
326  /// DeclaredInCondition - Whether this variable was declared in a
327  /// condition, e.g., if (int x = foo()) { ... }.
328  bool DeclaredInCondition : 1;
329
330  // Move to DeclGroup when it is implemented.
331  SourceLocation TypeSpecStartLoc;
332  friend class StmtIteratorBase;
333protected:
334  VarDecl(Kind DK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
335          QualType T, StorageClass SC, ScopedDecl *PrevDecl,
336          SourceLocation TSSL = SourceLocation())
337    : ValueDecl(DK, DC, L, Id, T, PrevDecl), Init(0),
338          ThreadSpecified(false), HasCXXDirectInit(false),
339          DeclaredInCondition(false), TypeSpecStartLoc(TSSL) {
340    SClass = SC;
341  }
342public:
343  static VarDecl *Create(ASTContext &C, DeclContext *DC,
344                         SourceLocation L, IdentifierInfo *Id,
345                         QualType T, StorageClass S, ScopedDecl *PrevDecl,
346                         SourceLocation TypeSpecStartLoc = SourceLocation());
347
348  StorageClass getStorageClass() const { return (StorageClass)SClass; }
349
350  SourceLocation getTypeSpecStartLoc() const { return TypeSpecStartLoc; }
351
352  const Expr *getInit() const { return (const Expr*) Init; }
353  Expr *getInit() { return (Expr*) Init; }
354  void setInit(Expr *I) { Init = (Stmt*) I; }
355
356  void setThreadSpecified(bool T) { ThreadSpecified = T; }
357  bool isThreadSpecified() const {
358    return ThreadSpecified;
359  }
360
361  void setCXXDirectInitializer(bool T) { HasCXXDirectInit = T; }
362
363  /// hasCXXDirectInitializer - If true, the initializer was a direct
364  /// initializer, e.g: "int x(1);". The Init expression will be the expression
365  /// inside the parens or a "ClassType(a,b,c)" class constructor expression for
366  /// class types. Clients can distinguish between "int x(1);" and "int x=1;"
367  /// by checking hasCXXDirectInitializer.
368  ///
369  bool hasCXXDirectInitializer() const {
370    return HasCXXDirectInit;
371  }
372
373  /// isDeclaredInCondition - Whether this variable was declared as
374  /// part of a condition in an if/switch/while statement, e.g.,
375  /// @code
376  /// if (int x = foo()) { ... }
377  /// @endcode
378  bool isDeclaredInCondition() const {
379    return DeclaredInCondition;
380  }
381  void setDeclaredInCondition(bool InCondition) {
382    DeclaredInCondition = InCondition;
383  }
384
385  /// hasLocalStorage - Returns true if a variable with function scope
386  ///  is a non-static local variable.
387  bool hasLocalStorage() const {
388    if (getStorageClass() == None)
389      return !isFileVarDecl();
390
391    // Return true for:  Auto, Register.
392    // Return false for: Extern, Static, PrivateExtern.
393
394    return getStorageClass() <= Register;
395  }
396
397  /// hasGlobalStorage - Returns true for all variables that do not
398  ///  have local storage.  This includs all global variables as well
399  ///  as static variables declared within a function.
400  bool hasGlobalStorage() const { return !hasLocalStorage(); }
401
402  /// isBlockVarDecl - Returns true for local variable declarations.  Note that
403  /// this includes static variables inside of functions.
404  ///
405  ///   void foo() { int x; static int y; extern int z; }
406  ///
407  bool isBlockVarDecl() const {
408    if (getKind() != Decl::Var)
409      return false;
410    if (const DeclContext *DC = getDeclContext())
411      return DC->isFunctionOrMethod();
412    return false;
413  }
414
415  /// isFileVarDecl - Returns true for file scoped variable declaration.
416  bool isFileVarDecl() const {
417    if (getKind() != Decl::Var)
418      return false;
419    if (isa<TranslationUnitDecl>(getDeclContext()) ||
420        isa<NamespaceDecl>(getDeclContext()) )
421      return true;
422    return false;
423  }
424
425  // Implement isa/cast/dyncast/etc.
426  static bool classof(const Decl *D) {
427    return D->getKind() >= VarFirst && D->getKind() <= VarLast;
428  }
429  static bool classof(const VarDecl *D) { return true; }
430
431protected:
432  void EmitInRec(llvm::Serializer& S) const;
433  void ReadInRec(llvm::Deserializer& D, ASTContext& C);
434
435  void EmitOutRec(llvm::Serializer& S) const;
436  void ReadOutRec(llvm::Deserializer& D, ASTContext& C);
437
438  /// EmitImpl - Serialize this VarDecl. Called by Decl::Emit.
439  virtual void EmitImpl(llvm::Serializer& S) const;
440
441  /// ReadImpl - Deserialize this VarDecl. Called by subclasses.
442  virtual void ReadImpl(llvm::Deserializer& D, ASTContext& C);
443
444  /// CreateImpl - Deserialize a VarDecl.  Called by Decl::Create.
445  static VarDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
446};
447
448class ImplicitParamDecl : public VarDecl {
449protected:
450  ImplicitParamDecl(Kind DK, DeclContext *DC, SourceLocation L,
451            IdentifierInfo *Id, QualType T, ScopedDecl *PrevDecl)
452    : VarDecl(DK, DC, L, Id, T, VarDecl::None, PrevDecl) {}
453public:
454  static ImplicitParamDecl *Create(ASTContext &C, DeclContext *DC,
455                         SourceLocation L, IdentifierInfo *Id,
456                         QualType T, ScopedDecl *PrevDecl);
457  // Implement isa/cast/dyncast/etc.
458  static bool classof(const ImplicitParamDecl *D) { return true; }
459  static bool classof(const Decl *D) { return D->getKind() == ImplicitParam; }
460};
461
462/// ParmVarDecl - Represent a parameter to a function.
463class ParmVarDecl : public VarDecl {
464  // NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum
465  /// FIXME: Also can be paced into the bitfields in Decl.
466  /// in, inout, etc.
467  unsigned objcDeclQualifier : 6;
468
469  /// Default argument, if any.  [C++ Only]
470  Expr *DefaultArg;
471
472  ParmVarDecl(DeclContext *DC, SourceLocation L,
473              IdentifierInfo *Id, QualType T, StorageClass S,
474              Expr *DefArg, ScopedDecl *PrevDecl)
475    : VarDecl(ParmVar, DC, L, Id, T, S, PrevDecl),
476      objcDeclQualifier(OBJC_TQ_None), DefaultArg(DefArg) {}
477
478public:
479  static ParmVarDecl *Create(ASTContext &C, DeclContext *DC,
480                             SourceLocation L,IdentifierInfo *Id,
481                             QualType T, StorageClass S, Expr *DefArg,
482                             ScopedDecl *PrevDecl);
483
484  ObjCDeclQualifier getObjCDeclQualifier() const {
485    return ObjCDeclQualifier(objcDeclQualifier);
486  }
487  void setObjCDeclQualifier(ObjCDeclQualifier QTVal)
488  { objcDeclQualifier = QTVal; }
489
490  const Expr *getDefaultArg() const { return DefaultArg; }
491  Expr *getDefaultArg() { return DefaultArg; }
492  void setDefaultArg(Expr *defarg) { DefaultArg = defarg; }
493
494  // Implement isa/cast/dyncast/etc.
495  static bool classof(const Decl *D) { return D->getKind() == ParmVar; }
496  static bool classof(const ParmVarDecl *D) { return true; }
497
498protected:
499  /// EmitImpl - Serialize this ParmVarDecl. Called by Decl::Emit.
500  virtual void EmitImpl(llvm::Serializer& S) const;
501
502  /// CreateImpl - Deserialize a ParmVarDecl.  Called by Decl::Create.
503  static ParmVarDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
504
505  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
506};
507
508/// FunctionDecl - An instance of this class is created to represent a
509/// function declaration or definition.
510///
511/// Since a given function can be declared several times in a program,
512/// there may be several FunctionDecls that correspond to that
513/// function. Only one of those FunctionDecls will be found when
514/// traversing the list of declarations in the context of the
515/// FunctionDecl (e.g., the translation unit); this FunctionDecl
516/// contains all of the information known about the function. Other,
517/// previous declarations of the function are available via the
518/// getPreviousDeclaration() chain.
519class FunctionDecl : public ValueDecl, public DeclContext {
520public:
521  enum StorageClass {
522    None, Extern, Static, PrivateExtern
523  };
524private:
525  /// ParamInfo - new[]'d array of pointers to VarDecls for the formal
526  /// parameters of this function.  This is null if a prototype or if there are
527  /// no formals.  TODO: we could allocate this space immediately after the
528  /// FunctionDecl object to save an allocation like FunctionType does.
529  ParmVarDecl **ParamInfo;
530
531  Stmt *Body;  // Null if a prototype.
532
533  /// PreviousDeclaration - A link to the previous declaration of this
534  /// same function, NULL if this is the first declaration. For
535  /// example, in the following code, the PreviousDeclaration can be
536  /// traversed several times to see all three declarations of the
537  /// function "f", the last of which is also a definition.
538  ///
539  ///   int f(int x, int y = 1);
540  ///   int f(int x = 0, int y);
541  ///   int f(int x, int y) { return x + y; }
542  FunctionDecl *PreviousDeclaration;
543
544  // NOTE: VC++ treats enums as signed, avoid using the StorageClass enum
545  unsigned SClass : 2;
546  bool IsInline : 1;
547  bool IsImplicit : 1;
548
549  // Move to DeclGroup when it is implemented.
550  SourceLocation TypeSpecStartLoc;
551protected:
552  FunctionDecl(Kind DK, DeclContext *DC, SourceLocation L,
553               DeclarationName N, QualType T,
554               StorageClass S, bool isInline, ScopedDecl *PrevDecl,
555               SourceLocation TSSL = SourceLocation())
556    : ValueDecl(DK, DC, L, N, T, PrevDecl),
557      DeclContext(DK),
558      ParamInfo(0), Body(0), PreviousDeclaration(0),
559      SClass(S), IsInline(isInline), IsImplicit(0), TypeSpecStartLoc(TSSL) {}
560
561  virtual ~FunctionDecl();
562  virtual void Destroy(ASTContext& C);
563
564public:
565  static FunctionDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
566                              DeclarationName N, QualType T,
567                              StorageClass S = None, bool isInline = false,
568                              ScopedDecl *PrevDecl = 0,
569                              SourceLocation TSStartLoc = SourceLocation());
570
571  SourceLocation getTypeSpecStartLoc() const { return TypeSpecStartLoc; }
572
573  /// getBody - Retrieve the body (definition) of the function. The
574  /// function body might be in any of the (re-)declarations of this
575  /// function. The variant that accepts a FunctionDecl pointer will
576  /// set that function declaration to the actual declaration
577  /// containing the body (if there is one).
578  Stmt *getBody(const FunctionDecl *&Definition) const;
579
580  virtual Stmt *getBody() const {
581    const FunctionDecl* Definition;
582    return getBody(Definition);
583  }
584
585  /// isThisDeclarationADefinition - Returns whether this specific
586  /// declaration of the function is also a definition. This does not
587  /// determine whether the function has been defined (e.g., in a
588  /// previous definition); for that information, use getBody.
589  bool isThisDeclarationADefinition() const { return Body != 0; }
590
591  void setBody(Stmt *B) { Body = B; }
592
593  bool isImplicit() { return IsImplicit; }
594  void setImplicit() { IsImplicit = true; }
595
596  /// getPreviousDeclaration - Return the previous declaration of this
597  /// function.
598  const FunctionDecl *getPreviousDeclaration() const {
599    return PreviousDeclaration;
600  }
601
602  void setPreviousDeclaration(FunctionDecl * PrevDecl) {
603    PreviousDeclaration = PrevDecl;
604  }
605
606  // Iterator access to formal parameters.
607  unsigned param_size() const { return getNumParams(); }
608  typedef ParmVarDecl **param_iterator;
609  typedef ParmVarDecl * const *param_const_iterator;
610
611  param_iterator param_begin() { return ParamInfo; }
612  param_iterator param_end()   { return ParamInfo+param_size(); }
613
614  param_const_iterator param_begin() const { return ParamInfo; }
615  param_const_iterator param_end() const   { return ParamInfo+param_size(); }
616
617  unsigned getNumParams() const;
618  const ParmVarDecl *getParamDecl(unsigned i) const {
619    assert(i < getNumParams() && "Illegal param #");
620    return ParamInfo[i];
621  }
622  ParmVarDecl *getParamDecl(unsigned i) {
623    assert(i < getNumParams() && "Illegal param #");
624    return ParamInfo[i];
625  }
626  void setParams(ParmVarDecl **NewParamInfo, unsigned NumParams);
627
628  /// getMinRequiredArguments - Returns the minimum number of arguments
629  /// needed to call this function. This may be fewer than the number of
630  /// function parameters, if some of the parameters have default
631  /// arguments (in C++).
632  unsigned getMinRequiredArguments() const;
633
634  QualType getResultType() const {
635    return getType()->getAsFunctionType()->getResultType();
636  }
637  StorageClass getStorageClass() const { return StorageClass(SClass); }
638  bool isInline() const { return IsInline; }
639
640  /// isOverloadedOperator - Whether this function declaration
641  /// represents an C++ overloaded operator, e.g., "operator+".
642  bool isOverloadedOperator() const {
643    return getOverloadedOperator() != OO_None;
644  };
645
646  OverloadedOperatorKind getOverloadedOperator() const;
647
648  // Implement isa/cast/dyncast/etc.
649  static bool classof(const Decl *D) {
650    return D->getKind() >= FunctionFirst && D->getKind() <= FunctionLast;
651  }
652  static bool classof(const FunctionDecl *D) { return true; }
653  static DeclContext *castToDeclContext(const FunctionDecl *D) {
654    return static_cast<DeclContext *>(const_cast<FunctionDecl*>(D));
655  }
656  static FunctionDecl *castFromDeclContext(const DeclContext *DC) {
657    return static_cast<FunctionDecl *>(const_cast<DeclContext*>(DC));
658  }
659
660protected:
661  /// EmitImpl - Serialize this FunctionDecl.  Called by Decl::Emit.
662  virtual void EmitImpl(llvm::Serializer& S) const;
663
664  /// CreateImpl - Deserialize a FunctionDecl.  Called by Decl::Create.
665  static FunctionDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
666
667  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
668  friend class CXXRecordDecl;
669};
670
671
672/// FieldDecl - An instance of this class is created by Sema::ActOnField to
673/// represent a member of a struct/union/class.
674class FieldDecl : public ScopedDecl {
675  bool Mutable : 1;
676  QualType DeclType;
677  Expr *BitWidth;
678protected:
679  FieldDecl(Kind DK, DeclContext *DC, SourceLocation L,
680            IdentifierInfo *Id, QualType T, Expr *BW, bool Mutable,
681            ScopedDecl *PrevDecl)
682    : ScopedDecl(DK, DC, L, Id, PrevDecl), Mutable(Mutable), DeclType(T),
683      BitWidth(BW)
684      { }
685
686public:
687  static FieldDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
688                           IdentifierInfo *Id, QualType T, Expr *BW,
689                           bool Mutable, ScopedDecl *PrevDecl);
690
691  QualType getType() const { return DeclType; }
692
693  /// isMutable - Determines whether this field is mutable (C++ only).
694  bool isMutable() const { return Mutable; }
695
696  /// isBitfield - Determines whether this field is a bitfield.
697  bool isBitField() const { return BitWidth != NULL; }
698
699  Expr *getBitWidth() const { return BitWidth; }
700  // Implement isa/cast/dyncast/etc.
701  static bool classof(const Decl *D) {
702    return D->getKind() >= FieldFirst && D->getKind() <= FieldLast;
703  }
704  static bool classof(const FieldDecl *D) { return true; }
705
706protected:
707  /// EmitImpl - Serialize this FieldDecl.  Called by Decl::Emit.
708  virtual void EmitImpl(llvm::Serializer& S) const;
709
710  /// CreateImpl - Deserialize a FieldDecl.  Called by Decl::Create.
711  static FieldDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
712
713  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
714};
715
716/// EnumConstantDecl - An instance of this object exists for each enum constant
717/// that is defined.  For example, in "enum X {a,b}", each of a/b are
718/// EnumConstantDecl's, X is an instance of EnumDecl, and the type of a/b is a
719/// TagType for the X EnumDecl.
720class EnumConstantDecl : public ValueDecl {
721  Stmt *Init; // an integer constant expression
722  llvm::APSInt Val; // The value.
723protected:
724  EnumConstantDecl(DeclContext *DC, SourceLocation L,
725                   IdentifierInfo *Id, QualType T, Expr *E,
726                   const llvm::APSInt &V, ScopedDecl *PrevDecl)
727    : ValueDecl(EnumConstant, DC, L, Id, T, PrevDecl), Init((Stmt*)E), Val(V) {}
728
729  virtual ~EnumConstantDecl() {}
730public:
731
732  static EnumConstantDecl *Create(ASTContext &C, EnumDecl *DC,
733                                  SourceLocation L, IdentifierInfo *Id,
734                                  QualType T, Expr *E,
735                                  const llvm::APSInt &V, ScopedDecl *PrevDecl);
736
737  virtual void Destroy(ASTContext& C);
738
739  const Expr *getInitExpr() const { return (const Expr*) Init; }
740  Expr *getInitExpr() { return (Expr*) Init; }
741  const llvm::APSInt &getInitVal() const { return Val; }
742
743  void setInitExpr(Expr *E) { Init = (Stmt*) E; }
744  void setInitVal(const llvm::APSInt &V) { Val = V; }
745
746  // Implement isa/cast/dyncast/etc.
747  static bool classof(const Decl *D) { return D->getKind() == EnumConstant; }
748  static bool classof(const EnumConstantDecl *D) { return true; }
749
750  friend class StmtIteratorBase;
751
752protected:
753  /// EmitImpl - Serialize this EnumConstantDecl.  Called by Decl::Emit.
754  virtual void EmitImpl(llvm::Serializer& S) const;
755
756  /// CreateImpl - Deserialize a EnumConstantDecl.  Called by Decl::Create.
757  static EnumConstantDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
758
759  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
760};
761
762
763/// TypeDecl - Represents a declaration of a type.
764///
765class TypeDecl : public ScopedDecl {
766  /// TypeForDecl - This indicates the Type object that represents this
767  /// TypeDecl.  It is a cache maintained by ASTContext::getTypedefType,
768  /// ASTContext::getTagDeclType, and ASTContext::getTemplateTypeParmType.
769  Type *TypeForDecl;
770  friend class ASTContext;
771protected:
772  TypeDecl(Kind DK, DeclContext *DC, SourceLocation L,
773           IdentifierInfo *Id, ScopedDecl *PrevDecl)
774    : ScopedDecl(DK, DC, L, Id, PrevDecl), TypeForDecl(0) {}
775public:
776  void setAccess(AccessSpecifier AS) { Access = AS; }
777  AccessSpecifier getAccess() const { return AccessSpecifier(Access); }
778
779  // Implement isa/cast/dyncast/etc.
780  static bool classof(const Decl *D) {
781    return D->getKind() >= TypeFirst && D->getKind() <= TypeLast;
782  }
783  static bool classof(const TypeDecl *D) { return true; }
784};
785
786
787class TypedefDecl : public TypeDecl {
788  /// UnderlyingType - This is the type the typedef is set to.
789  QualType UnderlyingType;
790  TypedefDecl(DeclContext *DC, SourceLocation L,
791              IdentifierInfo *Id, QualType T, ScopedDecl *PD)
792    : TypeDecl(Typedef, DC, L, Id, PD), UnderlyingType(T) {}
793
794  virtual ~TypedefDecl() {}
795public:
796
797  static TypedefDecl *Create(ASTContext &C, DeclContext *DC,
798                             SourceLocation L,IdentifierInfo *Id,
799                             QualType T, ScopedDecl *PD);
800
801  QualType getUnderlyingType() const { return UnderlyingType; }
802  void setUnderlyingType(QualType newType) { UnderlyingType = newType; }
803
804  // Implement isa/cast/dyncast/etc.
805  static bool classof(const Decl *D) { return D->getKind() == Typedef; }
806  static bool classof(const TypedefDecl *D) { return true; }
807
808protected:
809  /// EmitImpl - Serialize this TypedefDecl.  Called by Decl::Emit.
810  virtual void EmitImpl(llvm::Serializer& S) const;
811
812  /// CreateImpl - Deserialize a TypedefDecl.  Called by Decl::Create.
813  static TypedefDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
814
815  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
816};
817
818
819/// TagDecl - Represents the declaration of a struct/union/class/enum.
820class TagDecl : public TypeDecl {
821public:
822  enum TagKind {
823    TK_struct,
824    TK_union,
825    TK_class,
826    TK_enum
827  };
828
829private:
830  /// TagDeclKind - The TagKind enum.
831  unsigned TagDeclKind : 2;
832
833  /// IsDefinition - True if this is a definition ("struct foo {};"), false if
834  /// it is a declaration ("struct foo;").
835  bool IsDefinition : 1;
836protected:
837  TagDecl(Kind DK, TagKind TK, DeclContext *DC, SourceLocation L,
838          IdentifierInfo *Id, ScopedDecl *PrevDecl)
839    : TypeDecl(DK, DC, L, Id, PrevDecl) {
840    assert((DK != Enum || TK == TK_enum) &&"EnumDecl not matched with TK_enum");
841    TagDeclKind = TK;
842    IsDefinition = false;
843  }
844public:
845
846  /// isDefinition - Return true if this decl has its body specified.
847  bool isDefinition() const {
848    return IsDefinition;
849  }
850
851  /// getDefinition - Returns the TagDecl that actually defines this
852  ///  struct/union/class/enum.  When determining whether or not a
853  ///  struct/union/class/enum is completely defined, one should use this method
854  ///  as opposed to 'isDefinition'.  'isDefinition' indicates whether or not a
855  ///  specific TagDecl is defining declaration, not whether or not the
856  ///  struct/union/class/enum type is defined.  This method returns NULL if
857  ///  there is no TagDecl that defines the struct/union/class/enum.
858  TagDecl* getDefinition(ASTContext& C) const;
859
860  const char *getKindName() const {
861    switch (getTagKind()) {
862    default: assert(0 && "Unknown TagKind!");
863    case TK_struct: return "struct";
864    case TK_union:  return "union";
865    case TK_class:  return "class";
866    case TK_enum:   return "enum";
867    }
868  }
869
870  TagKind getTagKind() const {
871    return TagKind(TagDeclKind);
872  }
873
874  bool isStruct() const { return getTagKind() == TK_struct; }
875  bool isClass()  const { return getTagKind() == TK_class; }
876  bool isUnion()  const { return getTagKind() == TK_union; }
877  bool isEnum()   const { return getTagKind() == TK_enum; }
878
879  // Implement isa/cast/dyncast/etc.
880  static bool classof(const Decl *D) {
881    return D->getKind() >= TagFirst && D->getKind() <= TagLast;
882  }
883  static bool classof(const TagDecl *D) { return true; }
884protected:
885  void setDefinition(bool V) { IsDefinition = V; }
886};
887
888/// EnumDecl - Represents an enum.  As an extension, we allow forward-declared
889/// enums.
890class EnumDecl : public TagDecl, public DeclContext {
891  /// IntegerType - This represent the integer type that the enum corresponds
892  /// to for code generation purposes.  Note that the enumerator constants may
893  /// have a different type than this does.
894  QualType IntegerType;
895
896  EnumDecl(DeclContext *DC, SourceLocation L,
897           IdentifierInfo *Id, ScopedDecl *PrevDecl)
898    : TagDecl(Enum, TK_enum, DC, L, Id, PrevDecl), DeclContext(Enum) {
899      IntegerType = QualType();
900    }
901public:
902  static EnumDecl *Create(ASTContext &C, DeclContext *DC,
903                          SourceLocation L, IdentifierInfo *Id,
904                          ScopedDecl *PrevDecl);
905
906  virtual void Destroy(ASTContext& C);
907
908  /// completeDefinition - When created, the EnumDecl corresponds to a
909  /// forward-declared enum. This method is used to mark the
910  /// declaration as being defined; it's enumerators have already been
911  /// added (via DeclContext::addDecl). NewType is the new underlying
912  /// type of the enumeration type.
913  void completeDefinition(ASTContext &C, QualType NewType);
914
915  // enumerator_iterator - Iterates through the enumerators of this
916  // enumeration.
917  struct enumerator_iterator : public DeclContext::decl_iterator {
918    typedef EnumConstantDecl* value_type;
919    typedef EnumConstantDecl* reference;
920    typedef EnumConstantDecl* pointer;
921
922    enumerator_iterator() : DeclContext::decl_iterator() { }
923
924    explicit enumerator_iterator(DeclContext::decl_iterator Pos)
925      : DeclContext::decl_iterator(Pos) { }
926
927    reference operator*() const {
928      return cast<EnumConstantDecl>(DeclContext::decl_iterator::operator*());
929    }
930
931    pointer operator->() const {
932      return cast<EnumConstantDecl>(DeclContext::decl_iterator::operator*());
933    }
934  };
935
936  enumerator_iterator enumerator_begin() const {
937    return enumerator_iterator(this->decls_begin());
938  }
939
940  enumerator_iterator enumerator_end() const {
941    return enumerator_iterator(this->decls_end());
942  }
943
944  /// getIntegerType - Return the integer type this enum decl corresponds to.
945  /// This returns a null qualtype for an enum forward definition.
946  QualType getIntegerType() const { return IntegerType; }
947
948  static bool classof(const Decl *D) { return D->getKind() == Enum; }
949  static bool classof(const EnumDecl *D) { return true; }
950  static DeclContext *castToDeclContext(const EnumDecl *D) {
951    return static_cast<DeclContext *>(const_cast<EnumDecl*>(D));
952  }
953  static EnumDecl *castFromDeclContext(const DeclContext *DC) {
954    return static_cast<EnumDecl *>(const_cast<DeclContext*>(DC));
955  }
956
957protected:
958  /// EmitImpl - Serialize this EnumDecl.  Called by Decl::Emit.
959  virtual void EmitImpl(llvm::Serializer& S) const;
960
961  /// CreateImpl - Deserialize a EnumDecl.  Called by Decl::Create.
962  static EnumDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
963
964  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
965};
966
967
968/// RecordDecl - Represents a struct/union/class.  For example:
969///   struct X;                  // Forward declaration, no "body".
970///   union Y { int A, B; };     // Has body with members A and B (FieldDecls).
971/// This decl will be marked invalid if *any* members are invalid.
972///
973class RecordDecl : public TagDecl, public DeclContext {
974  /// HasFlexibleArrayMember - This is true if this struct ends with a flexible
975  /// array member (e.g. int X[]) or if this union contains a struct that does.
976  /// If so, this cannot be contained in arrays or other structs as a member.
977  bool HasFlexibleArrayMember : 1;
978
979protected:
980  RecordDecl(Kind DK, TagKind TK, DeclContext *DC,
981             SourceLocation L, IdentifierInfo *Id);
982  virtual ~RecordDecl();
983
984public:
985  static RecordDecl *Create(ASTContext &C, TagKind TK, DeclContext *DC,
986                            SourceLocation L, IdentifierInfo *Id,
987                            RecordDecl* PrevDecl = 0);
988
989  virtual void Destroy(ASTContext& C);
990
991  bool hasFlexibleArrayMember() const { return HasFlexibleArrayMember; }
992  void setHasFlexibleArrayMember(bool V) { HasFlexibleArrayMember = V; }
993
994  /// getDefinition - Returns the RecordDecl that actually defines this
995  ///  struct/union/class.  When determining whether or not a struct/union/class
996  ///  is completely defined, one should use this method as opposed to
997  ///  'isDefinition'.  'isDefinition' indicates whether or not a specific
998  ///  RecordDecl is defining declaration, not whether or not the record
999  ///  type is defined.  This method returns NULL if there is no RecordDecl
1000  ///  that defines the struct/union/tag.
1001  RecordDecl* getDefinition(ASTContext& C) const {
1002    return cast_or_null<RecordDecl>(TagDecl::getDefinition(C));
1003  }
1004
1005  // Iterator access to field members.
1006  class field_iterator {
1007    /// Current - Current position within the sequence of declarations
1008    /// in this record.
1009    DeclContext::decl_iterator Current;
1010
1011    /// End - Last position in the sequence of declarations in this
1012    /// record.
1013    DeclContext::decl_iterator End;
1014
1015    /// SkipToNextField - Advances the current position up to the next
1016    /// FieldDecl.
1017    void SkipToNextField() {
1018      while (Current != End && !isa<FieldDecl>(*Current))
1019        ++Current;
1020    }
1021
1022  public:
1023    typedef FieldDecl*                value_type;
1024    typedef FieldDecl*                reference;
1025    typedef FieldDecl*                pointer;
1026    typedef std::ptrdiff_t            difference_type;
1027    typedef std::forward_iterator_tag iterator_category;
1028
1029    field_iterator() : Current(), End() { }
1030
1031    field_iterator(DeclContext::decl_iterator C, DeclContext::decl_iterator E)
1032      : Current(C), End(E) {
1033      SkipToNextField();
1034    }
1035
1036    reference operator*() const { return cast<FieldDecl>(*Current); }
1037
1038    pointer operator->() const { return cast<FieldDecl>(*Current); }
1039
1040    field_iterator& operator++() {
1041      ++Current;
1042      SkipToNextField();
1043      return *this;
1044    }
1045
1046    field_iterator operator++(int) {
1047      field_iterator tmp(*this);
1048      ++(*this);
1049      return tmp;
1050    }
1051
1052    friend bool operator==(const field_iterator& x, const field_iterator& y) {
1053      return x.Current == y.Current;
1054    }
1055
1056    friend bool operator!=(const field_iterator& x, const field_iterator& y) {
1057      return x.Current != y.Current;
1058    }
1059  };
1060
1061  typedef field_iterator field_const_iterator;
1062
1063  field_iterator field_begin() const {
1064    return field_iterator(decls_begin(), decls_end());
1065  }
1066  field_iterator field_end() const {
1067    return field_iterator(decls_end(), decls_end());
1068  }
1069
1070  /// completeDefinition - Notes that the definition of this type is
1071  /// now complete.
1072  void completeDefinition(ASTContext& C);
1073
1074  static bool classof(const Decl *D) {
1075    return D->getKind() >= RecordFirst && D->getKind() <= RecordLast;
1076  }
1077  static bool classof(const RecordDecl *D) { return true; }
1078
1079protected:
1080  /// EmitImpl - Serialize this RecordDecl.  Called by Decl::Emit.
1081  virtual void EmitImpl(llvm::Serializer& S) const;
1082
1083  /// CreateImpl - Deserialize a RecordDecl.  Called by Decl::Create.
1084  static RecordDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
1085
1086  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
1087};
1088
1089class FileScopeAsmDecl : public Decl {
1090  StringLiteral *AsmString;
1091  FileScopeAsmDecl(SourceLocation L, StringLiteral *asmstring)
1092    : Decl(FileScopeAsm, L), AsmString(asmstring) {}
1093public:
1094  static FileScopeAsmDecl *Create(ASTContext &C, SourceLocation L,
1095                                  StringLiteral *Str);
1096
1097  const StringLiteral *getAsmString() const { return AsmString; }
1098  StringLiteral *getAsmString() { return AsmString; }
1099  static bool classof(const Decl *D) {
1100    return D->getKind() == FileScopeAsm;
1101  }
1102  static bool classof(const FileScopeAsmDecl *D) { return true; }
1103protected:
1104  /// EmitImpl - Serialize this FileScopeAsmDecl. Called by Decl::Emit.
1105  virtual void EmitImpl(llvm::Serializer& S) const;
1106
1107  /// CreateImpl - Deserialize a FileScopeAsmDecl.  Called by Decl::Create.
1108  static FileScopeAsmDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
1109
1110  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
1111};
1112
1113/// BlockDecl - This represents a block literal declaration, which is like an
1114/// unnamed FunctionDecl.  For example:
1115/// ^{ statement-body }   or   ^(int arg1, float arg2){ statement-body }
1116///
1117class BlockDecl : public Decl, public DeclContext {
1118  llvm::SmallVector<ParmVarDecl*, 8> Args;
1119  Stmt *Body;
1120
1121  // Since BlockDecl's aren't named/scoped, we need to store the context.
1122  DeclContext *ParentContext;
1123protected:
1124  BlockDecl(DeclContext *DC, SourceLocation CaretLoc)
1125    : Decl(Block, CaretLoc), DeclContext(Block), Body(0), ParentContext(DC) {}
1126
1127  virtual ~BlockDecl();
1128  virtual void Destroy(ASTContext& C);
1129
1130public:
1131  static BlockDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L);
1132
1133  SourceLocation getCaretLocation() const { return getLocation(); }
1134
1135  Stmt *getBody() const { return Body; }
1136  void setBody(Stmt *B) { Body = B; }
1137
1138  void setArgs(ParmVarDecl **args, unsigned numargs) {
1139    Args.clear();
1140    Args.insert(Args.begin(), args, args+numargs);
1141  }
1142  const DeclContext *getParentContext() const { return ParentContext; }
1143  DeclContext *getParentContext() { return ParentContext; }
1144
1145  /// arg_iterator - Iterate over the ParmVarDecl's for this block.
1146  typedef llvm::SmallVector<ParmVarDecl*, 8>::const_iterator param_iterator;
1147  bool param_empty() const { return Args.empty(); }
1148  param_iterator param_begin() const { return Args.begin(); }
1149  param_iterator param_end() const { return Args.end(); }
1150
1151  // Implement isa/cast/dyncast/etc.
1152  static bool classof(const Decl *D) { return D->getKind() == Block; }
1153  static bool classof(const BlockDecl *D) { return true; }
1154  static DeclContext *castToDeclContext(const BlockDecl *D) {
1155    return static_cast<DeclContext *>(const_cast<BlockDecl*>(D));
1156  }
1157  static BlockDecl *castFromDeclContext(const DeclContext *DC) {
1158    return static_cast<BlockDecl *>(const_cast<DeclContext*>(DC));
1159  }
1160
1161protected:
1162  /// EmitImpl - Serialize this BlockDecl. Called by Decl::Emit.
1163  virtual void EmitImpl(llvm::Serializer& S) const;
1164
1165  /// CreateImpl - Deserialize a BlockDecl.  Called by Decl::Create.
1166  static BlockDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
1167
1168  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
1169};
1170
1171}  // end namespace clang
1172
1173#endif
1174