DeclCXX.h revision 195341
1//===-- DeclCXX.h - Classes for representing C++ 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 C++ Decl subclasses.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_AST_DECLCXX_H
15#define LLVM_CLANG_AST_DECLCXX_H
16
17#include "clang/AST/Decl.h"
18#include "llvm/ADT/SmallVector.h"
19
20namespace clang {
21
22class ClassTemplateDecl;
23class CXXRecordDecl;
24class CXXConstructorDecl;
25class CXXDestructorDecl;
26class CXXConversionDecl;
27class CXXMethodDecl;
28class ClassTemplateSpecializationDecl;
29
30/// \brief Represents any kind of function declaration, whether it is a
31/// concrete function or a function template.
32class AnyFunctionDecl {
33  NamedDecl *Function;
34
35  AnyFunctionDecl(NamedDecl *ND) : Function(ND) { }
36
37public:
38  AnyFunctionDecl(FunctionDecl *FD) : Function(FD) { }
39  AnyFunctionDecl(FunctionTemplateDecl *FTD);
40
41  /// \brief Implicily converts any function or function template into a
42  /// named declaration.
43  operator NamedDecl *() const { return Function; }
44
45  /// \brief Retrieve the underlying function or function template.
46  NamedDecl *get() const { return Function; }
47
48  static AnyFunctionDecl getFromNamedDecl(NamedDecl *ND) {
49    return AnyFunctionDecl(ND);
50  }
51};
52
53} // end namespace clang
54
55namespace llvm {
56  /// Implement simplify_type for AnyFunctionDecl, so that we can dyn_cast from
57  /// AnyFunctionDecl to any function or function template declaration.
58  template<> struct simplify_type<const ::clang::AnyFunctionDecl> {
59    typedef ::clang::NamedDecl* SimpleType;
60    static SimpleType getSimplifiedValue(const ::clang::AnyFunctionDecl &Val) {
61      return Val;
62    }
63  };
64  template<> struct simplify_type< ::clang::AnyFunctionDecl>
65  : public simplify_type<const ::clang::AnyFunctionDecl> {};
66
67  // Provide PointerLikeTypeTraits for non-cvr pointers.
68  template<>
69  class PointerLikeTypeTraits< ::clang::AnyFunctionDecl> {
70  public:
71    static inline void *getAsVoidPointer(::clang::AnyFunctionDecl F) {
72      return F.get();
73    }
74    static inline ::clang::AnyFunctionDecl getFromVoidPointer(void *P) {
75      return ::clang::AnyFunctionDecl::getFromNamedDecl(
76                                      static_cast< ::clang::NamedDecl*>(P));
77    }
78
79    enum { NumLowBitsAvailable = 2 };
80  };
81
82} // end namespace llvm
83
84namespace clang {
85
86/// OverloadedFunctionDecl - An instance of this class represents a
87/// set of overloaded functions. All of the functions have the same
88/// name and occur within the same scope.
89///
90/// An OverloadedFunctionDecl has no ownership over the FunctionDecl
91/// nodes it contains. Rather, the FunctionDecls are owned by the
92/// enclosing scope (which also owns the OverloadedFunctionDecl
93/// node). OverloadedFunctionDecl is used primarily to store a set of
94/// overloaded functions for name lookup.
95class OverloadedFunctionDecl : public NamedDecl {
96protected:
97  OverloadedFunctionDecl(DeclContext *DC, DeclarationName N)
98    : NamedDecl(OverloadedFunction, DC, SourceLocation(), N) { }
99
100  /// Functions - the set of overloaded functions contained in this
101  /// overload set.
102  llvm::SmallVector<AnyFunctionDecl, 4> Functions;
103
104  // FIXME: This should go away when we stop using
105  // OverloadedFunctionDecl to store conversions in CXXRecordDecl.
106  friend class CXXRecordDecl;
107
108public:
109  typedef llvm::SmallVector<AnyFunctionDecl, 4>::iterator function_iterator;
110  typedef llvm::SmallVector<AnyFunctionDecl, 4>::const_iterator
111    function_const_iterator;
112
113  static OverloadedFunctionDecl *Create(ASTContext &C, DeclContext *DC,
114                                        DeclarationName N);
115
116  /// \brief Add a new overloaded function or function template to the set
117  /// of overloaded function templates.
118  void addOverload(AnyFunctionDecl F);
119
120  function_iterator function_begin() { return Functions.begin(); }
121  function_iterator function_end() { return Functions.end(); }
122  function_const_iterator function_begin() const { return Functions.begin(); }
123  function_const_iterator function_end() const { return Functions.end(); }
124
125  /// \brief Returns the number of overloaded functions stored in
126  /// this set.
127  unsigned size() const { return Functions.size(); }
128
129  // Implement isa/cast/dyncast/etc.
130  static bool classof(const Decl *D) {
131    return D->getKind() == OverloadedFunction;
132  }
133  static bool classof(const OverloadedFunctionDecl *D) { return true; }
134};
135
136/// CXXBaseSpecifier - A base class of a C++ class.
137///
138/// Each CXXBaseSpecifier represents a single, direct base class (or
139/// struct) of a C++ class (or struct). It specifies the type of that
140/// base class, whether it is a virtual or non-virtual base, and what
141/// level of access (public, protected, private) is used for the
142/// derivation. For example:
143///
144/// @code
145///   class A { };
146///   class B { };
147///   class C : public virtual A, protected B { };
148/// @endcode
149///
150/// In this code, C will have two CXXBaseSpecifiers, one for "public
151/// virtual A" and the other for "protected B".
152class CXXBaseSpecifier {
153  /// Range - The source code range that covers the full base
154  /// specifier, including the "virtual" (if present) and access
155  /// specifier (if present).
156  SourceRange Range;
157
158  /// Virtual - Whether this is a virtual base class or not.
159  bool Virtual : 1;
160
161  /// BaseOfClass - Whether this is the base of a class (true) or of a
162  /// struct (false). This determines the mapping from the access
163  /// specifier as written in the source code to the access specifier
164  /// used for semantic analysis.
165  bool BaseOfClass : 1;
166
167  /// Access - Access specifier as written in the source code (which
168  /// may be AS_none). The actual type of data stored here is an
169  /// AccessSpecifier, but we use "unsigned" here to work around a
170  /// VC++ bug.
171  unsigned Access : 2;
172
173  /// BaseType - The type of the base class. This will be a class or
174  /// struct (or a typedef of such).
175  QualType BaseType;
176
177public:
178  CXXBaseSpecifier() { }
179
180  CXXBaseSpecifier(SourceRange R, bool V, bool BC, AccessSpecifier A, QualType T)
181    : Range(R), Virtual(V), BaseOfClass(BC), Access(A), BaseType(T) { }
182
183  /// getSourceRange - Retrieves the source range that contains the
184  /// entire base specifier.
185  SourceRange getSourceRange() const { return Range; }
186
187  /// isVirtual - Determines whether the base class is a virtual base
188  /// class (or not).
189  bool isVirtual() const { return Virtual; }
190
191  /// getAccessSpecifier - Returns the access specifier for this base
192  /// specifier. This is the actual base specifier as used for
193  /// semantic analysis, so the result can never be AS_none. To
194  /// retrieve the access specifier as written in the source code, use
195  /// getAccessSpecifierAsWritten().
196  AccessSpecifier getAccessSpecifier() const {
197    if ((AccessSpecifier)Access == AS_none)
198      return BaseOfClass? AS_private : AS_public;
199    else
200      return (AccessSpecifier)Access;
201  }
202
203  /// getAccessSpecifierAsWritten - Retrieves the access specifier as
204  /// written in the source code (which may mean that no access
205  /// specifier was explicitly written). Use getAccessSpecifier() to
206  /// retrieve the access specifier for use in semantic analysis.
207  AccessSpecifier getAccessSpecifierAsWritten() const {
208    return (AccessSpecifier)Access;
209  }
210
211  /// getType - Retrieves the type of the base class. This type will
212  /// always be an unqualified class type.
213  QualType getType() const { return BaseType; }
214};
215
216/// CXXRecordDecl - Represents a C++ struct/union/class.
217/// FIXME: This class will disappear once we've properly taught RecordDecl
218/// to deal with C++-specific things.
219class CXXRecordDecl : public RecordDecl {
220  /// UserDeclaredConstructor - True when this class has a
221  /// user-declared constructor.
222  bool UserDeclaredConstructor : 1;
223
224  /// UserDeclaredCopyConstructor - True when this class has a
225  /// user-declared copy constructor.
226  bool UserDeclaredCopyConstructor : 1;
227
228  /// UserDeclaredCopyAssignment - True when this class has a
229  /// user-declared copy assignment operator.
230  bool UserDeclaredCopyAssignment : 1;
231
232  /// UserDeclaredDestructor - True when this class has a
233  /// user-declared destructor.
234  bool UserDeclaredDestructor : 1;
235
236  /// Aggregate - True when this class is an aggregate.
237  bool Aggregate : 1;
238
239  /// PlainOldData - True when this class is a POD-type.
240  bool PlainOldData : 1;
241
242  /// Polymorphic - True when this class is polymorphic, i.e. has at least one
243  /// virtual member or derives from a polymorphic class.
244  bool Polymorphic : 1;
245
246  /// Abstract - True when this class is abstract, i.e. has at least one
247  /// pure virtual function, (that can come from a base class).
248  bool Abstract : 1;
249
250  /// HasTrivialConstructor - True when this class has a trivial constructor
251  bool HasTrivialConstructor : 1;
252
253  /// HasTrivialDestructor - True when this class has a trivial destructor
254  bool HasTrivialDestructor : 1;
255
256  /// Bases - Base classes of this class.
257  /// FIXME: This is wasted space for a union.
258  CXXBaseSpecifier *Bases;
259
260  /// NumBases - The number of base class specifiers in Bases.
261  unsigned NumBases;
262
263  /// Conversions - Overload set containing the conversion functions
264  /// of this C++ class (but not its inherited conversion
265  /// functions). Each of the entries in this overload set is a
266  /// CXXConversionDecl.
267  OverloadedFunctionDecl Conversions;
268
269  /// \brief The template or declaration that this declaration
270  /// describes or was instantiated from, respectively.
271  ///
272  /// For non-templates, this value will be NULL. For record
273  /// declarations that describe a class template, this will be a
274  /// pointer to a ClassTemplateDecl. For member
275  /// classes of class template specializations, this will be the
276  /// RecordDecl from which the member class was instantiated.
277  llvm::PointerUnion<ClassTemplateDecl*, CXXRecordDecl*>
278    TemplateOrInstantiation;
279
280protected:
281  CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC,
282                SourceLocation L, IdentifierInfo *Id);
283
284  ~CXXRecordDecl();
285
286public:
287  /// base_class_iterator - Iterator that traverses the base classes
288  /// of a clas.
289  typedef CXXBaseSpecifier*       base_class_iterator;
290
291  /// base_class_const_iterator - Iterator that traverses the base
292  /// classes of a clas.
293  typedef const CXXBaseSpecifier* base_class_const_iterator;
294
295  static CXXRecordDecl *Create(ASTContext &C, TagKind TK, DeclContext *DC,
296                               SourceLocation L, IdentifierInfo *Id,
297                               CXXRecordDecl* PrevDecl=0,
298                               bool DelayTypeCreation = false);
299
300  virtual void Destroy(ASTContext& C);
301
302  /// setBases - Sets the base classes of this struct or class.
303  void setBases(ASTContext &C,
304                CXXBaseSpecifier const * const *Bases, unsigned NumBases);
305
306  /// getNumBases - Retrieves the number of base classes of this
307  /// class.
308  unsigned getNumBases() const { return NumBases; }
309
310  base_class_iterator       bases_begin()       { return Bases; }
311  base_class_const_iterator bases_begin() const { return Bases; }
312  base_class_iterator       bases_end()         { return Bases + NumBases; }
313  base_class_const_iterator bases_end()   const { return Bases + NumBases; }
314
315  /// hasConstCopyConstructor - Determines whether this class has a
316  /// copy constructor that accepts a const-qualified argument.
317  bool hasConstCopyConstructor(ASTContext &Context) const;
318
319  /// getCopyConstructor - Returns the copy constructor for this class
320  CXXConstructorDecl *getCopyConstructor(ASTContext &Context,
321                                         unsigned TypeQuals) const;
322
323  /// hasConstCopyAssignment - Determines whether this class has a
324  /// copy assignment operator that accepts a const-qualified argument.
325  bool hasConstCopyAssignment(ASTContext &Context) const;
326
327  /// addedConstructor - Notify the class that another constructor has
328  /// been added. This routine helps maintain information about the
329  /// class based on which constructors have been added.
330  void addedConstructor(ASTContext &Context, CXXConstructorDecl *ConDecl);
331
332  /// hasUserDeclaredConstructor - Whether this class has any
333  /// user-declared constructors. When true, a default constructor
334  /// will not be implicitly declared.
335  bool hasUserDeclaredConstructor() const { return UserDeclaredConstructor; }
336
337  /// hasUserDeclaredCopyConstructor - Whether this class has a
338  /// user-declared copy constructor. When false, a copy constructor
339  /// will be implicitly declared.
340  bool hasUserDeclaredCopyConstructor() const {
341    return UserDeclaredCopyConstructor;
342  }
343
344  /// addedAssignmentOperator - Notify the class that another assignment
345  /// operator has been added. This routine helps maintain information about the
346   /// class based on which operators have been added.
347  void addedAssignmentOperator(ASTContext &Context, CXXMethodDecl *OpDecl);
348
349  /// hasUserDeclaredCopyAssignment - Whether this class has a
350  /// user-declared copy assignment operator. When false, a copy
351  /// assigment operator will be implicitly declared.
352  bool hasUserDeclaredCopyAssignment() const {
353    return UserDeclaredCopyAssignment;
354  }
355
356  /// hasUserDeclaredDestructor - Whether this class has a
357  /// user-declared destructor. When false, a destructor will be
358  /// implicitly declared.
359  bool hasUserDeclaredDestructor() const { return UserDeclaredDestructor; }
360
361  /// setUserDeclaredDestructor - Set whether this class has a
362  /// user-declared destructor. If not set by the time the class is
363  /// fully defined, a destructor will be implicitly declared.
364  void setUserDeclaredDestructor(bool UCD) {
365    UserDeclaredDestructor = UCD;
366  }
367
368  /// getConversions - Retrieve the overload set containing all of the
369  /// conversion functions in this class.
370  OverloadedFunctionDecl *getConversionFunctions() {
371    return &Conversions;
372  }
373  const OverloadedFunctionDecl *getConversionFunctions() const {
374    return &Conversions;
375  }
376
377  /// addConversionFunction - Add a new conversion function to the
378  /// list of conversion functions.
379  void addConversionFunction(ASTContext &Context, CXXConversionDecl *ConvDecl);
380
381  /// isAggregate - Whether this class is an aggregate (C++
382  /// [dcl.init.aggr]), which is a class with no user-declared
383  /// constructors, no private or protected non-static data members,
384  /// no base classes, and no virtual functions (C++ [dcl.init.aggr]p1).
385  bool isAggregate() const { return Aggregate; }
386
387  /// setAggregate - Set whether this class is an aggregate (C++
388  /// [dcl.init.aggr]).
389  void setAggregate(bool Agg) { Aggregate = Agg; }
390
391  /// isPOD - Whether this class is a POD-type (C++ [class]p4), which is a class
392  /// that is an aggregate that has no non-static non-POD data members, no
393  /// reference data members, no user-defined copy assignment operator and no
394  /// user-defined destructor.
395  bool isPOD() const { return PlainOldData; }
396
397  /// setPOD - Set whether this class is a POD-type (C++ [class]p4).
398  void setPOD(bool POD) { PlainOldData = POD; }
399
400  /// isPolymorphic - Whether this class is polymorphic (C++ [class.virtual]),
401  /// which means that the class contains or inherits a virtual function.
402  bool isPolymorphic() const { return Polymorphic; }
403
404  /// setPolymorphic - Set whether this class is polymorphic (C++
405  /// [class.virtual]).
406  void setPolymorphic(bool Poly) { Polymorphic = Poly; }
407
408  /// isAbstract - Whether this class is abstract (C++ [class.abstract]),
409  /// which means that the class contains or inherits a pure virtual function.
410  bool isAbstract() const { return Abstract; }
411
412  /// setAbstract - Set whether this class is abstract (C++ [class.abstract])
413  void setAbstract(bool Abs) { Abstract = Abs; }
414
415  // hasTrivialConstructor - Whether this class has a trivial constructor
416  // (C++ [class.ctor]p5)
417  bool hasTrivialConstructor() const { return HasTrivialConstructor; }
418
419  // setHasTrivialConstructor - Set whether this class has a trivial constructor
420  // (C++ [class.ctor]p5)
421  void setHasTrivialConstructor(bool TC) { HasTrivialConstructor = TC; }
422
423  // hasTrivialDestructor - Whether this class has a trivial destructor
424  // (C++ [class.dtor]p3)
425  bool hasTrivialDestructor() const { return HasTrivialDestructor; }
426
427  // setHasTrivialDestructor - Set whether this class has a trivial destructor
428  // (C++ [class.dtor]p3)
429  void setHasTrivialDestructor(bool TC) { HasTrivialDestructor = TC; }
430
431  /// \brief If this record is an instantiation of a member class,
432  /// retrieves the member class from which it was instantiated.
433  ///
434  /// This routine will return non-NULL for (non-templated) member
435  /// classes of class templates. For example, given:
436  ///
437  /// \code
438  /// template<typename T>
439  /// struct X {
440  ///   struct A { };
441  /// };
442  /// \endcode
443  ///
444  /// The declaration for X<int>::A is a (non-templated) CXXRecordDecl
445  /// whose parent is the class template specialization X<int>. For
446  /// this declaration, getInstantiatedFromMemberClass() will return
447  /// the CXXRecordDecl X<T>::A. When a complete definition of
448  /// X<int>::A is required, it will be instantiated from the
449  /// declaration returned by getInstantiatedFromMemberClass().
450  CXXRecordDecl *getInstantiatedFromMemberClass() const {
451    return TemplateOrInstantiation.dyn_cast<CXXRecordDecl*>();
452  }
453
454  /// \brief Specify that this record is an instantiation of the
455  /// member class RD.
456  void setInstantiationOfMemberClass(CXXRecordDecl *RD) {
457    TemplateOrInstantiation = RD;
458  }
459
460  /// \brief Retrieves the class template that is described by this
461  /// class declaration.
462  ///
463  /// Every class template is represented as a ClassTemplateDecl and a
464  /// CXXRecordDecl. The former contains template properties (such as
465  /// the template parameter lists) while the latter contains the
466  /// actual description of the template's
467  /// contents. ClassTemplateDecl::getTemplatedDecl() retrieves the
468  /// CXXRecordDecl that from a ClassTemplateDecl, while
469  /// getDescribedClassTemplate() retrieves the ClassTemplateDecl from
470  /// a CXXRecordDecl.
471  ClassTemplateDecl *getDescribedClassTemplate() const {
472    return TemplateOrInstantiation.dyn_cast<ClassTemplateDecl*>();
473  }
474
475  void setDescribedClassTemplate(ClassTemplateDecl *Template) {
476    TemplateOrInstantiation = Template;
477  }
478
479  /// getDefaultConstructor - Returns the default constructor for this class
480  CXXConstructorDecl *getDefaultConstructor(ASTContext &Context);
481
482  /// getDestructor - Returns the destructor decl for this class.
483  const CXXDestructorDecl *getDestructor(ASTContext &Context);
484
485  /// isLocalClass - If the class is a local class [class.local], returns
486  /// the enclosing function declaration.
487  const FunctionDecl *isLocalClass() const {
488    if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(getDeclContext()))
489      return RD->isLocalClass();
490
491    return dyn_cast<FunctionDecl>(getDeclContext());
492  }
493
494  /// viewInheritance - Renders and displays an inheritance diagram
495  /// for this C++ class and all of its base classes (transitively) using
496  /// GraphViz.
497  void viewInheritance(ASTContext& Context) const;
498
499  static bool classof(const Decl *D) {
500    return D->getKind() == CXXRecord ||
501           D->getKind() == ClassTemplateSpecialization ||
502           D->getKind() == ClassTemplatePartialSpecialization;
503  }
504  static bool classof(const CXXRecordDecl *D) { return true; }
505  static bool classof(const ClassTemplateSpecializationDecl *D) {
506    return true;
507  }
508};
509
510/// CXXMethodDecl - Represents a static or instance method of a
511/// struct/union/class.
512class CXXMethodDecl : public FunctionDecl {
513protected:
514  CXXMethodDecl(Kind DK, CXXRecordDecl *RD, SourceLocation L,
515                DeclarationName N, QualType T,
516                bool isStatic, bool isInline)
517    : FunctionDecl(DK, RD, L, N, T, (isStatic ? Static : None),
518                   isInline) {}
519
520public:
521  static CXXMethodDecl *Create(ASTContext &C, CXXRecordDecl *RD,
522                              SourceLocation L, DeclarationName N,
523                              QualType T, bool isStatic = false,
524                              bool isInline = false);
525
526  bool isStatic() const { return getStorageClass() == Static; }
527  bool isInstance() const { return !isStatic(); }
528
529  bool isVirtual() const {
530    return isVirtualAsWritten() ||
531      (begin_overridden_methods() != end_overridden_methods());
532  }
533
534  ///
535  void addOverriddenMethod(const CXXMethodDecl *MD);
536
537  typedef const CXXMethodDecl ** method_iterator;
538
539  method_iterator begin_overridden_methods() const;
540  method_iterator end_overridden_methods() const;
541
542  /// getParent - Returns the parent of this method declaration, which
543  /// is the class in which this method is defined.
544  const CXXRecordDecl *getParent() const {
545    return cast<CXXRecordDecl>(FunctionDecl::getParent());
546  }
547
548  /// getParent - Returns the parent of this method declaration, which
549  /// is the class in which this method is defined.
550  CXXRecordDecl *getParent() {
551    return const_cast<CXXRecordDecl *>(
552             cast<CXXRecordDecl>(FunctionDecl::getParent()));
553  }
554
555  /// getThisType - Returns the type of 'this' pointer.
556  /// Should only be called for instance methods.
557  QualType getThisType(ASTContext &C) const;
558
559  unsigned getTypeQualifiers() const {
560    return getType()->getAsFunctionProtoType()->getTypeQuals();
561  }
562
563  // Implement isa/cast/dyncast/etc.
564  static bool classof(const Decl *D) {
565    return D->getKind() >= CXXMethod && D->getKind() <= CXXConversion;
566  }
567  static bool classof(const CXXMethodDecl *D) { return true; }
568};
569
570/// CXXBaseOrMemberInitializer - Represents a C++ base or member
571/// initializer, which is part of a constructor initializer that
572/// initializes one non-static member variable or one base class. For
573/// example, in the following, both 'A(a)' and 'f(3.14159)' are member
574/// initializers:
575///
576/// @code
577/// class A { };
578/// class B : public A {
579///   float f;
580/// public:
581///   B(A& a) : A(a), f(3.14159) { }
582/// };
583/// @endcode
584class CXXBaseOrMemberInitializer {
585  /// BaseOrMember - This points to the entity being initialized,
586  /// which is either a base class (a Type) or a non-static data
587  /// member. When the low bit is 1, it's a base
588  /// class; when the low bit is 0, it's a member.
589  uintptr_t BaseOrMember;
590
591  /// Args - The arguments used to initialize the base or member.
592  Expr **Args;
593  unsigned NumArgs;
594
595  /// IdLoc - Location of the id in ctor-initializer list.
596  SourceLocation IdLoc;
597
598public:
599  /// CXXBaseOrMemberInitializer - Creates a new base-class initializer.
600  explicit
601  CXXBaseOrMemberInitializer(QualType BaseType, Expr **Args, unsigned NumArgs,
602                             SourceLocation L);
603
604  /// CXXBaseOrMemberInitializer - Creates a new member initializer.
605  explicit
606  CXXBaseOrMemberInitializer(FieldDecl *Member, Expr **Args, unsigned NumArgs,
607                             SourceLocation L);
608
609  /// ~CXXBaseOrMemberInitializer - Destroy the base or member initializer.
610  ~CXXBaseOrMemberInitializer();
611
612  /// arg_iterator - Iterates through the member initialization
613  /// arguments.
614  typedef Expr **arg_iterator;
615
616  /// arg_const_iterator - Iterates through the member initialization
617  /// arguments.
618  typedef Expr * const * arg_const_iterator;
619
620  /// getBaseOrMember - get the generic 'member' representing either the field
621  /// or a base class.
622  void* getBaseOrMember() const { return reinterpret_cast<void*>(BaseOrMember); }
623
624  /// isBaseInitializer - Returns true when this initializer is
625  /// initializing a base class.
626  bool isBaseInitializer() const { return (BaseOrMember & 0x1) != 0; }
627
628  /// isMemberInitializer - Returns true when this initializer is
629  /// initializing a non-static data member.
630  bool isMemberInitializer() const { return (BaseOrMember & 0x1) == 0; }
631
632  /// getBaseClass - If this is a base class initializer, returns the
633  /// type used to specify the initializer. The resulting type will be
634  /// a class type or a typedef of a class type. If this is not a base
635  /// class initializer, returns NULL.
636  Type *getBaseClass() {
637    if (isBaseInitializer())
638      return reinterpret_cast<Type*>(BaseOrMember & ~0x01);
639    else
640      return 0;
641  }
642
643  /// getBaseClass - If this is a base class initializer, returns the
644  /// type used to specify the initializer. The resulting type will be
645  /// a class type or a typedef of a class type. If this is not a base
646  /// class initializer, returns NULL.
647  const Type *getBaseClass() const {
648    if (isBaseInitializer())
649      return reinterpret_cast<const Type*>(BaseOrMember & ~0x01);
650    else
651      return 0;
652  }
653
654  /// getMember - If this is a member initializer, returns the
655  /// declaration of the non-static data member being
656  /// initialized. Otherwise, returns NULL.
657  FieldDecl *getMember() {
658    if (isMemberInitializer())
659      return reinterpret_cast<FieldDecl *>(BaseOrMember);
660    else
661      return 0;
662  }
663
664  SourceLocation getSourceLocation() const { return IdLoc; }
665
666  /// begin() - Retrieve an iterator to the first initializer argument.
667  arg_iterator       begin()       { return Args; }
668  /// begin() - Retrieve an iterator to the first initializer argument.
669  arg_const_iterator begin() const { return Args; }
670
671  /// end() - Retrieve an iterator past the last initializer argument.
672  arg_iterator       end()       { return Args + NumArgs; }
673  /// end() - Retrieve an iterator past the last initializer argument.
674  arg_const_iterator end() const { return Args + NumArgs; }
675
676  /// getNumArgs - Determine the number of arguments used to
677  /// initialize the member or base.
678  unsigned getNumArgs() const { return NumArgs; }
679};
680
681/// CXXConstructorDecl - Represents a C++ constructor within a
682/// class. For example:
683///
684/// @code
685/// class X {
686/// public:
687///   explicit X(int); // represented by a CXXConstructorDecl.
688/// };
689/// @endcode
690class CXXConstructorDecl : public CXXMethodDecl {
691  /// Explicit - Whether this constructor is explicit.
692  bool Explicit : 1;
693
694  /// ImplicitlyDefined - Whether this constructor was implicitly
695  /// defined by the compiler. When false, the constructor was defined
696  /// by the user. In C++03, this flag will have the same value as
697  /// Implicit. In C++0x, however, a constructor that is
698  /// explicitly defaulted (i.e., defined with " = default") will have
699  /// @c !Implicit && ImplicitlyDefined.
700  bool ImplicitlyDefined : 1;
701
702  /// Support for base and member initializers.
703  /// BaseOrMemberInitializers - The arguments used to initialize the base
704  /// or member.
705  CXXBaseOrMemberInitializer **BaseOrMemberInitializers;
706  unsigned NumBaseOrMemberInitializers;
707
708  CXXConstructorDecl(CXXRecordDecl *RD, SourceLocation L,
709                     DeclarationName N, QualType T,
710                     bool isExplicit, bool isInline, bool isImplicitlyDeclared)
711    : CXXMethodDecl(CXXConstructor, RD, L, N, T, false, isInline),
712      Explicit(isExplicit), ImplicitlyDefined(false),
713      BaseOrMemberInitializers(0), NumBaseOrMemberInitializers(0) {
714    setImplicit(isImplicitlyDeclared);
715  }
716  virtual void Destroy(ASTContext& C);
717
718public:
719  static CXXConstructorDecl *Create(ASTContext &C, CXXRecordDecl *RD,
720                                    SourceLocation L, DeclarationName N,
721                                    QualType T, bool isExplicit,
722                                    bool isInline, bool isImplicitlyDeclared);
723
724  /// isExplicit - Whether this constructor was marked "explicit" or not.
725  bool isExplicit() const { return Explicit; }
726
727  /// isImplicitlyDefined - Whether this constructor was implicitly
728  /// defined. If false, then this constructor was defined by the
729  /// user. This operation can only be invoked if the constructor has
730  /// already been defined.
731  bool isImplicitlyDefined(ASTContext &C) const {
732    assert(isThisDeclarationADefinition() &&
733           "Can only get the implicit-definition flag once the "
734           "constructor has been defined");
735    return ImplicitlyDefined;
736  }
737
738  /// setImplicitlyDefined - Set whether this constructor was
739  /// implicitly defined or not.
740  void setImplicitlyDefined(bool ID) {
741    assert(isThisDeclarationADefinition() &&
742           "Can only set the implicit-definition flag once the constructor "
743           "has been defined");
744    ImplicitlyDefined = ID;
745  }
746
747  /// init_iterator - Iterates through the member/base initializer list.
748  typedef CXXBaseOrMemberInitializer **init_iterator;
749
750  /// init_const_iterator - Iterates through the memberbase initializer list.
751  typedef CXXBaseOrMemberInitializer * const * init_const_iterator;
752
753  /// begin() - Retrieve an iterator to the first initializer.
754  init_iterator       begin()       { return BaseOrMemberInitializers; }
755  /// begin() - Retrieve an iterator to the first initializer.
756  init_const_iterator begin() const { return BaseOrMemberInitializers; }
757
758  /// end() - Retrieve an iterator past the last initializer.
759  init_iterator       end()       {
760    return BaseOrMemberInitializers + NumBaseOrMemberInitializers;
761  }
762  /// end() - Retrieve an iterator past the last initializer.
763  init_const_iterator end() const {
764    return BaseOrMemberInitializers + NumBaseOrMemberInitializers;
765  }
766
767  /// getNumArgs - Determine the number of arguments used to
768  /// initialize the member or base.
769  unsigned getNumBaseOrMemberInitializers() const {
770      return NumBaseOrMemberInitializers;
771  }
772
773  void setBaseOrMemberInitializers(ASTContext &C,
774                                   CXXBaseOrMemberInitializer **Initializers,
775                                   unsigned NumInitializers);
776
777  /// isDefaultConstructor - Whether this constructor is a default
778  /// constructor (C++ [class.ctor]p5), which can be used to
779  /// default-initialize a class of this type.
780  bool isDefaultConstructor() const;
781
782  /// isCopyConstructor - Whether this constructor is a copy
783  /// constructor (C++ [class.copy]p2, which can be used to copy the
784  /// class. @p TypeQuals will be set to the qualifiers on the
785  /// argument type. For example, @p TypeQuals would be set to @c
786  /// QualType::Const for the following copy constructor:
787  ///
788  /// @code
789  /// class X {
790  /// public:
791  ///   X(const X&);
792  /// };
793  /// @endcode
794  bool isCopyConstructor(ASTContext &Context, unsigned &TypeQuals) const;
795
796  /// isCopyConstructor - Whether this constructor is a copy
797  /// constructor (C++ [class.copy]p2, which can be used to copy the
798  /// class.
799  bool isCopyConstructor(ASTContext &Context) const {
800    unsigned TypeQuals = 0;
801    return isCopyConstructor(Context, TypeQuals);
802  }
803
804  /// isConvertingConstructor - Whether this constructor is a
805  /// converting constructor (C++ [class.conv.ctor]), which can be
806  /// used for user-defined conversions.
807  bool isConvertingConstructor() const;
808
809  // Implement isa/cast/dyncast/etc.
810  static bool classof(const Decl *D) {
811    return D->getKind() == CXXConstructor;
812  }
813  static bool classof(const CXXConstructorDecl *D) { return true; }
814};
815
816/// CXXDestructorDecl - Represents a C++ destructor within a
817/// class. For example:
818///
819/// @code
820/// class X {
821/// public:
822///   ~X(); // represented by a CXXDestructorDecl.
823/// };
824/// @endcode
825class CXXDestructorDecl : public CXXMethodDecl {
826  /// ImplicitlyDefined - Whether this destructor was implicitly
827  /// defined by the compiler. When false, the destructor was defined
828  /// by the user. In C++03, this flag will have the same value as
829  /// Implicit. In C++0x, however, a destructor that is
830  /// explicitly defaulted (i.e., defined with " = default") will have
831  /// @c !Implicit && ImplicitlyDefined.
832  bool ImplicitlyDefined : 1;
833
834  CXXDestructorDecl(CXXRecordDecl *RD, SourceLocation L,
835                    DeclarationName N, QualType T,
836                    bool isInline, bool isImplicitlyDeclared)
837    : CXXMethodDecl(CXXDestructor, RD, L, N, T, false, isInline),
838      ImplicitlyDefined(false) {
839    setImplicit(isImplicitlyDeclared);
840  }
841
842public:
843  static CXXDestructorDecl *Create(ASTContext &C, CXXRecordDecl *RD,
844                                   SourceLocation L, DeclarationName N,
845                                   QualType T, bool isInline,
846                                   bool isImplicitlyDeclared);
847
848  /// isImplicitlyDefined - Whether this destructor was implicitly
849  /// defined. If false, then this destructor was defined by the
850  /// user. This operation can only be invoked if the destructor has
851  /// already been defined.
852  bool isImplicitlyDefined() const {
853    assert(isThisDeclarationADefinition() &&
854           "Can only get the implicit-definition flag once the destructor has been defined");
855    return ImplicitlyDefined;
856  }
857
858  /// setImplicitlyDefined - Set whether this destructor was
859  /// implicitly defined or not.
860  void setImplicitlyDefined(bool ID) {
861    assert(isThisDeclarationADefinition() &&
862           "Can only set the implicit-definition flag once the destructor has been defined");
863    ImplicitlyDefined = ID;
864  }
865
866  // Implement isa/cast/dyncast/etc.
867  static bool classof(const Decl *D) {
868    return D->getKind() == CXXDestructor;
869  }
870  static bool classof(const CXXDestructorDecl *D) { return true; }
871};
872
873/// CXXConversionDecl - Represents a C++ conversion function within a
874/// class. For example:
875///
876/// @code
877/// class X {
878/// public:
879///   operator bool();
880/// };
881/// @endcode
882class CXXConversionDecl : public CXXMethodDecl {
883  /// Explicit - Whether this conversion function is marked
884  /// "explicit", meaning that it can only be applied when the user
885  /// explicitly wrote a cast. This is a C++0x feature.
886  bool Explicit : 1;
887
888  CXXConversionDecl(CXXRecordDecl *RD, SourceLocation L,
889                    DeclarationName N, QualType T,
890                    bool isInline, bool isExplicit)
891    : CXXMethodDecl(CXXConversion, RD, L, N, T, false, isInline),
892      Explicit(isExplicit) { }
893
894public:
895  static CXXConversionDecl *Create(ASTContext &C, CXXRecordDecl *RD,
896                                   SourceLocation L, DeclarationName N,
897                                   QualType T, bool isInline,
898                                   bool isExplicit);
899
900  /// isExplicit - Whether this is an explicit conversion operator
901  /// (C++0x only). Explicit conversion operators are only considered
902  /// when the user has explicitly written a cast.
903  bool isExplicit() const { return Explicit; }
904
905  /// getConversionType - Returns the type that this conversion
906  /// function is converting to.
907  QualType getConversionType() const {
908    return getType()->getAsFunctionType()->getResultType();
909  }
910
911  // Implement isa/cast/dyncast/etc.
912  static bool classof(const Decl *D) {
913    return D->getKind() == CXXConversion;
914  }
915  static bool classof(const CXXConversionDecl *D) { return true; }
916};
917
918/// LinkageSpecDecl - This represents a linkage specification.  For example:
919///   extern "C" void foo();
920///
921class LinkageSpecDecl : public Decl, public DeclContext {
922public:
923  /// LanguageIDs - Used to represent the language in a linkage
924  /// specification.  The values are part of the serialization abi for
925  /// ASTs and cannot be changed without altering that abi.  To help
926  /// ensure a stable abi for this, we choose the DW_LANG_ encodings
927  /// from the dwarf standard.
928  enum LanguageIDs { lang_c = /* DW_LANG_C */ 0x0002,
929  lang_cxx = /* DW_LANG_C_plus_plus */ 0x0004 };
930private:
931  /// Language - The language for this linkage specification.
932  LanguageIDs Language;
933
934  /// HadBraces - Whether this linkage specification had curly braces or not.
935  bool HadBraces : 1;
936
937  LinkageSpecDecl(DeclContext *DC, SourceLocation L, LanguageIDs lang,
938                  bool Braces)
939    : Decl(LinkageSpec, DC, L),
940      DeclContext(LinkageSpec), Language(lang), HadBraces(Braces) { }
941
942public:
943  static LinkageSpecDecl *Create(ASTContext &C, DeclContext *DC,
944                                 SourceLocation L, LanguageIDs Lang,
945                                 bool Braces);
946
947  LanguageIDs getLanguage() const { return Language; }
948
949  /// hasBraces - Determines whether this linkage specification had
950  /// braces in its syntactic form.
951  bool hasBraces() const { return HadBraces; }
952
953  static bool classof(const Decl *D) {
954    return D->getKind() == LinkageSpec;
955  }
956  static bool classof(const LinkageSpecDecl *D) { return true; }
957  static DeclContext *castToDeclContext(const LinkageSpecDecl *D) {
958    return static_cast<DeclContext *>(const_cast<LinkageSpecDecl*>(D));
959  }
960  static LinkageSpecDecl *castFromDeclContext(const DeclContext *DC) {
961    return static_cast<LinkageSpecDecl *>(const_cast<DeclContext*>(DC));
962  }
963};
964
965/// UsingDirectiveDecl - Represents C++ using-directive. For example:
966///
967///    using namespace std;
968///
969// NB: UsingDirectiveDecl should be Decl not NamedDecl, but we provide
970// artificial name, for all using-directives in order to store
971// them in DeclContext effectively.
972class UsingDirectiveDecl : public NamedDecl {
973
974  /// SourceLocation - Location of 'namespace' token.
975  SourceLocation NamespaceLoc;
976
977  /// \brief The source range that covers the nested-name-specifier
978  /// preceding the namespace name.
979  SourceRange QualifierRange;
980
981  /// \brief The nested-name-specifier that precedes the namespace
982  /// name, if any.
983  NestedNameSpecifier *Qualifier;
984
985  /// IdentLoc - Location of nominated namespace-name identifier.
986  // FIXME: We don't store location of scope specifier.
987  SourceLocation IdentLoc;
988
989  /// NominatedNamespace - Namespace nominated by using-directive.
990  NamespaceDecl *NominatedNamespace;
991
992  /// Enclosing context containing both using-directive and nomintated
993  /// namespace.
994  DeclContext *CommonAncestor;
995
996  /// getUsingDirectiveName - Returns special DeclarationName used by
997  /// using-directives. This is only used by DeclContext for storing
998  /// UsingDirectiveDecls in its lookup structure.
999  static DeclarationName getName() {
1000    return DeclarationName::getUsingDirectiveName();
1001  }
1002
1003  UsingDirectiveDecl(DeclContext *DC, SourceLocation L,
1004                     SourceLocation NamespcLoc,
1005                     SourceRange QualifierRange,
1006                     NestedNameSpecifier *Qualifier,
1007                     SourceLocation IdentLoc,
1008                     NamespaceDecl *Nominated,
1009                     DeclContext *CommonAncestor)
1010    : NamedDecl(Decl::UsingDirective, DC, L, getName()),
1011      NamespaceLoc(NamespcLoc), QualifierRange(QualifierRange),
1012      Qualifier(Qualifier), IdentLoc(IdentLoc),
1013      NominatedNamespace(Nominated? Nominated->getOriginalNamespace() : 0),
1014      CommonAncestor(CommonAncestor) {
1015  }
1016
1017public:
1018  /// \brief Retrieve the source range of the nested-name-specifier
1019  /// that qualifiers the namespace name.
1020  SourceRange getQualifierRange() const { return QualifierRange; }
1021
1022  /// \brief Retrieve the nested-name-specifier that qualifies the
1023  /// name of the namespace.
1024  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1025
1026  /// getNominatedNamespace - Returns namespace nominated by using-directive.
1027  NamespaceDecl *getNominatedNamespace() { return NominatedNamespace; }
1028
1029  const NamespaceDecl *getNominatedNamespace() const {
1030    return const_cast<UsingDirectiveDecl*>(this)->getNominatedNamespace();
1031  }
1032
1033  /// getCommonAncestor - returns common ancestor context of using-directive,
1034  /// and nominated by it namespace.
1035  DeclContext *getCommonAncestor() { return CommonAncestor; }
1036  const DeclContext *getCommonAncestor() const { return CommonAncestor; }
1037
1038  /// getNamespaceKeyLocation - Returns location of namespace keyword.
1039  SourceLocation getNamespaceKeyLocation() const { return NamespaceLoc; }
1040
1041  /// getIdentLocation - Returns location of identifier.
1042  SourceLocation getIdentLocation() const { return IdentLoc; }
1043
1044  static UsingDirectiveDecl *Create(ASTContext &C, DeclContext *DC,
1045                                    SourceLocation L,
1046                                    SourceLocation NamespaceLoc,
1047                                    SourceRange QualifierRange,
1048                                    NestedNameSpecifier *Qualifier,
1049                                    SourceLocation IdentLoc,
1050                                    NamespaceDecl *Nominated,
1051                                    DeclContext *CommonAncestor);
1052
1053  static bool classof(const Decl *D) {
1054    return D->getKind() == Decl::UsingDirective;
1055  }
1056  static bool classof(const UsingDirectiveDecl *D) { return true; }
1057
1058  // Friend for getUsingDirectiveName.
1059  friend class DeclContext;
1060};
1061
1062/// NamespaceAliasDecl - Represents a C++ namespace alias. For example:
1063///
1064/// @code
1065/// namespace Foo = Bar;
1066/// @endcode
1067class NamespaceAliasDecl : public NamedDecl {
1068  SourceLocation AliasLoc;
1069
1070  /// \brief The source range that covers the nested-name-specifier
1071  /// preceding the namespace name.
1072  SourceRange QualifierRange;
1073
1074  /// \brief The nested-name-specifier that precedes the namespace
1075  /// name, if any.
1076  NestedNameSpecifier *Qualifier;
1077
1078  /// IdentLoc - Location of namespace identifier.
1079  SourceLocation IdentLoc;
1080
1081  /// Namespace - The Decl that this alias points to. Can either be a
1082  /// NamespaceDecl or a NamespaceAliasDecl.
1083  NamedDecl *Namespace;
1084
1085  NamespaceAliasDecl(DeclContext *DC, SourceLocation L,
1086                     SourceLocation AliasLoc, IdentifierInfo *Alias,
1087                     SourceRange QualifierRange,
1088                     NestedNameSpecifier *Qualifier,
1089                     SourceLocation IdentLoc, NamedDecl *Namespace)
1090    : NamedDecl(Decl::NamespaceAlias, DC, L, Alias), AliasLoc(AliasLoc),
1091      QualifierRange(QualifierRange), Qualifier(Qualifier),
1092      IdentLoc(IdentLoc), Namespace(Namespace) { }
1093
1094public:
1095  /// \brief Retrieve the source range of the nested-name-specifier
1096  /// that qualifiers the namespace name.
1097  SourceRange getQualifierRange() const { return QualifierRange; }
1098
1099  /// \brief Retrieve the nested-name-specifier that qualifies the
1100  /// name of the namespace.
1101  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1102
1103  NamespaceDecl *getNamespace() {
1104    if (NamespaceAliasDecl *AD = dyn_cast<NamespaceAliasDecl>(Namespace))
1105      return AD->getNamespace();
1106
1107    return cast<NamespaceDecl>(Namespace);
1108  }
1109
1110  const NamespaceDecl *getNamespace() const {
1111    return const_cast<NamespaceAliasDecl*>(this)->getNamespace();
1112  }
1113
1114  /// \brief Retrieve the namespace that this alias refers to, which
1115  /// may either be a NamespaceDecl or a NamespaceAliasDecl.
1116  NamedDecl *getAliasedNamespace() const { return Namespace; }
1117
1118  static NamespaceAliasDecl *Create(ASTContext &C, DeclContext *DC,
1119                                    SourceLocation L, SourceLocation AliasLoc,
1120                                    IdentifierInfo *Alias,
1121                                    SourceRange QualifierRange,
1122                                    NestedNameSpecifier *Qualifier,
1123                                    SourceLocation IdentLoc,
1124                                    NamedDecl *Namespace);
1125
1126  static bool classof(const Decl *D) {
1127    return D->getKind() == Decl::NamespaceAlias;
1128  }
1129  static bool classof(const NamespaceAliasDecl *D) { return true; }
1130};
1131
1132/// UsingDecl - Represents a C++ using-declaration. For example:
1133///    using someNameSpace::someIdentifier;
1134class UsingDecl : public NamedDecl {
1135
1136  /// \brief The source range that covers the nested-name-specifier
1137  /// preceding the declaration name.
1138  SourceRange NestedNameRange;
1139  /// \brief The source location of the target declaration name.
1140  SourceLocation TargetNameLocation;
1141  /// \brief The source location of the "using" location itself.
1142  SourceLocation UsingLocation;
1143  /// \brief Target declaration.
1144  NamedDecl* TargetDecl;
1145  /// \brief Target declaration.
1146  NestedNameSpecifier* TargetNestedNameDecl;
1147
1148  // Had 'typename' keyword.
1149  bool IsTypeName;
1150
1151  UsingDecl(DeclContext *DC, SourceLocation L, SourceRange NNR,
1152            SourceLocation TargetNL, SourceLocation UL, NamedDecl* Target,
1153            NestedNameSpecifier* TargetNNS, bool IsTypeNameArg)
1154    : NamedDecl(Decl::Using, DC, L, Target->getDeclName()),
1155      NestedNameRange(NNR), TargetNameLocation(TargetNL),
1156      UsingLocation(UL), TargetDecl(Target),
1157      TargetNestedNameDecl(TargetNNS), IsTypeName(IsTypeNameArg) {
1158    this->IdentifierNamespace = TargetDecl->getIdentifierNamespace();
1159  }
1160
1161public:
1162  /// \brief Returns the source range that covers the nested-name-specifier
1163  /// preceding the namespace name.
1164  SourceRange getNestedNameRange() { return NestedNameRange; }
1165
1166  /// \brief Returns the source location of the target declaration name.
1167  SourceLocation getTargetNameLocation() { return TargetNameLocation; }
1168
1169  /// \brief Returns the source location of the "using" location itself.
1170  SourceLocation getUsingLocation() { return UsingLocation; }
1171
1172  /// \brief getTargetDecl - Returns target specified by using-decl.
1173  NamedDecl *getTargetDecl() { return TargetDecl; }
1174  const NamedDecl *getTargetDecl() const { return TargetDecl; }
1175
1176  /// \brief Get target nested name declaration.
1177  NestedNameSpecifier* getTargetNestedNameDecl() {
1178    return TargetNestedNameDecl;
1179  }
1180
1181  /// isTypeName - Return true if using decl had 'typename'.
1182  bool isTypeName() const { return IsTypeName; }
1183
1184  static UsingDecl *Create(ASTContext &C, DeclContext *DC,
1185      SourceLocation L, SourceRange NNR, SourceLocation TargetNL,
1186      SourceLocation UL, NamedDecl* Target,
1187      NestedNameSpecifier* TargetNNS, bool IsTypeNameArg);
1188
1189  static bool classof(const Decl *D) {
1190    return D->getKind() == Decl::Using;
1191  }
1192  static bool classof(const UsingDecl *D) { return true; }
1193};
1194
1195/// StaticAssertDecl - Represents a C++0x static_assert declaration.
1196class StaticAssertDecl : public Decl {
1197  Expr *AssertExpr;
1198  StringLiteral *Message;
1199
1200  StaticAssertDecl(DeclContext *DC, SourceLocation L,
1201                   Expr *assertexpr, StringLiteral *message)
1202  : Decl(StaticAssert, DC, L), AssertExpr(assertexpr), Message(message) { }
1203
1204public:
1205  static StaticAssertDecl *Create(ASTContext &C, DeclContext *DC,
1206                                  SourceLocation L, Expr *AssertExpr,
1207                                  StringLiteral *Message);
1208
1209  Expr *getAssertExpr() { return AssertExpr; }
1210  const Expr *getAssertExpr() const { return AssertExpr; }
1211
1212  StringLiteral *getMessage() { return Message; }
1213  const StringLiteral *getMessage() const { return Message; }
1214
1215  virtual ~StaticAssertDecl();
1216  virtual void Destroy(ASTContext& C);
1217
1218  static bool classof(const Decl *D) {
1219    return D->getKind() == Decl::StaticAssert;
1220  }
1221  static bool classof(StaticAssertDecl *D) { return true; }
1222};
1223
1224/// Insertion operator for diagnostics.  This allows sending AccessSpecifier's
1225/// into a diagnostic with <<.
1226const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1227                                    AccessSpecifier AS);
1228
1229} // end namespace clang
1230
1231#endif
1232