DeclCXX.h revision e8174bc483615e79614d9284a50ac94831e8b7c6
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/Expr.h"
18#include "clang/AST/Decl.h"
19#include "llvm/ADT/SmallVector.h"
20#include "llvm/ADT/SmallPtrSet.h"
21
22namespace clang {
23
24class ClassTemplateDecl;
25class ClassTemplateSpecializationDecl;
26class CXXBasePath;
27class CXXBasePaths;
28class CXXConstructorDecl;
29class CXXConversionDecl;
30class CXXDestructorDecl;
31class CXXMethodDecl;
32class CXXRecordDecl;
33class CXXMemberLookupCriteria;
34
35/// \brief Represents any kind of function declaration, whether it is a
36/// concrete function or a function template.
37class AnyFunctionDecl {
38  NamedDecl *Function;
39
40  AnyFunctionDecl(NamedDecl *ND) : Function(ND) { }
41
42public:
43  AnyFunctionDecl(FunctionDecl *FD) : Function(FD) { }
44  AnyFunctionDecl(FunctionTemplateDecl *FTD);
45
46  /// \brief Implicily converts any function or function template into a
47  /// named declaration.
48  operator NamedDecl *() const { return Function; }
49
50  /// \brief Retrieve the underlying function or function template.
51  NamedDecl *get() const { return Function; }
52
53  static AnyFunctionDecl getFromNamedDecl(NamedDecl *ND) {
54    return AnyFunctionDecl(ND);
55  }
56};
57
58} // end namespace clang
59
60namespace llvm {
61  /// Implement simplify_type for AnyFunctionDecl, so that we can dyn_cast from
62  /// AnyFunctionDecl to any function or function template declaration.
63  template<> struct simplify_type<const ::clang::AnyFunctionDecl> {
64    typedef ::clang::NamedDecl* SimpleType;
65    static SimpleType getSimplifiedValue(const ::clang::AnyFunctionDecl &Val) {
66      return Val;
67    }
68  };
69  template<> struct simplify_type< ::clang::AnyFunctionDecl>
70  : public simplify_type<const ::clang::AnyFunctionDecl> {};
71
72  // Provide PointerLikeTypeTraits for non-cvr pointers.
73  template<>
74  class PointerLikeTypeTraits< ::clang::AnyFunctionDecl> {
75  public:
76    static inline void *getAsVoidPointer(::clang::AnyFunctionDecl F) {
77      return F.get();
78    }
79    static inline ::clang::AnyFunctionDecl getFromVoidPointer(void *P) {
80      return ::clang::AnyFunctionDecl::getFromNamedDecl(
81                                      static_cast< ::clang::NamedDecl*>(P));
82    }
83
84    enum { NumLowBitsAvailable = 2 };
85  };
86
87} // end namespace llvm
88
89namespace clang {
90
91/// CXXBaseSpecifier - A base class of a C++ class.
92///
93/// Each CXXBaseSpecifier represents a single, direct base class (or
94/// struct) of a C++ class (or struct). It specifies the type of that
95/// base class, whether it is a virtual or non-virtual base, and what
96/// level of access (public, protected, private) is used for the
97/// derivation. For example:
98///
99/// @code
100///   class A { };
101///   class B { };
102///   class C : public virtual A, protected B { };
103/// @endcode
104///
105/// In this code, C will have two CXXBaseSpecifiers, one for "public
106/// virtual A" and the other for "protected B".
107class CXXBaseSpecifier {
108  /// Range - The source code range that covers the full base
109  /// specifier, including the "virtual" (if present) and access
110  /// specifier (if present).
111  SourceRange Range;
112
113  /// Virtual - Whether this is a virtual base class or not.
114  bool Virtual : 1;
115
116  /// BaseOfClass - Whether this is the base of a class (true) or of a
117  /// struct (false). This determines the mapping from the access
118  /// specifier as written in the source code to the access specifier
119  /// used for semantic analysis.
120  bool BaseOfClass : 1;
121
122  /// Access - Access specifier as written in the source code (which
123  /// may be AS_none). The actual type of data stored here is an
124  /// AccessSpecifier, but we use "unsigned" here to work around a
125  /// VC++ bug.
126  unsigned Access : 2;
127
128  /// BaseType - The type of the base class. This will be a class or
129  /// struct (or a typedef of such).
130  QualType BaseType;
131
132public:
133  CXXBaseSpecifier() { }
134
135  CXXBaseSpecifier(SourceRange R, bool V, bool BC, AccessSpecifier A, QualType T)
136    : Range(R), Virtual(V), BaseOfClass(BC), Access(A), BaseType(T) { }
137
138  /// getSourceRange - Retrieves the source range that contains the
139  /// entire base specifier.
140  SourceRange getSourceRange() const { return Range; }
141
142  /// isVirtual - Determines whether the base class is a virtual base
143  /// class (or not).
144  bool isVirtual() const { return Virtual; }
145
146  /// getAccessSpecifier - Returns the access specifier for this base
147  /// specifier. This is the actual base specifier as used for
148  /// semantic analysis, so the result can never be AS_none. To
149  /// retrieve the access specifier as written in the source code, use
150  /// getAccessSpecifierAsWritten().
151  AccessSpecifier getAccessSpecifier() const {
152    if ((AccessSpecifier)Access == AS_none)
153      return BaseOfClass? AS_private : AS_public;
154    else
155      return (AccessSpecifier)Access;
156  }
157
158  /// getAccessSpecifierAsWritten - Retrieves the access specifier as
159  /// written in the source code (which may mean that no access
160  /// specifier was explicitly written). Use getAccessSpecifier() to
161  /// retrieve the access specifier for use in semantic analysis.
162  AccessSpecifier getAccessSpecifierAsWritten() const {
163    return (AccessSpecifier)Access;
164  }
165
166  /// getType - Retrieves the type of the base class. This type will
167  /// always be an unqualified class type.
168  QualType getType() const { return BaseType; }
169};
170
171/// CXXRecordDecl - Represents a C++ struct/union/class.
172/// FIXME: This class will disappear once we've properly taught RecordDecl
173/// to deal with C++-specific things.
174class CXXRecordDecl : public RecordDecl {
175  /// UserDeclaredConstructor - True when this class has a
176  /// user-declared constructor.
177  bool UserDeclaredConstructor : 1;
178
179  /// UserDeclaredCopyConstructor - True when this class has a
180  /// user-declared copy constructor.
181  bool UserDeclaredCopyConstructor : 1;
182
183  /// UserDeclaredCopyAssignment - True when this class has a
184  /// user-declared copy assignment operator.
185  bool UserDeclaredCopyAssignment : 1;
186
187  /// UserDeclaredDestructor - True when this class has a
188  /// user-declared destructor.
189  bool UserDeclaredDestructor : 1;
190
191  /// Aggregate - True when this class is an aggregate.
192  bool Aggregate : 1;
193
194  /// PlainOldData - True when this class is a POD-type.
195  bool PlainOldData : 1;
196
197  /// Empty - true when this class is empty for traits purposes, i.e. has no
198  /// data members other than 0-width bit-fields, has no virtual function/base,
199  /// and doesn't inherit from a non-empty class. Doesn't take union-ness into
200  /// account.
201  bool Empty : 1;
202
203  /// Polymorphic - True when this class is polymorphic, i.e. has at least one
204  /// virtual member or derives from a polymorphic class.
205  bool Polymorphic : 1;
206
207  /// Abstract - True when this class is abstract, i.e. has at least one
208  /// pure virtual function, (that can come from a base class).
209  bool Abstract : 1;
210
211  /// HasTrivialConstructor - True when this class has a trivial constructor.
212  ///
213  /// C++ [class.ctor]p5.  A constructor is trivial if it is an
214  /// implicitly-declared default constructor and if:
215  /// * its class has no virtual functions and no virtual base classes, and
216  /// * all the direct base classes of its class have trivial constructors, and
217  /// * for all the nonstatic data members of its class that are of class type
218  ///   (or array thereof), each such class has a trivial constructor.
219  bool HasTrivialConstructor : 1;
220
221  /// HasTrivialCopyConstructor - True when this class has a trivial copy
222  /// constructor.
223  ///
224  /// C++ [class.copy]p6.  A copy constructor for class X is trivial
225  /// if it is implicitly declared and if
226  /// * class X has no virtual functions and no virtual base classes, and
227  /// * each direct base class of X has a trivial copy constructor, and
228  /// * for all the nonstatic data members of X that are of class type (or
229  ///   array thereof), each such class type has a trivial copy constructor;
230  /// otherwise the copy constructor is non-trivial.
231  bool HasTrivialCopyConstructor : 1;
232
233  /// HasTrivialCopyAssignment - True when this class has a trivial copy
234  /// assignment operator.
235  ///
236  /// C++ [class.copy]p11.  A copy assignment operator for class X is
237  /// trivial if it is implicitly declared and if
238  /// * class X has no virtual functions and no virtual base classes, and
239  /// * each direct base class of X has a trivial copy assignment operator, and
240  /// * for all the nonstatic data members of X that are of class type (or
241  ///   array thereof), each such class type has a trivial copy assignment
242  ///   operator;
243  /// otherwise the copy assignment operator is non-trivial.
244  bool HasTrivialCopyAssignment : 1;
245
246  /// HasTrivialDestructor - True when this class has a trivial destructor.
247  ///
248  /// C++ [class.dtor]p3.  A destructor is trivial if it is an
249  /// implicitly-declared destructor and if:
250  /// * all of the direct base classes of its class have trivial destructors
251  ///   and
252  /// * for all of the non-static data members of its class that are of class
253  ///   type (or array thereof), each such class has a trivial destructor.
254  bool HasTrivialDestructor : 1;
255
256  /// ComputedVisibleConversions - True when visible conversion functions are
257  /// already computed and are available.
258  bool ComputedVisibleConversions : 1;
259
260  /// Bases - Base classes of this class.
261  /// FIXME: This is wasted space for a union.
262  CXXBaseSpecifier *Bases;
263
264  /// NumBases - The number of base class specifiers in Bases.
265  unsigned NumBases;
266
267  /// VBases - direct and indirect virtual base classes of this class.
268  CXXBaseSpecifier *VBases;
269
270  /// NumVBases - The number of virtual base class specifiers in VBases.
271  unsigned NumVBases;
272
273  /// Conversions - Overload set containing the conversion functions
274  /// of this C++ class (but not its inherited conversion
275  /// functions). Each of the entries in this overload set is a
276  /// CXXConversionDecl.
277  UnresolvedSet Conversions;
278
279  /// VisibleConversions - Overload set containing the conversion functions
280  /// of this C++ class and all those inherited conversion functions that
281  /// are visible in this class. Each of the entries in this overload set is
282  /// a CXXConversionDecl or a FunctionTemplateDecl.
283  UnresolvedSet VisibleConversions;
284
285  /// \brief The template or declaration that this declaration
286  /// describes or was instantiated from, respectively.
287  ///
288  /// For non-templates, this value will be NULL. For record
289  /// declarations that describe a class template, this will be a
290  /// pointer to a ClassTemplateDecl. For member
291  /// classes of class template specializations, this will be the
292  /// MemberSpecializationInfo referring to the member class that was
293  /// instantiated or specialized.
294  llvm::PointerUnion<ClassTemplateDecl*, MemberSpecializationInfo*>
295    TemplateOrInstantiation;
296
297  void getNestedVisibleConversionFunctions(CXXRecordDecl *RD,
298          const llvm::SmallPtrSet<CanQualType, 8> &TopConversionsTypeSet,
299          const llvm::SmallPtrSet<CanQualType, 8> &HiddenConversionTypes);
300  void collectConversionFunctions(
301    llvm::SmallPtrSet<CanQualType, 8>& ConversionsTypeSet) const;
302
303protected:
304  CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC,
305                SourceLocation L, IdentifierInfo *Id,
306                CXXRecordDecl *PrevDecl,
307                SourceLocation TKL = SourceLocation());
308
309  ~CXXRecordDecl();
310
311public:
312  /// base_class_iterator - Iterator that traverses the base classes
313  /// of a class.
314  typedef CXXBaseSpecifier*       base_class_iterator;
315
316  /// base_class_const_iterator - Iterator that traverses the base
317  /// classes of a class.
318  typedef const CXXBaseSpecifier* base_class_const_iterator;
319
320  /// reverse_base_class_iterator = Iterator that traverses the base classes
321  /// of a class in reverse order.
322  typedef std::reverse_iterator<base_class_iterator>
323    reverse_base_class_iterator;
324
325  /// reverse_base_class_iterator = Iterator that traverses the base classes
326  /// of a class in reverse order.
327  typedef std::reverse_iterator<base_class_const_iterator>
328    reverse_base_class_const_iterator;
329
330  virtual CXXRecordDecl *getCanonicalDecl() {
331    return cast<CXXRecordDecl>(RecordDecl::getCanonicalDecl());
332  }
333  virtual const CXXRecordDecl *getCanonicalDecl() const {
334    return cast<CXXRecordDecl>(RecordDecl::getCanonicalDecl());
335  }
336
337  static CXXRecordDecl *Create(ASTContext &C, TagKind TK, DeclContext *DC,
338                               SourceLocation L, IdentifierInfo *Id,
339                               SourceLocation TKL = SourceLocation(),
340                               CXXRecordDecl* PrevDecl=0,
341                               bool DelayTypeCreation = false);
342
343  virtual void Destroy(ASTContext& C);
344
345  bool isDynamicClass() const {
346    return Polymorphic || NumVBases != 0;
347  }
348
349  /// setBases - Sets the base classes of this struct or class.
350  void setBases(ASTContext &C,
351                CXXBaseSpecifier const * const *Bases, unsigned NumBases);
352
353  /// getNumBases - Retrieves the number of base classes of this
354  /// class.
355  unsigned getNumBases() const { return NumBases; }
356
357  base_class_iterator       bases_begin()       { return Bases; }
358  base_class_const_iterator bases_begin() const { return Bases; }
359  base_class_iterator       bases_end()         { return Bases + NumBases; }
360  base_class_const_iterator bases_end()   const { return Bases + NumBases; }
361  reverse_base_class_iterator       bases_rbegin() {
362    return reverse_base_class_iterator(bases_end());
363  }
364  reverse_base_class_const_iterator bases_rbegin() const {
365    return reverse_base_class_const_iterator(bases_end());
366  }
367  reverse_base_class_iterator bases_rend() {
368    return reverse_base_class_iterator(bases_begin());
369  }
370  reverse_base_class_const_iterator bases_rend() const {
371    return reverse_base_class_const_iterator(bases_begin());
372  }
373
374  /// getNumVBases - Retrieves the number of virtual base classes of this
375  /// class.
376  unsigned getNumVBases() const { return NumVBases; }
377
378  base_class_iterator       vbases_begin()       { return VBases; }
379  base_class_const_iterator vbases_begin() const { return VBases; }
380  base_class_iterator       vbases_end()         { return VBases + NumVBases; }
381  base_class_const_iterator vbases_end()   const { return VBases + NumVBases; }
382  reverse_base_class_iterator vbases_rbegin() {
383    return reverse_base_class_iterator(vbases_end());
384  }
385  reverse_base_class_const_iterator vbases_rbegin() const {
386    return reverse_base_class_const_iterator(vbases_end());
387  }
388  reverse_base_class_iterator vbases_rend() {
389    return reverse_base_class_iterator(vbases_begin());
390  }
391  reverse_base_class_const_iterator vbases_rend() const {
392    return reverse_base_class_const_iterator(vbases_begin());
393 }
394
395  /// Iterator access to method members.  The method iterator visits
396  /// all method members of the class, including non-instance methods,
397  /// special methods, etc.
398  typedef specific_decl_iterator<CXXMethodDecl> method_iterator;
399
400  /// method_begin - Method begin iterator.  Iterates in the order the methods
401  /// were declared.
402  method_iterator method_begin() const {
403    return method_iterator(decls_begin());
404  }
405  /// method_end - Method end iterator.
406  method_iterator method_end() const {
407    return method_iterator(decls_end());
408  }
409
410  /// Iterator access to constructor members.
411  typedef specific_decl_iterator<CXXConstructorDecl> ctor_iterator;
412
413  ctor_iterator ctor_begin() const {
414    return ctor_iterator(decls_begin());
415  }
416  ctor_iterator ctor_end() const {
417    return ctor_iterator(decls_end());
418  }
419
420  /// hasConstCopyConstructor - Determines whether this class has a
421  /// copy constructor that accepts a const-qualified argument.
422  bool hasConstCopyConstructor(ASTContext &Context) const;
423
424  /// getCopyConstructor - Returns the copy constructor for this class
425  CXXConstructorDecl *getCopyConstructor(ASTContext &Context,
426                                         unsigned TypeQuals) const;
427
428  /// hasConstCopyAssignment - Determines whether this class has a
429  /// copy assignment operator that accepts a const-qualified argument.
430  /// It returns its decl in MD if found.
431  bool hasConstCopyAssignment(ASTContext &Context,
432                              const CXXMethodDecl *&MD) const;
433
434  /// addedConstructor - Notify the class that another constructor has
435  /// been added. This routine helps maintain information about the
436  /// class based on which constructors have been added.
437  void addedConstructor(ASTContext &Context, CXXConstructorDecl *ConDecl);
438
439  /// hasUserDeclaredConstructor - Whether this class has any
440  /// user-declared constructors. When true, a default constructor
441  /// will not be implicitly declared.
442  bool hasUserDeclaredConstructor() const {
443    assert((isDefinition() ||
444            cast<RecordType>(getTypeForDecl())->isBeingDefined()) &&
445           "Incomplete record decl!");
446    return UserDeclaredConstructor;
447  }
448
449  /// hasUserDeclaredCopyConstructor - Whether this class has a
450  /// user-declared copy constructor. When false, a copy constructor
451  /// will be implicitly declared.
452  bool hasUserDeclaredCopyConstructor() const {
453    return UserDeclaredCopyConstructor;
454  }
455
456  /// addedAssignmentOperator - Notify the class that another assignment
457  /// operator has been added. This routine helps maintain information about the
458   /// class based on which operators have been added.
459  void addedAssignmentOperator(ASTContext &Context, CXXMethodDecl *OpDecl);
460
461  /// hasUserDeclaredCopyAssignment - Whether this class has a
462  /// user-declared copy assignment operator. When false, a copy
463  /// assigment operator will be implicitly declared.
464  bool hasUserDeclaredCopyAssignment() const {
465    return UserDeclaredCopyAssignment;
466  }
467
468  /// hasUserDeclaredDestructor - Whether this class has a
469  /// user-declared destructor. When false, a destructor will be
470  /// implicitly declared.
471  bool hasUserDeclaredDestructor() const { return UserDeclaredDestructor; }
472
473  /// setUserDeclaredDestructor - Set whether this class has a
474  /// user-declared destructor. If not set by the time the class is
475  /// fully defined, a destructor will be implicitly declared.
476  void setUserDeclaredDestructor(bool UCD) {
477    UserDeclaredDestructor = UCD;
478  }
479
480  /// getConversions - Retrieve the overload set containing all of the
481  /// conversion functions in this class.
482  UnresolvedSet *getConversionFunctions() {
483    assert((this->isDefinition() ||
484            cast<RecordType>(getTypeForDecl())->isBeingDefined()) &&
485           "getConversionFunctions() called on incomplete type");
486    return &Conversions;
487  }
488  const UnresolvedSet *getConversionFunctions() const {
489    assert((this->isDefinition() ||
490            cast<RecordType>(getTypeForDecl())->isBeingDefined()) &&
491           "getConversionFunctions() called on incomplete type");
492    return &Conversions;
493  }
494
495  typedef UnresolvedSet::iterator conversion_iterator;
496  conversion_iterator conversion_begin() const { return Conversions.begin(); }
497  conversion_iterator conversion_end() const { return Conversions.end(); }
498
499  /// Replaces a conversion function with a new declaration.
500  ///
501  /// Returns true if the old conversion was found.
502  bool replaceConversion(const NamedDecl* Old, NamedDecl *New) {
503    return Conversions.replace(Old, New);
504  }
505
506  /// getVisibleConversionFunctions - get all conversion functions visible
507  /// in current class; including conversion function templates.
508  const UnresolvedSet *getVisibleConversionFunctions();
509
510  /// addVisibleConversionFunction - Add a new conversion function to the
511  /// list of visible conversion functions.
512  void addVisibleConversionFunction(CXXConversionDecl *ConvDecl);
513
514  /// \brief Add a new conversion function template to the list of visible
515  /// conversion functions.
516  void addVisibleConversionFunction(FunctionTemplateDecl *ConvDecl);
517
518  /// addConversionFunction - Add a new conversion function to the
519  /// list of conversion functions.
520  void addConversionFunction(CXXConversionDecl *ConvDecl);
521
522  /// \brief Add a new conversion function template to the list of conversion
523  /// functions.
524  void addConversionFunction(FunctionTemplateDecl *ConvDecl);
525
526  /// isAggregate - Whether this class is an aggregate (C++
527  /// [dcl.init.aggr]), which is a class with no user-declared
528  /// constructors, no private or protected non-static data members,
529  /// no base classes, and no virtual functions (C++ [dcl.init.aggr]p1).
530  bool isAggregate() const { return Aggregate; }
531
532  /// setAggregate - Set whether this class is an aggregate (C++
533  /// [dcl.init.aggr]).
534  void setAggregate(bool Agg) { Aggregate = Agg; }
535
536  /// setMethodAsVirtual - Make input method virtual and set the necesssary
537  /// special function bits and other bits accordingly.
538  void setMethodAsVirtual(FunctionDecl *Method);
539
540  /// isPOD - Whether this class is a POD-type (C++ [class]p4), which is a class
541  /// that is an aggregate that has no non-static non-POD data members, no
542  /// reference data members, no user-defined copy assignment operator and no
543  /// user-defined destructor.
544  bool isPOD() const { return PlainOldData; }
545
546  /// setPOD - Set whether this class is a POD-type (C++ [class]p4).
547  void setPOD(bool POD) { PlainOldData = POD; }
548
549  /// isEmpty - Whether this class is empty (C++0x [meta.unary.prop]), which
550  /// means it has a virtual function, virtual base, data member (other than
551  /// 0-width bit-field) or inherits from a non-empty class. Does NOT include
552  /// a check for union-ness.
553  bool isEmpty() const { return Empty; }
554
555  /// Set whether this class is empty (C++0x [meta.unary.prop])
556  void setEmpty(bool Emp) { Empty = Emp; }
557
558  /// isPolymorphic - Whether this class is polymorphic (C++ [class.virtual]),
559  /// which means that the class contains or inherits a virtual function.
560  bool isPolymorphic() const { return Polymorphic; }
561
562  /// setPolymorphic - Set whether this class is polymorphic (C++
563  /// [class.virtual]).
564  void setPolymorphic(bool Poly) { Polymorphic = Poly; }
565
566  /// isAbstract - Whether this class is abstract (C++ [class.abstract]),
567  /// which means that the class contains or inherits a pure virtual function.
568  bool isAbstract() const { return Abstract; }
569
570  /// setAbstract - Set whether this class is abstract (C++ [class.abstract])
571  void setAbstract(bool Abs) { Abstract = Abs; }
572
573  // hasTrivialConstructor - Whether this class has a trivial constructor
574  // (C++ [class.ctor]p5)
575  bool hasTrivialConstructor() const { return HasTrivialConstructor; }
576
577  // setHasTrivialConstructor - Set whether this class has a trivial constructor
578  // (C++ [class.ctor]p5)
579  void setHasTrivialConstructor(bool TC) { HasTrivialConstructor = TC; }
580
581  // hasTrivialCopyConstructor - Whether this class has a trivial copy
582  // constructor (C++ [class.copy]p6)
583  bool hasTrivialCopyConstructor() const { return HasTrivialCopyConstructor; }
584
585  // setHasTrivialCopyConstructor - Set whether this class has a trivial
586  // copy constructor (C++ [class.copy]p6)
587  void setHasTrivialCopyConstructor(bool TC) { HasTrivialCopyConstructor = TC; }
588
589  // hasTrivialCopyAssignment - Whether this class has a trivial copy
590  // assignment operator (C++ [class.copy]p11)
591  bool hasTrivialCopyAssignment() const { return HasTrivialCopyAssignment; }
592
593  // setHasTrivialCopyAssignment - Set whether this class has a
594  // trivial copy assignment operator (C++ [class.copy]p11)
595  void setHasTrivialCopyAssignment(bool TC) { HasTrivialCopyAssignment = TC; }
596
597  // hasTrivialDestructor - Whether this class has a trivial destructor
598  // (C++ [class.dtor]p3)
599  bool hasTrivialDestructor() const { return HasTrivialDestructor; }
600
601  // setHasTrivialDestructor - Set whether this class has a trivial destructor
602  // (C++ [class.dtor]p3)
603  void setHasTrivialDestructor(bool TC) { HasTrivialDestructor = TC; }
604
605  /// \brief If this record is an instantiation of a member class,
606  /// retrieves the member class from which it was instantiated.
607  ///
608  /// This routine will return non-NULL for (non-templated) member
609  /// classes of class templates. For example, given:
610  ///
611  /// \code
612  /// template<typename T>
613  /// struct X {
614  ///   struct A { };
615  /// };
616  /// \endcode
617  ///
618  /// The declaration for X<int>::A is a (non-templated) CXXRecordDecl
619  /// whose parent is the class template specialization X<int>. For
620  /// this declaration, getInstantiatedFromMemberClass() will return
621  /// the CXXRecordDecl X<T>::A. When a complete definition of
622  /// X<int>::A is required, it will be instantiated from the
623  /// declaration returned by getInstantiatedFromMemberClass().
624  CXXRecordDecl *getInstantiatedFromMemberClass() const;
625
626  /// \brief If this class is an instantiation of a member class of a
627  /// class template specialization, retrieves the member specialization
628  /// information.
629  MemberSpecializationInfo *getMemberSpecializationInfo() const;
630
631  /// \brief Specify that this record is an instantiation of the
632  /// member class RD.
633  void setInstantiationOfMemberClass(CXXRecordDecl *RD,
634                                     TemplateSpecializationKind TSK);
635
636  /// \brief Retrieves the class template that is described by this
637  /// class declaration.
638  ///
639  /// Every class template is represented as a ClassTemplateDecl and a
640  /// CXXRecordDecl. The former contains template properties (such as
641  /// the template parameter lists) while the latter contains the
642  /// actual description of the template's
643  /// contents. ClassTemplateDecl::getTemplatedDecl() retrieves the
644  /// CXXRecordDecl that from a ClassTemplateDecl, while
645  /// getDescribedClassTemplate() retrieves the ClassTemplateDecl from
646  /// a CXXRecordDecl.
647  ClassTemplateDecl *getDescribedClassTemplate() const {
648    return TemplateOrInstantiation.dyn_cast<ClassTemplateDecl*>();
649  }
650
651  void setDescribedClassTemplate(ClassTemplateDecl *Template) {
652    TemplateOrInstantiation = Template;
653  }
654
655  /// \brief Determine whether this particular class is a specialization or
656  /// instantiation of a class template or member class of a class template,
657  /// and how it was instantiated or specialized.
658  TemplateSpecializationKind getTemplateSpecializationKind() const;
659
660  /// \brief Set the kind of specialization or template instantiation this is.
661  void setTemplateSpecializationKind(TemplateSpecializationKind TSK);
662
663  /// getDefaultConstructor - Returns the default constructor for this class
664  CXXConstructorDecl *getDefaultConstructor(ASTContext &Context);
665
666  /// getDestructor - Returns the destructor decl for this class.
667  CXXDestructorDecl *getDestructor(ASTContext &Context);
668
669  /// isLocalClass - If the class is a local class [class.local], returns
670  /// the enclosing function declaration.
671  const FunctionDecl *isLocalClass() const {
672    if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(getDeclContext()))
673      return RD->isLocalClass();
674
675    return dyn_cast<FunctionDecl>(getDeclContext());
676  }
677
678  /// \brief Determine whether this class is derived from the class \p Base.
679  ///
680  /// This routine only determines whether this class is derived from \p Base,
681  /// but does not account for factors that may make a Derived -> Base class
682  /// ill-formed, such as private/protected inheritance or multiple, ambiguous
683  /// base class subobjects.
684  ///
685  /// \param Base the base class we are searching for.
686  ///
687  /// \returns true if this class is derived from Base, false otherwise.
688  bool isDerivedFrom(CXXRecordDecl *Base) const;
689
690  /// \brief Determine whether this class is derived from the type \p Base.
691  ///
692  /// This routine only determines whether this class is derived from \p Base,
693  /// but does not account for factors that may make a Derived -> Base class
694  /// ill-formed, such as private/protected inheritance or multiple, ambiguous
695  /// base class subobjects.
696  ///
697  /// \param Base the base class we are searching for.
698  ///
699  /// \param Paths will contain the paths taken from the current class to the
700  /// given \p Base class.
701  ///
702  /// \returns true if this class is derived from Base, false otherwise.
703  ///
704  /// \todo add a separate paramaeter to configure IsDerivedFrom, rather than
705  /// tangling input and output in \p Paths
706  bool isDerivedFrom(CXXRecordDecl *Base, CXXBasePaths &Paths) const;
707
708  /// \brief Determine whether this class is provably not derived from
709  /// the type \p Base.
710  bool isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const;
711
712  /// \brief Function type used by forallBases() as a callback.
713  ///
714  /// \param Base the definition of the base class
715  ///
716  /// \returns true if this base matched the search criteria
717  typedef bool ForallBasesCallback(const CXXRecordDecl *BaseDefinition,
718                                   void *UserData);
719
720  /// \brief Determines if the given callback holds for all the direct
721  /// or indirect base classes of this type.
722  ///
723  /// The class itself does not count as a base class.  This routine
724  /// returns false if the class has non-computable base classes.
725  ///
726  /// \param AllowShortCircuit if false, forces the callback to be called
727  /// for every base class, even if a dependent or non-matching base was
728  /// found.
729  bool forallBases(ForallBasesCallback *BaseMatches, void *UserData,
730                   bool AllowShortCircuit = true) const;
731
732  /// \brief Function type used by lookupInBases() to determine whether a
733  /// specific base class subobject matches the lookup criteria.
734  ///
735  /// \param Specifier the base-class specifier that describes the inheritance
736  /// from the base class we are trying to match.
737  ///
738  /// \param Path the current path, from the most-derived class down to the
739  /// base named by the \p Specifier.
740  ///
741  /// \param UserData a single pointer to user-specified data, provided to
742  /// lookupInBases().
743  ///
744  /// \returns true if this base matched the search criteria, false otherwise.
745  typedef bool BaseMatchesCallback(const CXXBaseSpecifier *Specifier,
746                                   CXXBasePath &Path,
747                                   void *UserData);
748
749  /// \brief Look for entities within the base classes of this C++ class,
750  /// transitively searching all base class subobjects.
751  ///
752  /// This routine uses the callback function \p BaseMatches to find base
753  /// classes meeting some search criteria, walking all base class subobjects
754  /// and populating the given \p Paths structure with the paths through the
755  /// inheritance hierarchy that resulted in a match. On a successful search,
756  /// the \p Paths structure can be queried to retrieve the matching paths and
757  /// to determine if there were any ambiguities.
758  ///
759  /// \param BaseMatches callback function used to determine whether a given
760  /// base matches the user-defined search criteria.
761  ///
762  /// \param UserData user data pointer that will be provided to \p BaseMatches.
763  ///
764  /// \param Paths used to record the paths from this class to its base class
765  /// subobjects that match the search criteria.
766  ///
767  /// \returns true if there exists any path from this class to a base class
768  /// subobject that matches the search criteria.
769  bool lookupInBases(BaseMatchesCallback *BaseMatches, void *UserData,
770                     CXXBasePaths &Paths) const;
771
772  /// \brief Base-class lookup callback that determines whether the given
773  /// base class specifier refers to a specific class declaration.
774  ///
775  /// This callback can be used with \c lookupInBases() to determine whether
776  /// a given derived class has is a base class subobject of a particular type.
777  /// The user data pointer should refer to the canonical CXXRecordDecl of the
778  /// base class that we are searching for.
779  static bool FindBaseClass(const CXXBaseSpecifier *Specifier,
780                            CXXBasePath &Path, void *BaseRecord);
781
782  /// \brief Base-class lookup callback that determines whether there exists
783  /// a tag with the given name.
784  ///
785  /// This callback can be used with \c lookupInBases() to find tag members
786  /// of the given name within a C++ class hierarchy. The user data pointer
787  /// is an opaque \c DeclarationName pointer.
788  static bool FindTagMember(const CXXBaseSpecifier *Specifier,
789                            CXXBasePath &Path, void *Name);
790
791  /// \brief Base-class lookup callback that determines whether there exists
792  /// a member with the given name.
793  ///
794  /// This callback can be used with \c lookupInBases() to find members
795  /// of the given name within a C++ class hierarchy. The user data pointer
796  /// is an opaque \c DeclarationName pointer.
797  static bool FindOrdinaryMember(const CXXBaseSpecifier *Specifier,
798                                 CXXBasePath &Path, void *Name);
799
800  /// \brief Base-class lookup callback that determines whether there exists
801  /// a member with the given name that can be used in a nested-name-specifier.
802  ///
803  /// This callback can be used with \c lookupInBases() to find membes of
804  /// the given name within a C++ class hierarchy that can occur within
805  /// nested-name-specifiers.
806  static bool FindNestedNameSpecifierMember(const CXXBaseSpecifier *Specifier,
807                                            CXXBasePath &Path,
808                                            void *UserData);
809
810  /// viewInheritance - Renders and displays an inheritance diagram
811  /// for this C++ class and all of its base classes (transitively) using
812  /// GraphViz.
813  void viewInheritance(ASTContext& Context) const;
814
815  static bool classof(const Decl *D) {
816    return D->getKind() == CXXRecord ||
817           D->getKind() == ClassTemplateSpecialization ||
818           D->getKind() == ClassTemplatePartialSpecialization;
819  }
820  static bool classof(const CXXRecordDecl *D) { return true; }
821  static bool classof(const ClassTemplateSpecializationDecl *D) {
822    return true;
823  }
824};
825
826/// CXXMethodDecl - Represents a static or instance method of a
827/// struct/union/class.
828class CXXMethodDecl : public FunctionDecl {
829protected:
830  CXXMethodDecl(Kind DK, CXXRecordDecl *RD, SourceLocation L,
831                DeclarationName N, QualType T, TypeSourceInfo *TInfo,
832                bool isStatic, bool isInline)
833    : FunctionDecl(DK, RD, L, N, T, TInfo, (isStatic ? Static : None),
834                   isInline) {}
835
836public:
837  static CXXMethodDecl *Create(ASTContext &C, CXXRecordDecl *RD,
838                              SourceLocation L, DeclarationName N,
839                              QualType T, TypeSourceInfo *TInfo,
840                              bool isStatic = false,
841                              bool isInline = false);
842
843  bool isStatic() const { return getStorageClass() == Static; }
844  bool isInstance() const { return !isStatic(); }
845
846  bool isVirtual() const {
847    CXXMethodDecl *CD =
848      cast<CXXMethodDecl>(const_cast<CXXMethodDecl*>(this)->getCanonicalDecl());
849
850    if (CD->isVirtualAsWritten())
851      return true;
852
853    return (CD->begin_overridden_methods() != CD->end_overridden_methods());
854  }
855
856  /// \brief Determine whether this is a usual deallocation function
857  /// (C++ [basic.stc.dynamic.deallocation]p2), which is an overloaded
858  /// delete or delete[] operator with a particular signature.
859  bool isUsualDeallocationFunction() const;
860
861  const CXXMethodDecl *getCanonicalDecl() const {
862    return cast<CXXMethodDecl>(FunctionDecl::getCanonicalDecl());
863  }
864  CXXMethodDecl *getCanonicalDecl() {
865    return cast<CXXMethodDecl>(FunctionDecl::getCanonicalDecl());
866  }
867
868  ///
869  void addOverriddenMethod(const CXXMethodDecl *MD);
870
871  typedef const CXXMethodDecl ** method_iterator;
872
873  method_iterator begin_overridden_methods() const;
874  method_iterator end_overridden_methods() const;
875
876  /// getParent - Returns the parent of this method declaration, which
877  /// is the class in which this method is defined.
878  const CXXRecordDecl *getParent() const {
879    return cast<CXXRecordDecl>(FunctionDecl::getParent());
880  }
881
882  /// getParent - Returns the parent of this method declaration, which
883  /// is the class in which this method is defined.
884  CXXRecordDecl *getParent() {
885    return const_cast<CXXRecordDecl *>(
886             cast<CXXRecordDecl>(FunctionDecl::getParent()));
887  }
888
889  /// getThisType - Returns the type of 'this' pointer.
890  /// Should only be called for instance methods.
891  QualType getThisType(ASTContext &C) const;
892
893  unsigned getTypeQualifiers() const {
894    return getType()->getAs<FunctionProtoType>()->getTypeQuals();
895  }
896
897  bool hasInlineBody() const;
898
899  // Implement isa/cast/dyncast/etc.
900  static bool classof(const Decl *D) {
901    return D->getKind() >= CXXMethod && D->getKind() <= CXXConversion;
902  }
903  static bool classof(const CXXMethodDecl *D) { return true; }
904};
905
906/// CXXBaseOrMemberInitializer - Represents a C++ base or member
907/// initializer, which is part of a constructor initializer that
908/// initializes one non-static member variable or one base class. For
909/// example, in the following, both 'A(a)' and 'f(3.14159)' are member
910/// initializers:
911///
912/// @code
913/// class A { };
914/// class B : public A {
915///   float f;
916/// public:
917///   B(A& a) : A(a), f(3.14159) { }
918/// };
919/// @endcode
920class CXXBaseOrMemberInitializer {
921  /// \brief Either the base class name (stored as a TypeSourceInfo*) or the
922  /// field being initialized.
923  llvm::PointerUnion<TypeSourceInfo *, FieldDecl *> BaseOrMember;
924
925  /// \brief The source location for the field name.
926  SourceLocation MemberLocation;
927
928  /// Args - The arguments used to initialize the base or member.
929  Stmt **Args;
930  unsigned NumArgs;
931
932  /// \brief Stores either the constructor to call to initialize this base or
933  /// member (a CXXConstructorDecl pointer), or stores the anonymous union of
934  /// which the initialized value is a member.
935  ///
936  /// When the value is a FieldDecl pointer, 'BaseOrMember' is class's
937  /// anonymous union data member, this field holds the FieldDecl for the
938  /// member of the anonymous union being initialized.
939  /// @code
940  /// struct X {
941  ///   X() : au_i1(123) {}
942  ///   union {
943  ///     int au_i1;
944  ///     float au_f1;
945  ///   };
946  /// };
947  /// @endcode
948  /// In above example, BaseOrMember holds the field decl. for anonymous union
949  /// and AnonUnionMember holds field decl for au_i1.
950  llvm::PointerUnion<CXXConstructorDecl *, FieldDecl *> CtorOrAnonUnion;
951
952  /// LParenLoc - Location of the left paren of the ctor-initializer.
953  SourceLocation LParenLoc;
954
955  /// RParenLoc - Location of the right paren of the ctor-initializer.
956  SourceLocation RParenLoc;
957
958public:
959  /// CXXBaseOrMemberInitializer - Creates a new base-class initializer.
960  explicit
961  CXXBaseOrMemberInitializer(ASTContext &Context,
962                             TypeSourceInfo *TInfo, CXXConstructorDecl *C,
963                             SourceLocation L,
964                             Expr **Args, unsigned NumArgs,
965                             SourceLocation R);
966
967  /// CXXBaseOrMemberInitializer - Creates a new member initializer.
968  explicit
969  CXXBaseOrMemberInitializer(ASTContext &Context,
970                             FieldDecl *Member, SourceLocation MemberLoc,
971                             CXXConstructorDecl *C, SourceLocation L,
972                             Expr **Args, unsigned NumArgs,
973                             SourceLocation R);
974
975  /// \brief Destroy the base or member initializer.
976  void Destroy(ASTContext &Context);
977
978  /// arg_iterator - Iterates through the member initialization
979  /// arguments.
980  typedef ExprIterator arg_iterator;
981
982  /// arg_const_iterator - Iterates through the member initialization
983  /// arguments.
984  typedef ConstExprIterator const_arg_iterator;
985
986  /// isBaseInitializer - Returns true when this initializer is
987  /// initializing a base class.
988  bool isBaseInitializer() const { return BaseOrMember.is<TypeSourceInfo*>(); }
989
990  /// isMemberInitializer - Returns true when this initializer is
991  /// initializing a non-static data member.
992  bool isMemberInitializer() const { return BaseOrMember.is<FieldDecl*>(); }
993
994  /// If this is a base class initializer, returns the type of the
995  /// base class with location information. Otherwise, returns an NULL
996  /// type location.
997  TypeLoc getBaseClassLoc() const;
998
999  /// If this is a base class initializer, returns the type of the base class.
1000  /// Otherwise, returns NULL.
1001  const Type *getBaseClass() const;
1002  Type *getBaseClass();
1003
1004  /// \brief Returns the declarator information for a base class initializer.
1005  TypeSourceInfo *getBaseClassInfo() const {
1006    return BaseOrMember.dyn_cast<TypeSourceInfo *>();
1007  }
1008
1009  /// getMember - If this is a member initializer, returns the
1010  /// declaration of the non-static data member being
1011  /// initialized. Otherwise, returns NULL.
1012  FieldDecl *getMember() {
1013    if (isMemberInitializer())
1014      return BaseOrMember.get<FieldDecl*>();
1015    else
1016      return 0;
1017  }
1018
1019  SourceLocation getMemberLocation() const {
1020    return MemberLocation;
1021  }
1022
1023  void setMember(FieldDecl *Member) {
1024    assert(isMemberInitializer());
1025    BaseOrMember = Member;
1026  }
1027
1028  /// \brief Determine the source location of the initializer.
1029  SourceLocation getSourceLocation() const;
1030
1031  /// \brief Determine the source range covering the entire initializer.
1032  SourceRange getSourceRange() const;
1033
1034  FieldDecl *getAnonUnionMember() const {
1035    return CtorOrAnonUnion.dyn_cast<FieldDecl *>();
1036  }
1037  void setAnonUnionMember(FieldDecl *anonMember) {
1038    CtorOrAnonUnion = anonMember;
1039  }
1040
1041  const CXXConstructorDecl *getConstructor() const {
1042    return CtorOrAnonUnion.dyn_cast<CXXConstructorDecl *>();
1043  }
1044
1045  SourceLocation getLParenLoc() const { return LParenLoc; }
1046  SourceLocation getRParenLoc() const { return RParenLoc; }
1047
1048  /// arg_begin() - Retrieve an iterator to the first initializer argument.
1049  arg_iterator       arg_begin()       { return Args; }
1050  /// arg_begin() - Retrieve an iterator to the first initializer argument.
1051  const_arg_iterator const_arg_begin() const { return Args; }
1052
1053  /// arg_end() - Retrieve an iterator past the last initializer argument.
1054  arg_iterator       arg_end()       { return Args + NumArgs; }
1055  /// arg_end() - Retrieve an iterator past the last initializer argument.
1056  const_arg_iterator const_arg_end() const { return Args + NumArgs; }
1057
1058  /// getNumArgs - Determine the number of arguments used to
1059  /// initialize the member or base.
1060  unsigned getNumArgs() const { return NumArgs; }
1061};
1062
1063/// CXXConstructorDecl - Represents a C++ constructor within a
1064/// class. For example:
1065///
1066/// @code
1067/// class X {
1068/// public:
1069///   explicit X(int); // represented by a CXXConstructorDecl.
1070/// };
1071/// @endcode
1072class CXXConstructorDecl : public CXXMethodDecl {
1073  /// Explicit - Whether this constructor is explicit.
1074  bool Explicit : 1;
1075
1076  /// ImplicitlyDefined - Whether this constructor was implicitly
1077  /// defined by the compiler. When false, the constructor was defined
1078  /// by the user. In C++03, this flag will have the same value as
1079  /// Implicit. In C++0x, however, a constructor that is
1080  /// explicitly defaulted (i.e., defined with " = default") will have
1081  /// @c !Implicit && ImplicitlyDefined.
1082  bool ImplicitlyDefined : 1;
1083
1084  /// Support for base and member initializers.
1085  /// BaseOrMemberInitializers - The arguments used to initialize the base
1086  /// or member.
1087  CXXBaseOrMemberInitializer **BaseOrMemberInitializers;
1088  unsigned NumBaseOrMemberInitializers;
1089
1090  CXXConstructorDecl(CXXRecordDecl *RD, SourceLocation L,
1091                     DeclarationName N, QualType T, TypeSourceInfo *TInfo,
1092                     bool isExplicit, bool isInline, bool isImplicitlyDeclared)
1093    : CXXMethodDecl(CXXConstructor, RD, L, N, T, TInfo, false, isInline),
1094      Explicit(isExplicit), ImplicitlyDefined(false),
1095      BaseOrMemberInitializers(0), NumBaseOrMemberInitializers(0) {
1096    setImplicit(isImplicitlyDeclared);
1097  }
1098  virtual void Destroy(ASTContext& C);
1099
1100public:
1101  static CXXConstructorDecl *Create(ASTContext &C, CXXRecordDecl *RD,
1102                                    SourceLocation L, DeclarationName N,
1103                                    QualType T, TypeSourceInfo *TInfo,
1104                                    bool isExplicit,
1105                                    bool isInline, bool isImplicitlyDeclared);
1106
1107  /// isExplicit - Whether this constructor was marked "explicit" or not.
1108  bool isExplicit() const { return Explicit; }
1109
1110  /// isImplicitlyDefined - Whether this constructor was implicitly
1111  /// defined. If false, then this constructor was defined by the
1112  /// user. This operation can only be invoked if the constructor has
1113  /// already been defined.
1114  bool isImplicitlyDefined(ASTContext &C) const {
1115    assert(isThisDeclarationADefinition() &&
1116           "Can only get the implicit-definition flag once the "
1117           "constructor has been defined");
1118    return ImplicitlyDefined;
1119  }
1120
1121  /// setImplicitlyDefined - Set whether this constructor was
1122  /// implicitly defined or not.
1123  void setImplicitlyDefined(bool ID) {
1124    assert(isThisDeclarationADefinition() &&
1125           "Can only set the implicit-definition flag once the constructor "
1126           "has been defined");
1127    ImplicitlyDefined = ID;
1128  }
1129
1130  /// init_iterator - Iterates through the member/base initializer list.
1131  typedef CXXBaseOrMemberInitializer **init_iterator;
1132
1133  /// init_const_iterator - Iterates through the memberbase initializer list.
1134  typedef CXXBaseOrMemberInitializer * const * init_const_iterator;
1135
1136  /// init_begin() - Retrieve an iterator to the first initializer.
1137  init_iterator       init_begin()       { return BaseOrMemberInitializers; }
1138  /// begin() - Retrieve an iterator to the first initializer.
1139  init_const_iterator init_begin() const { return BaseOrMemberInitializers; }
1140
1141  /// init_end() - Retrieve an iterator past the last initializer.
1142  init_iterator       init_end()       {
1143    return BaseOrMemberInitializers + NumBaseOrMemberInitializers;
1144  }
1145  /// end() - Retrieve an iterator past the last initializer.
1146  init_const_iterator init_end() const {
1147    return BaseOrMemberInitializers + NumBaseOrMemberInitializers;
1148  }
1149
1150  /// getNumArgs - Determine the number of arguments used to
1151  /// initialize the member or base.
1152  unsigned getNumBaseOrMemberInitializers() const {
1153      return NumBaseOrMemberInitializers;
1154  }
1155
1156  void setNumBaseOrMemberInitializers(unsigned numBaseOrMemberInitializers) {
1157    NumBaseOrMemberInitializers = numBaseOrMemberInitializers;
1158  }
1159
1160  void setBaseOrMemberInitializers(CXXBaseOrMemberInitializer ** initializers) {
1161    BaseOrMemberInitializers = initializers;
1162  }
1163  /// isDefaultConstructor - Whether this constructor is a default
1164  /// constructor (C++ [class.ctor]p5), which can be used to
1165  /// default-initialize a class of this type.
1166  bool isDefaultConstructor() const;
1167
1168  /// isCopyConstructor - Whether this constructor is a copy
1169  /// constructor (C++ [class.copy]p2, which can be used to copy the
1170  /// class. @p TypeQuals will be set to the qualifiers on the
1171  /// argument type. For example, @p TypeQuals would be set to @c
1172  /// QualType::Const for the following copy constructor:
1173  ///
1174  /// @code
1175  /// class X {
1176  /// public:
1177  ///   X(const X&);
1178  /// };
1179  /// @endcode
1180  bool isCopyConstructor(ASTContext &Context, unsigned &TypeQuals) const;
1181
1182  /// isCopyConstructor - Whether this constructor is a copy
1183  /// constructor (C++ [class.copy]p2, which can be used to copy the
1184  /// class.
1185  bool isCopyConstructor(ASTContext &Context) const {
1186    unsigned TypeQuals = 0;
1187    return isCopyConstructor(Context, TypeQuals);
1188  }
1189
1190  /// isConvertingConstructor - Whether this constructor is a
1191  /// converting constructor (C++ [class.conv.ctor]), which can be
1192  /// used for user-defined conversions.
1193  bool isConvertingConstructor(bool AllowExplicit) const;
1194
1195  /// \brief Determine whether this is a member template specialization that
1196  /// looks like a copy constructor. Such constructors are never used to copy
1197  /// an object.
1198  bool isCopyConstructorLikeSpecialization() const;
1199
1200  // Implement isa/cast/dyncast/etc.
1201  static bool classof(const Decl *D) {
1202    return D->getKind() == CXXConstructor;
1203  }
1204  static bool classof(const CXXConstructorDecl *D) { return true; }
1205};
1206
1207/// CXXDestructorDecl - Represents a C++ destructor within a
1208/// class. For example:
1209///
1210/// @code
1211/// class X {
1212/// public:
1213///   ~X(); // represented by a CXXDestructorDecl.
1214/// };
1215/// @endcode
1216class CXXDestructorDecl : public CXXMethodDecl {
1217  /// ImplicitlyDefined - Whether this destructor was implicitly
1218  /// defined by the compiler. When false, the destructor was defined
1219  /// by the user. In C++03, this flag will have the same value as
1220  /// Implicit. In C++0x, however, a destructor that is
1221  /// explicitly defaulted (i.e., defined with " = default") will have
1222  /// @c !Implicit && ImplicitlyDefined.
1223  bool ImplicitlyDefined : 1;
1224
1225  FunctionDecl *OperatorDelete;
1226
1227  CXXDestructorDecl(CXXRecordDecl *RD, SourceLocation L,
1228                    DeclarationName N, QualType T,
1229                    bool isInline, bool isImplicitlyDeclared)
1230    : CXXMethodDecl(CXXDestructor, RD, L, N, T, /*TInfo=*/0, false, isInline),
1231      ImplicitlyDefined(false), OperatorDelete(0) {
1232    setImplicit(isImplicitlyDeclared);
1233  }
1234
1235public:
1236  static CXXDestructorDecl *Create(ASTContext &C, CXXRecordDecl *RD,
1237                                   SourceLocation L, DeclarationName N,
1238                                   QualType T, bool isInline,
1239                                   bool isImplicitlyDeclared);
1240
1241  /// isImplicitlyDefined - Whether this destructor was implicitly
1242  /// defined. If false, then this destructor was defined by the
1243  /// user. This operation can only be invoked if the destructor has
1244  /// already been defined.
1245  bool isImplicitlyDefined() const {
1246    assert(isThisDeclarationADefinition() &&
1247           "Can only get the implicit-definition flag once the destructor has been defined");
1248    return ImplicitlyDefined;
1249  }
1250
1251  /// setImplicitlyDefined - Set whether this destructor was
1252  /// implicitly defined or not.
1253  void setImplicitlyDefined(bool ID) {
1254    assert(isThisDeclarationADefinition() &&
1255           "Can only set the implicit-definition flag once the destructor has been defined");
1256    ImplicitlyDefined = ID;
1257  }
1258
1259  void setOperatorDelete(FunctionDecl *OD) { OperatorDelete = OD; }
1260  const FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
1261
1262  // Implement isa/cast/dyncast/etc.
1263  static bool classof(const Decl *D) {
1264    return D->getKind() == CXXDestructor;
1265  }
1266  static bool classof(const CXXDestructorDecl *D) { return true; }
1267};
1268
1269/// CXXConversionDecl - Represents a C++ conversion function within a
1270/// class. For example:
1271///
1272/// @code
1273/// class X {
1274/// public:
1275///   operator bool();
1276/// };
1277/// @endcode
1278class CXXConversionDecl : public CXXMethodDecl {
1279  /// Explicit - Whether this conversion function is marked
1280  /// "explicit", meaning that it can only be applied when the user
1281  /// explicitly wrote a cast. This is a C++0x feature.
1282  bool Explicit : 1;
1283
1284  CXXConversionDecl(CXXRecordDecl *RD, SourceLocation L,
1285                    DeclarationName N, QualType T, TypeSourceInfo *TInfo,
1286                    bool isInline, bool isExplicit)
1287    : CXXMethodDecl(CXXConversion, RD, L, N, T, TInfo, false, isInline),
1288      Explicit(isExplicit) { }
1289
1290public:
1291  static CXXConversionDecl *Create(ASTContext &C, CXXRecordDecl *RD,
1292                                   SourceLocation L, DeclarationName N,
1293                                   QualType T, TypeSourceInfo *TInfo,
1294                                   bool isInline, bool isExplicit);
1295
1296  /// isExplicit - Whether this is an explicit conversion operator
1297  /// (C++0x only). Explicit conversion operators are only considered
1298  /// when the user has explicitly written a cast.
1299  bool isExplicit() const { return Explicit; }
1300
1301  /// getConversionType - Returns the type that this conversion
1302  /// function is converting to.
1303  QualType getConversionType() const {
1304    return getType()->getAs<FunctionType>()->getResultType();
1305  }
1306
1307  // Implement isa/cast/dyncast/etc.
1308  static bool classof(const Decl *D) {
1309    return D->getKind() == CXXConversion;
1310  }
1311  static bool classof(const CXXConversionDecl *D) { return true; }
1312};
1313
1314/// FriendDecl - Represents the declaration of a friend entity,
1315/// which can be a function, a type, or a templated function or type.
1316//  For example:
1317///
1318/// @code
1319/// template <typename T> class A {
1320///   friend int foo(T);
1321///   friend class B;
1322///   friend T; // only in C++0x
1323///   template <typename U> friend class C;
1324///   template <typename U> friend A& operator+=(A&, const U&) { ... }
1325/// };
1326/// @endcode
1327///
1328/// The semantic context of a friend decl is its declaring class.
1329class FriendDecl : public Decl {
1330public:
1331  typedef llvm::PointerUnion<NamedDecl*,Type*> FriendUnion;
1332
1333private:
1334  // The declaration that's a friend of this class.
1335  FriendUnion Friend;
1336
1337  // Location of the 'friend' specifier.
1338  SourceLocation FriendLoc;
1339
1340  FriendDecl(DeclContext *DC, SourceLocation L, FriendUnion Friend,
1341             SourceLocation FriendL)
1342    : Decl(Decl::Friend, DC, L),
1343      Friend(Friend),
1344      FriendLoc(FriendL) {
1345  }
1346
1347public:
1348  static FriendDecl *Create(ASTContext &C, DeclContext *DC,
1349                            SourceLocation L, FriendUnion Friend_,
1350                            SourceLocation FriendL);
1351
1352  /// If this friend declaration names an (untemplated but
1353  /// possibly dependent) type, return the type;  otherwise
1354  /// return null.  This is used only for C++0x's unelaborated
1355  /// friend type declarations.
1356  Type *getFriendType() const {
1357    return Friend.dyn_cast<Type*>();
1358  }
1359
1360  /// If this friend declaration doesn't name an unelaborated
1361  /// type, return the inner declaration.
1362  NamedDecl *getFriendDecl() const {
1363    return Friend.dyn_cast<NamedDecl*>();
1364  }
1365
1366  /// Retrieves the location of the 'friend' keyword.
1367  SourceLocation getFriendLoc() const {
1368    return FriendLoc;
1369  }
1370
1371  // Implement isa/cast/dyncast/etc.
1372  static bool classof(const Decl *D) {
1373    return D->getKind() == Decl::Friend;
1374  }
1375  static bool classof(const FriendDecl *D) { return true; }
1376};
1377
1378/// LinkageSpecDecl - This represents a linkage specification.  For example:
1379///   extern "C" void foo();
1380///
1381class LinkageSpecDecl : public Decl, public DeclContext {
1382public:
1383  /// LanguageIDs - Used to represent the language in a linkage
1384  /// specification.  The values are part of the serialization abi for
1385  /// ASTs and cannot be changed without altering that abi.  To help
1386  /// ensure a stable abi for this, we choose the DW_LANG_ encodings
1387  /// from the dwarf standard.
1388  enum LanguageIDs { lang_c = /* DW_LANG_C */ 0x0002,
1389  lang_cxx = /* DW_LANG_C_plus_plus */ 0x0004 };
1390private:
1391  /// Language - The language for this linkage specification.
1392  LanguageIDs Language;
1393
1394  /// HadBraces - Whether this linkage specification had curly braces or not.
1395  bool HadBraces : 1;
1396
1397  LinkageSpecDecl(DeclContext *DC, SourceLocation L, LanguageIDs lang,
1398                  bool Braces)
1399    : Decl(LinkageSpec, DC, L),
1400      DeclContext(LinkageSpec), Language(lang), HadBraces(Braces) { }
1401
1402public:
1403  static LinkageSpecDecl *Create(ASTContext &C, DeclContext *DC,
1404                                 SourceLocation L, LanguageIDs Lang,
1405                                 bool Braces);
1406
1407  LanguageIDs getLanguage() const { return Language; }
1408
1409  /// hasBraces - Determines whether this linkage specification had
1410  /// braces in its syntactic form.
1411  bool hasBraces() const { return HadBraces; }
1412
1413  static bool classof(const Decl *D) {
1414    return D->getKind() == LinkageSpec;
1415  }
1416  static bool classof(const LinkageSpecDecl *D) { return true; }
1417  static DeclContext *castToDeclContext(const LinkageSpecDecl *D) {
1418    return static_cast<DeclContext *>(const_cast<LinkageSpecDecl*>(D));
1419  }
1420  static LinkageSpecDecl *castFromDeclContext(const DeclContext *DC) {
1421    return static_cast<LinkageSpecDecl *>(const_cast<DeclContext*>(DC));
1422  }
1423};
1424
1425/// UsingDirectiveDecl - Represents C++ using-directive. For example:
1426///
1427///    using namespace std;
1428///
1429// NB: UsingDirectiveDecl should be Decl not NamedDecl, but we provide
1430// artificial name, for all using-directives in order to store
1431// them in DeclContext effectively.
1432class UsingDirectiveDecl : public NamedDecl {
1433
1434  /// SourceLocation - Location of 'namespace' token.
1435  SourceLocation NamespaceLoc;
1436
1437  /// \brief The source range that covers the nested-name-specifier
1438  /// preceding the namespace name.
1439  SourceRange QualifierRange;
1440
1441  /// \brief The nested-name-specifier that precedes the namespace
1442  /// name, if any.
1443  NestedNameSpecifier *Qualifier;
1444
1445  /// IdentLoc - Location of nominated namespace-name identifier.
1446  // FIXME: We don't store location of scope specifier.
1447  SourceLocation IdentLoc;
1448
1449  /// NominatedNamespace - Namespace nominated by using-directive.
1450  NamedDecl *NominatedNamespace;
1451
1452  /// Enclosing context containing both using-directive and nominated
1453  /// namespace.
1454  DeclContext *CommonAncestor;
1455
1456  /// getUsingDirectiveName - Returns special DeclarationName used by
1457  /// using-directives. This is only used by DeclContext for storing
1458  /// UsingDirectiveDecls in its lookup structure.
1459  static DeclarationName getName() {
1460    return DeclarationName::getUsingDirectiveName();
1461  }
1462
1463  UsingDirectiveDecl(DeclContext *DC, SourceLocation L,
1464                     SourceLocation NamespcLoc,
1465                     SourceRange QualifierRange,
1466                     NestedNameSpecifier *Qualifier,
1467                     SourceLocation IdentLoc,
1468                     NamedDecl *Nominated,
1469                     DeclContext *CommonAncestor)
1470    : NamedDecl(Decl::UsingDirective, DC, L, getName()),
1471      NamespaceLoc(NamespcLoc), QualifierRange(QualifierRange),
1472      Qualifier(Qualifier), IdentLoc(IdentLoc),
1473      NominatedNamespace(Nominated),
1474      CommonAncestor(CommonAncestor) {
1475  }
1476
1477public:
1478  /// \brief Retrieve the source range of the nested-name-specifier
1479  /// that qualifiers the namespace name.
1480  SourceRange getQualifierRange() const { return QualifierRange; }
1481
1482  /// \brief Retrieve the nested-name-specifier that qualifies the
1483  /// name of the namespace.
1484  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1485
1486  NamedDecl *getNominatedNamespaceAsWritten() { return NominatedNamespace; }
1487  const NamedDecl *getNominatedNamespaceAsWritten() const {
1488    return NominatedNamespace;
1489  }
1490
1491  /// getNominatedNamespace - Returns namespace nominated by using-directive.
1492  NamespaceDecl *getNominatedNamespace();
1493
1494  const NamespaceDecl *getNominatedNamespace() const {
1495    return const_cast<UsingDirectiveDecl*>(this)->getNominatedNamespace();
1496  }
1497
1498  /// getCommonAncestor - returns common ancestor context of using-directive,
1499  /// and nominated by it namespace.
1500  DeclContext *getCommonAncestor() { return CommonAncestor; }
1501  const DeclContext *getCommonAncestor() const { return CommonAncestor; }
1502
1503  /// getNamespaceKeyLocation - Returns location of namespace keyword.
1504  SourceLocation getNamespaceKeyLocation() const { return NamespaceLoc; }
1505
1506  /// getIdentLocation - Returns location of identifier.
1507  SourceLocation getIdentLocation() const { return IdentLoc; }
1508
1509  static UsingDirectiveDecl *Create(ASTContext &C, DeclContext *DC,
1510                                    SourceLocation L,
1511                                    SourceLocation NamespaceLoc,
1512                                    SourceRange QualifierRange,
1513                                    NestedNameSpecifier *Qualifier,
1514                                    SourceLocation IdentLoc,
1515                                    NamedDecl *Nominated,
1516                                    DeclContext *CommonAncestor);
1517
1518  static bool classof(const Decl *D) {
1519    return D->getKind() == Decl::UsingDirective;
1520  }
1521  static bool classof(const UsingDirectiveDecl *D) { return true; }
1522
1523  // Friend for getUsingDirectiveName.
1524  friend class DeclContext;
1525};
1526
1527/// NamespaceAliasDecl - Represents a C++ namespace alias. For example:
1528///
1529/// @code
1530/// namespace Foo = Bar;
1531/// @endcode
1532class NamespaceAliasDecl : public NamedDecl {
1533  SourceLocation AliasLoc;
1534
1535  /// \brief The source range that covers the nested-name-specifier
1536  /// preceding the namespace name.
1537  SourceRange QualifierRange;
1538
1539  /// \brief The nested-name-specifier that precedes the namespace
1540  /// name, if any.
1541  NestedNameSpecifier *Qualifier;
1542
1543  /// IdentLoc - Location of namespace identifier.
1544  SourceLocation IdentLoc;
1545
1546  /// Namespace - The Decl that this alias points to. Can either be a
1547  /// NamespaceDecl or a NamespaceAliasDecl.
1548  NamedDecl *Namespace;
1549
1550  NamespaceAliasDecl(DeclContext *DC, SourceLocation L,
1551                     SourceLocation AliasLoc, IdentifierInfo *Alias,
1552                     SourceRange QualifierRange,
1553                     NestedNameSpecifier *Qualifier,
1554                     SourceLocation IdentLoc, NamedDecl *Namespace)
1555    : NamedDecl(Decl::NamespaceAlias, DC, L, Alias), AliasLoc(AliasLoc),
1556      QualifierRange(QualifierRange), Qualifier(Qualifier),
1557      IdentLoc(IdentLoc), Namespace(Namespace) { }
1558
1559public:
1560  /// \brief Retrieve the source range of the nested-name-specifier
1561  /// that qualifiers the namespace name.
1562  SourceRange getQualifierRange() const { return QualifierRange; }
1563
1564  /// \brief Retrieve the nested-name-specifier that qualifies the
1565  /// name of the namespace.
1566  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1567
1568  NamespaceDecl *getNamespace() {
1569    if (NamespaceAliasDecl *AD = dyn_cast<NamespaceAliasDecl>(Namespace))
1570      return AD->getNamespace();
1571
1572    return cast<NamespaceDecl>(Namespace);
1573  }
1574
1575  const NamespaceDecl *getNamespace() const {
1576    return const_cast<NamespaceAliasDecl*>(this)->getNamespace();
1577  }
1578
1579  /// \brief Retrieve the namespace that this alias refers to, which
1580  /// may either be a NamespaceDecl or a NamespaceAliasDecl.
1581  NamedDecl *getAliasedNamespace() const { return Namespace; }
1582
1583  static NamespaceAliasDecl *Create(ASTContext &C, DeclContext *DC,
1584                                    SourceLocation L, SourceLocation AliasLoc,
1585                                    IdentifierInfo *Alias,
1586                                    SourceRange QualifierRange,
1587                                    NestedNameSpecifier *Qualifier,
1588                                    SourceLocation IdentLoc,
1589                                    NamedDecl *Namespace);
1590
1591  static bool classof(const Decl *D) {
1592    return D->getKind() == Decl::NamespaceAlias;
1593  }
1594  static bool classof(const NamespaceAliasDecl *D) { return true; }
1595};
1596
1597/// UsingShadowDecl - Represents a shadow declaration introduced into
1598/// a scope by a (resolved) using declaration.  For example,
1599///
1600/// namespace A {
1601///   void foo();
1602/// }
1603/// namespace B {
1604///   using A::foo(); // <- a UsingDecl
1605///                   // Also creates a UsingShadowDecl for A::foo in B
1606/// }
1607///
1608class UsingShadowDecl : public NamedDecl {
1609  /// The referenced declaration.
1610  NamedDecl *Underlying;
1611
1612  /// The using declaration which introduced this decl.
1613  UsingDecl *Using;
1614
1615  UsingShadowDecl(DeclContext *DC, SourceLocation Loc, UsingDecl *Using,
1616                  NamedDecl *Target)
1617    : NamedDecl(UsingShadow, DC, Loc, Target->getDeclName()),
1618      Underlying(Target), Using(Using) {
1619    IdentifierNamespace = Target->getIdentifierNamespace();
1620    setImplicit();
1621  }
1622
1623public:
1624  static UsingShadowDecl *Create(ASTContext &C, DeclContext *DC,
1625                                 SourceLocation Loc, UsingDecl *Using,
1626                                 NamedDecl *Target) {
1627    return new (C) UsingShadowDecl(DC, Loc, Using, Target);
1628  }
1629
1630  /// Gets the underlying declaration which has been brought into the
1631  /// local scope.
1632  NamedDecl *getTargetDecl() const {
1633    return Underlying;
1634  }
1635
1636  /// Gets the using declaration to which this declaration is tied.
1637  UsingDecl *getUsingDecl() const {
1638    return Using;
1639  }
1640
1641  static bool classof(const Decl *D) {
1642    return D->getKind() == Decl::UsingShadow;
1643  }
1644  static bool classof(const UsingShadowDecl *D) { return true; }
1645};
1646
1647/// UsingDecl - Represents a C++ using-declaration. For example:
1648///    using someNameSpace::someIdentifier;
1649class UsingDecl : public NamedDecl {
1650  /// \brief The source range that covers the nested-name-specifier
1651  /// preceding the declaration name.
1652  SourceRange NestedNameRange;
1653
1654  /// \brief The source location of the "using" location itself.
1655  SourceLocation UsingLocation;
1656
1657  /// \brief Target nested name specifier.
1658  NestedNameSpecifier* TargetNestedName;
1659
1660  /// \brief The collection of shadow declarations associated with
1661  /// this using declaration.  This set can change as a class is
1662  /// processed.
1663  llvm::SmallPtrSet<UsingShadowDecl*, 8> Shadows;
1664
1665  // \brief Has 'typename' keyword.
1666  bool IsTypeName;
1667
1668  UsingDecl(DeclContext *DC, SourceLocation L, SourceRange NNR,
1669            SourceLocation UL, NestedNameSpecifier* TargetNNS,
1670            DeclarationName Name, bool IsTypeNameArg)
1671    : NamedDecl(Decl::Using, DC, L, Name),
1672      NestedNameRange(NNR), UsingLocation(UL), TargetNestedName(TargetNNS),
1673      IsTypeName(IsTypeNameArg) {
1674  }
1675
1676public:
1677  /// \brief Returns the source range that covers the nested-name-specifier
1678  /// preceding the namespace name.
1679  SourceRange getNestedNameRange() { return NestedNameRange; }
1680
1681  /// \brief Returns the source location of the "using" location itself.
1682  SourceLocation getUsingLocation() { return UsingLocation; }
1683
1684  /// \brief Get target nested name declaration.
1685  NestedNameSpecifier* getTargetNestedNameDecl() {
1686    return TargetNestedName;
1687  }
1688
1689  /// isTypeName - Return true if using decl has 'typename'.
1690  bool isTypeName() const { return IsTypeName; }
1691
1692  typedef llvm::SmallPtrSet<UsingShadowDecl*,8>::const_iterator shadow_iterator;
1693  shadow_iterator shadow_begin() const { return Shadows.begin(); }
1694  shadow_iterator shadow_end() const { return Shadows.end(); }
1695
1696  void addShadowDecl(UsingShadowDecl *S) {
1697    assert(S->getUsingDecl() == this);
1698    if (!Shadows.insert(S)) {
1699      assert(false && "declaration already in set");
1700    }
1701  }
1702  void removeShadowDecl(UsingShadowDecl *S) {
1703    assert(S->getUsingDecl() == this);
1704    if (!Shadows.erase(S)) {
1705      assert(false && "declaration not in set");
1706    }
1707  }
1708
1709  static UsingDecl *Create(ASTContext &C, DeclContext *DC,
1710      SourceLocation IdentL, SourceRange NNR, SourceLocation UsingL,
1711      NestedNameSpecifier* TargetNNS, DeclarationName Name, bool IsTypeNameArg);
1712
1713  static bool classof(const Decl *D) {
1714    return D->getKind() == Decl::Using;
1715  }
1716  static bool classof(const UsingDecl *D) { return true; }
1717};
1718
1719/// UnresolvedUsingValueDecl - Represents a dependent using
1720/// declaration which was not marked with 'typename'.  Unlike
1721/// non-dependent using declarations, these *only* bring through
1722/// non-types; otherwise they would break two-phase lookup.
1723///
1724/// template <class T> class A : public Base<T> {
1725///   using Base<T>::foo;
1726/// };
1727class UnresolvedUsingValueDecl : public ValueDecl {
1728  /// \brief The source range that covers the nested-name-specifier
1729  /// preceding the declaration name.
1730  SourceRange TargetNestedNameRange;
1731
1732  /// \brief The source location of the 'using' keyword
1733  SourceLocation UsingLocation;
1734
1735  NestedNameSpecifier *TargetNestedNameSpecifier;
1736
1737  UnresolvedUsingValueDecl(DeclContext *DC, QualType Ty,
1738                           SourceLocation UsingLoc, SourceRange TargetNNR,
1739                           NestedNameSpecifier *TargetNNS,
1740                           SourceLocation TargetNameLoc,
1741                           DeclarationName TargetName)
1742    : ValueDecl(Decl::UnresolvedUsingValue, DC, TargetNameLoc, TargetName, Ty),
1743    TargetNestedNameRange(TargetNNR), UsingLocation(UsingLoc),
1744    TargetNestedNameSpecifier(TargetNNS)
1745  { }
1746
1747public:
1748  /// \brief Returns the source range that covers the nested-name-specifier
1749  /// preceding the namespace name.
1750  SourceRange getTargetNestedNameRange() const { return TargetNestedNameRange; }
1751
1752  /// \brief Get target nested name declaration.
1753  NestedNameSpecifier* getTargetNestedNameSpecifier() {
1754    return TargetNestedNameSpecifier;
1755  }
1756
1757  /// \brief Returns the source location of the 'using' keyword.
1758  SourceLocation getUsingLoc() const { return UsingLocation; }
1759
1760  static UnresolvedUsingValueDecl *
1761    Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc,
1762           SourceRange TargetNNR, NestedNameSpecifier *TargetNNS,
1763           SourceLocation TargetNameLoc, DeclarationName TargetName);
1764
1765  static bool classof(const Decl *D) {
1766    return D->getKind() == Decl::UnresolvedUsingValue;
1767  }
1768  static bool classof(const UnresolvedUsingValueDecl *D) { return true; }
1769};
1770
1771/// UnresolvedUsingTypenameDecl - Represents a dependent using
1772/// declaration which was marked with 'typename'.
1773///
1774/// template <class T> class A : public Base<T> {
1775///   using typename Base<T>::foo;
1776/// };
1777///
1778/// The type associated with a unresolved using typename decl is
1779/// currently always a typename type.
1780class UnresolvedUsingTypenameDecl : public TypeDecl {
1781  /// \brief The source range that covers the nested-name-specifier
1782  /// preceding the declaration name.
1783  SourceRange TargetNestedNameRange;
1784
1785  /// \brief The source location of the 'using' keyword
1786  SourceLocation UsingLocation;
1787
1788  /// \brief The source location of the 'typename' keyword
1789  SourceLocation TypenameLocation;
1790
1791  NestedNameSpecifier *TargetNestedNameSpecifier;
1792
1793  UnresolvedUsingTypenameDecl(DeclContext *DC, SourceLocation UsingLoc,
1794                    SourceLocation TypenameLoc,
1795                    SourceRange TargetNNR, NestedNameSpecifier *TargetNNS,
1796                    SourceLocation TargetNameLoc, IdentifierInfo *TargetName)
1797  : TypeDecl(Decl::UnresolvedUsingTypename, DC, TargetNameLoc, TargetName),
1798    TargetNestedNameRange(TargetNNR), UsingLocation(UsingLoc),
1799    TypenameLocation(TypenameLoc), TargetNestedNameSpecifier(TargetNNS)
1800  { }
1801
1802public:
1803  /// \brief Returns the source range that covers the nested-name-specifier
1804  /// preceding the namespace name.
1805  SourceRange getTargetNestedNameRange() const { return TargetNestedNameRange; }
1806
1807  /// \brief Get target nested name declaration.
1808  NestedNameSpecifier* getTargetNestedNameSpecifier() {
1809    return TargetNestedNameSpecifier;
1810  }
1811
1812  /// \brief Returns the source location of the 'using' keyword.
1813  SourceLocation getUsingLoc() const { return UsingLocation; }
1814
1815  /// \brief Returns the source location of the 'typename' keyword.
1816  SourceLocation getTypenameLoc() const { return TypenameLocation; }
1817
1818  static UnresolvedUsingTypenameDecl *
1819    Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc,
1820           SourceLocation TypenameLoc,
1821           SourceRange TargetNNR, NestedNameSpecifier *TargetNNS,
1822           SourceLocation TargetNameLoc, DeclarationName TargetName);
1823
1824  static bool classof(const Decl *D) {
1825    return D->getKind() == Decl::UnresolvedUsingTypename;
1826  }
1827  static bool classof(const UnresolvedUsingTypenameDecl *D) { return true; }
1828};
1829
1830/// StaticAssertDecl - Represents a C++0x static_assert declaration.
1831class StaticAssertDecl : public Decl {
1832  Expr *AssertExpr;
1833  StringLiteral *Message;
1834
1835  StaticAssertDecl(DeclContext *DC, SourceLocation L,
1836                   Expr *assertexpr, StringLiteral *message)
1837  : Decl(StaticAssert, DC, L), AssertExpr(assertexpr), Message(message) { }
1838
1839public:
1840  static StaticAssertDecl *Create(ASTContext &C, DeclContext *DC,
1841                                  SourceLocation L, Expr *AssertExpr,
1842                                  StringLiteral *Message);
1843
1844  Expr *getAssertExpr() { return AssertExpr; }
1845  const Expr *getAssertExpr() const { return AssertExpr; }
1846
1847  StringLiteral *getMessage() { return Message; }
1848  const StringLiteral *getMessage() const { return Message; }
1849
1850  virtual ~StaticAssertDecl();
1851  virtual void Destroy(ASTContext& C);
1852
1853  static bool classof(const Decl *D) {
1854    return D->getKind() == Decl::StaticAssert;
1855  }
1856  static bool classof(StaticAssertDecl *D) { return true; }
1857};
1858
1859/// Insertion operator for diagnostics.  This allows sending AccessSpecifier's
1860/// into a diagnostic with <<.
1861const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1862                                    AccessSpecifier AS);
1863
1864} // end namespace clang
1865
1866#endif
1867