DeclCXX.h revision 73b85f3d7ccdff37bab7adafc6b06dfd03740058
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 /// setBases - Sets the base classes of this struct or class. 301 void setBases(CXXBaseSpecifier const * const *Bases, unsigned NumBases); 302 303 /// getNumBases - Retrieves the number of base classes of this 304 /// class. 305 unsigned getNumBases() const { return NumBases; } 306 307 base_class_iterator bases_begin() { return Bases; } 308 base_class_const_iterator bases_begin() const { return Bases; } 309 base_class_iterator bases_end() { return Bases + NumBases; } 310 base_class_const_iterator bases_end() const { return Bases + NumBases; } 311 312 /// hasConstCopyConstructor - Determines whether this class has a 313 /// copy constructor that accepts a const-qualified argument. 314 bool hasConstCopyConstructor(ASTContext &Context) const; 315 316 /// getCopyConstructor - Returns the copy constructor for this class 317 CXXConstructorDecl *getCopyConstructor(ASTContext &Context, 318 unsigned TypeQuals) const; 319 320 /// hasConstCopyAssignment - Determines whether this class has a 321 /// copy assignment operator that accepts a const-qualified argument. 322 bool hasConstCopyAssignment(ASTContext &Context) const; 323 324 /// addedConstructor - Notify the class that another constructor has 325 /// been added. This routine helps maintain information about the 326 /// class based on which constructors have been added. 327 void addedConstructor(ASTContext &Context, CXXConstructorDecl *ConDecl); 328 329 /// hasUserDeclaredConstructor - Whether this class has any 330 /// user-declared constructors. When true, a default constructor 331 /// will not be implicitly declared. 332 bool hasUserDeclaredConstructor() const { return UserDeclaredConstructor; } 333 334 /// hasUserDeclaredCopyConstructor - Whether this class has a 335 /// user-declared copy constructor. When false, a copy constructor 336 /// will be implicitly declared. 337 bool hasUserDeclaredCopyConstructor() const { 338 return UserDeclaredCopyConstructor; 339 } 340 341 /// addedAssignmentOperator - Notify the class that another assignment 342 /// operator has been added. This routine helps maintain information about the 343 /// class based on which operators have been added. 344 void addedAssignmentOperator(ASTContext &Context, CXXMethodDecl *OpDecl); 345 346 /// hasUserDeclaredCopyAssignment - Whether this class has a 347 /// user-declared copy assignment operator. When false, a copy 348 /// assigment operator will be implicitly declared. 349 bool hasUserDeclaredCopyAssignment() const { 350 return UserDeclaredCopyAssignment; 351 } 352 353 /// hasUserDeclaredDestructor - Whether this class has a 354 /// user-declared destructor. When false, a destructor will be 355 /// implicitly declared. 356 bool hasUserDeclaredDestructor() const { return UserDeclaredDestructor; } 357 358 /// setUserDeclaredDestructor - Set whether this class has a 359 /// user-declared destructor. If not set by the time the class is 360 /// fully defined, a destructor will be implicitly declared. 361 void setUserDeclaredDestructor(bool UCD) { 362 UserDeclaredDestructor = UCD; 363 } 364 365 /// getConversions - Retrieve the overload set containing all of the 366 /// conversion functions in this class. 367 OverloadedFunctionDecl *getConversionFunctions() { 368 return &Conversions; 369 } 370 const OverloadedFunctionDecl *getConversionFunctions() const { 371 return &Conversions; 372 } 373 374 /// addConversionFunction - Add a new conversion function to the 375 /// list of conversion functions. 376 void addConversionFunction(ASTContext &Context, CXXConversionDecl *ConvDecl); 377 378 /// isAggregate - Whether this class is an aggregate (C++ 379 /// [dcl.init.aggr]), which is a class with no user-declared 380 /// constructors, no private or protected non-static data members, 381 /// no base classes, and no virtual functions (C++ [dcl.init.aggr]p1). 382 bool isAggregate() const { return Aggregate; } 383 384 /// setAggregate - Set whether this class is an aggregate (C++ 385 /// [dcl.init.aggr]). 386 void setAggregate(bool Agg) { Aggregate = Agg; } 387 388 /// isPOD - Whether this class is a POD-type (C++ [class]p4), which is a class 389 /// that is an aggregate that has no non-static non-POD data members, no 390 /// reference data members, no user-defined copy assignment operator and no 391 /// user-defined destructor. 392 bool isPOD() const { return PlainOldData; } 393 394 /// setPOD - Set whether this class is a POD-type (C++ [class]p4). 395 void setPOD(bool POD) { PlainOldData = POD; } 396 397 /// isPolymorphic - Whether this class is polymorphic (C++ [class.virtual]), 398 /// which means that the class contains or inherits a virtual function. 399 bool isPolymorphic() const { return Polymorphic; } 400 401 /// setPolymorphic - Set whether this class is polymorphic (C++ 402 /// [class.virtual]). 403 void setPolymorphic(bool Poly) { Polymorphic = Poly; } 404 405 /// isAbstract - Whether this class is abstract (C++ [class.abstract]), 406 /// which means that the class contains or inherits a pure virtual function. 407 bool isAbstract() const { return Abstract; } 408 409 /// setAbstract - Set whether this class is abstract (C++ [class.abstract]) 410 void setAbstract(bool Abs) { Abstract = Abs; } 411 412 // hasTrivialConstructor - Whether this class has a trivial constructor 413 // (C++ [class.ctor]p5) 414 bool hasTrivialConstructor() const { return HasTrivialConstructor; } 415 416 // setHasTrivialConstructor - Set whether this class has a trivial constructor 417 // (C++ [class.ctor]p5) 418 void setHasTrivialConstructor(bool TC) { HasTrivialConstructor = TC; } 419 420 // hasTrivialDestructor - Whether this class has a trivial destructor 421 // (C++ [class.dtor]p3) 422 bool hasTrivialDestructor() const { return HasTrivialDestructor; } 423 424 // setHasTrivialDestructor - Set whether this class has a trivial destructor 425 // (C++ [class.dtor]p3) 426 void setHasTrivialDestructor(bool TC) { HasTrivialDestructor = TC; } 427 428 /// \brief If this record is an instantiation of a member class, 429 /// retrieves the member class from which it was instantiated. 430 /// 431 /// This routine will return non-NULL for (non-templated) member 432 /// classes of class templates. For example, given: 433 /// 434 /// \code 435 /// template<typename T> 436 /// struct X { 437 /// struct A { }; 438 /// }; 439 /// \endcode 440 /// 441 /// The declaration for X<int>::A is a (non-templated) CXXRecordDecl 442 /// whose parent is the class template specialization X<int>. For 443 /// this declaration, getInstantiatedFromMemberClass() will return 444 /// the CXXRecordDecl X<T>::A. When a complete definition of 445 /// X<int>::A is required, it will be instantiated from the 446 /// declaration returned by getInstantiatedFromMemberClass(). 447 CXXRecordDecl *getInstantiatedFromMemberClass() const { 448 return TemplateOrInstantiation.dyn_cast<CXXRecordDecl*>(); 449 } 450 451 /// \brief Specify that this record is an instantiation of the 452 /// member class RD. 453 void setInstantiationOfMemberClass(CXXRecordDecl *RD) { 454 TemplateOrInstantiation = RD; 455 } 456 457 /// \brief Retrieves the class template that is described by this 458 /// class declaration. 459 /// 460 /// Every class template is represented as a ClassTemplateDecl and a 461 /// CXXRecordDecl. The former contains template properties (such as 462 /// the template parameter lists) while the latter contains the 463 /// actual description of the template's 464 /// contents. ClassTemplateDecl::getTemplatedDecl() retrieves the 465 /// CXXRecordDecl that from a ClassTemplateDecl, while 466 /// getDescribedClassTemplate() retrieves the ClassTemplateDecl from 467 /// a CXXRecordDecl. 468 ClassTemplateDecl *getDescribedClassTemplate() const { 469 return TemplateOrInstantiation.dyn_cast<ClassTemplateDecl*>(); 470 } 471 472 void setDescribedClassTemplate(ClassTemplateDecl *Template) { 473 TemplateOrInstantiation = Template; 474 } 475 476 /// getDefaultConstructor - Returns the default constructor for this class 477 CXXConstructorDecl *getDefaultConstructor(ASTContext &Context); 478 479 /// getDestructor - Returns the destructor decl for this class. 480 const CXXDestructorDecl *getDestructor(ASTContext &Context); 481 482 /// isLocalClass - If the class is a local class [class.local], returns 483 /// the enclosing function declaration. 484 const FunctionDecl *isLocalClass() const { 485 if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(getDeclContext())) 486 return RD->isLocalClass(); 487 488 return dyn_cast<FunctionDecl>(getDeclContext()); 489 } 490 491 /// viewInheritance - Renders and displays an inheritance diagram 492 /// for this C++ class and all of its base classes (transitively) using 493 /// GraphViz. 494 void viewInheritance(ASTContext& Context) const; 495 496 static bool classof(const Decl *D) { 497 return D->getKind() == CXXRecord || 498 D->getKind() == ClassTemplateSpecialization || 499 D->getKind() == ClassTemplatePartialSpecialization; 500 } 501 static bool classof(const CXXRecordDecl *D) { return true; } 502 static bool classof(const ClassTemplateSpecializationDecl *D) { 503 return true; 504 } 505}; 506 507/// CXXMethodDecl - Represents a static or instance method of a 508/// struct/union/class. 509class CXXMethodDecl : public FunctionDecl { 510protected: 511 CXXMethodDecl(Kind DK, CXXRecordDecl *RD, SourceLocation L, 512 DeclarationName N, QualType T, 513 bool isStatic, bool isInline) 514 : FunctionDecl(DK, RD, L, N, T, (isStatic ? Static : None), 515 isInline) {} 516 517public: 518 static CXXMethodDecl *Create(ASTContext &C, CXXRecordDecl *RD, 519 SourceLocation L, DeclarationName N, 520 QualType T, bool isStatic = false, 521 bool isInline = false); 522 523 bool isStatic() const { return getStorageClass() == Static; } 524 bool isInstance() const { return !isStatic(); } 525 526 bool isVirtual() const { 527 return isVirtualAsWritten() || 528 (begin_overridden_methods() != end_overridden_methods()); 529 } 530 531 /// 532 void addOverriddenMethod(const CXXMethodDecl *MD); 533 534 typedef const CXXMethodDecl ** method_iterator; 535 536 method_iterator begin_overridden_methods() const; 537 method_iterator end_overridden_methods() const; 538 539 /// getParent - Returns the parent of this method declaration, which 540 /// is the class in which this method is defined. 541 const CXXRecordDecl *getParent() const { 542 return cast<CXXRecordDecl>(FunctionDecl::getParent()); 543 } 544 545 /// getParent - Returns the parent of this method declaration, which 546 /// is the class in which this method is defined. 547 CXXRecordDecl *getParent() { 548 return const_cast<CXXRecordDecl *>( 549 cast<CXXRecordDecl>(FunctionDecl::getParent())); 550 } 551 552 /// getThisType - Returns the type of 'this' pointer. 553 /// Should only be called for instance methods. 554 QualType getThisType(ASTContext &C) const; 555 556 unsigned getTypeQualifiers() const { 557 return getType()->getAsFunctionProtoType()->getTypeQuals(); 558 } 559 560 // Implement isa/cast/dyncast/etc. 561 static bool classof(const Decl *D) { 562 return D->getKind() >= CXXMethod && D->getKind() <= CXXConversion; 563 } 564 static bool classof(const CXXMethodDecl *D) { return true; } 565}; 566 567/// CXXBaseOrMemberInitializer - Represents a C++ base or member 568/// initializer, which is part of a constructor initializer that 569/// initializes one non-static member variable or one base class. For 570/// example, in the following, both 'A(a)' and 'f(3.14159)' are member 571/// initializers: 572/// 573/// @code 574/// class A { }; 575/// class B : public A { 576/// float f; 577/// public: 578/// B(A& a) : A(a), f(3.14159) { } 579/// }; 580/// @endcode 581class CXXBaseOrMemberInitializer { 582 /// BaseOrMember - This points to the entity being initialized, 583 /// which is either a base class (a Type) or a non-static data 584 /// member. When the low bit is 1, it's a base 585 /// class; when the low bit is 0, it's a member. 586 uintptr_t BaseOrMember; 587 588 /// Args - The arguments used to initialize the base or member. 589 Expr **Args; 590 unsigned NumArgs; 591 592 /// IdLoc - Location of the id in ctor-initializer list. 593 SourceLocation IdLoc; 594 595public: 596 /// CXXBaseOrMemberInitializer - Creates a new base-class initializer. 597 explicit 598 CXXBaseOrMemberInitializer(QualType BaseType, Expr **Args, unsigned NumArgs, 599 SourceLocation L); 600 601 /// CXXBaseOrMemberInitializer - Creates a new member initializer. 602 explicit 603 CXXBaseOrMemberInitializer(FieldDecl *Member, Expr **Args, unsigned NumArgs, 604 SourceLocation L); 605 606 /// ~CXXBaseOrMemberInitializer - Destroy the base or member initializer. 607 ~CXXBaseOrMemberInitializer(); 608 609 /// arg_iterator - Iterates through the member initialization 610 /// arguments. 611 typedef Expr **arg_iterator; 612 613 /// arg_const_iterator - Iterates through the member initialization 614 /// arguments. 615 typedef Expr * const * arg_const_iterator; 616 617 /// getBaseOrMember - get the generic 'member' representing either the field 618 /// or a base class. 619 void* getBaseOrMember() const { return reinterpret_cast<void*>(BaseOrMember); } 620 621 /// isBaseInitializer - Returns true when this initializer is 622 /// initializing a base class. 623 bool isBaseInitializer() const { return (BaseOrMember & 0x1) != 0; } 624 625 /// isMemberInitializer - Returns true when this initializer is 626 /// initializing a non-static data member. 627 bool isMemberInitializer() const { return (BaseOrMember & 0x1) == 0; } 628 629 /// getBaseClass - If this is a base class initializer, returns the 630 /// type used to specify the initializer. The resulting type will be 631 /// a class type or a typedef of a class type. If this is not a base 632 /// class initializer, returns NULL. 633 Type *getBaseClass() { 634 if (isBaseInitializer()) 635 return reinterpret_cast<Type*>(BaseOrMember & ~0x01); 636 else 637 return 0; 638 } 639 640 /// getBaseClass - If this is a base class initializer, returns the 641 /// type used to specify the initializer. The resulting type will be 642 /// a class type or a typedef of a class type. If this is not a base 643 /// class initializer, returns NULL. 644 const Type *getBaseClass() const { 645 if (isBaseInitializer()) 646 return reinterpret_cast<const Type*>(BaseOrMember & ~0x01); 647 else 648 return 0; 649 } 650 651 /// getMember - If this is a member initializer, returns the 652 /// declaration of the non-static data member being 653 /// initialized. Otherwise, returns NULL. 654 FieldDecl *getMember() { 655 if (isMemberInitializer()) 656 return reinterpret_cast<FieldDecl *>(BaseOrMember); 657 else 658 return 0; 659 } 660 661 SourceLocation getSourceLocation() const { return IdLoc; } 662 663 /// begin() - Retrieve an iterator to the first initializer argument. 664 arg_iterator begin() { return Args; } 665 /// begin() - Retrieve an iterator to the first initializer argument. 666 arg_const_iterator begin() const { return Args; } 667 668 /// end() - Retrieve an iterator past the last initializer argument. 669 arg_iterator end() { return Args + NumArgs; } 670 /// end() - Retrieve an iterator past the last initializer argument. 671 arg_const_iterator end() const { return Args + NumArgs; } 672 673 /// getNumArgs - Determine the number of arguments used to 674 /// initialize the member or base. 675 unsigned getNumArgs() const { return NumArgs; } 676}; 677 678/// CXXConstructorDecl - Represents a C++ constructor within a 679/// class. For example: 680/// 681/// @code 682/// class X { 683/// public: 684/// explicit X(int); // represented by a CXXConstructorDecl. 685/// }; 686/// @endcode 687class CXXConstructorDecl : public CXXMethodDecl { 688 /// Explicit - Whether this constructor is explicit. 689 bool Explicit : 1; 690 691 /// ImplicitlyDefined - Whether this constructor was implicitly 692 /// defined by the compiler. When false, the constructor was defined 693 /// by the user. In C++03, this flag will have the same value as 694 /// Implicit. In C++0x, however, a constructor that is 695 /// explicitly defaulted (i.e., defined with " = default") will have 696 /// @c !Implicit && ImplicitlyDefined. 697 bool ImplicitlyDefined : 1; 698 699 /// Support for base and member initializers. 700 /// BaseOrMemberInitializers - The arguments used to initialize the base 701 /// or member. 702 CXXBaseOrMemberInitializer **BaseOrMemberInitializers; 703 unsigned NumBaseOrMemberInitializers; 704 705 CXXConstructorDecl(CXXRecordDecl *RD, SourceLocation L, 706 DeclarationName N, QualType T, 707 bool isExplicit, bool isInline, bool isImplicitlyDeclared) 708 : CXXMethodDecl(CXXConstructor, RD, L, N, T, false, isInline), 709 Explicit(isExplicit), ImplicitlyDefined(false), 710 BaseOrMemberInitializers(0), NumBaseOrMemberInitializers(0) { 711 setImplicit(isImplicitlyDeclared); 712 } 713 virtual void Destroy(ASTContext& C); 714 715public: 716 static CXXConstructorDecl *Create(ASTContext &C, CXXRecordDecl *RD, 717 SourceLocation L, DeclarationName N, 718 QualType T, bool isExplicit, 719 bool isInline, bool isImplicitlyDeclared); 720 721 /// isExplicit - Whether this constructor was marked "explicit" or not. 722 bool isExplicit() const { return Explicit; } 723 724 /// isImplicitlyDefined - Whether this constructor was implicitly 725 /// defined. If false, then this constructor was defined by the 726 /// user. This operation can only be invoked if the constructor has 727 /// already been defined. 728 bool isImplicitlyDefined(ASTContext &C) const { 729 assert(isThisDeclarationADefinition() && 730 "Can only get the implicit-definition flag once the " 731 "constructor has been defined"); 732 return ImplicitlyDefined; 733 } 734 735 /// setImplicitlyDefined - Set whether this constructor was 736 /// implicitly defined or not. 737 void setImplicitlyDefined(bool ID) { 738 assert(isThisDeclarationADefinition() && 739 "Can only set the implicit-definition flag once the constructor " 740 "has been defined"); 741 ImplicitlyDefined = ID; 742 } 743 744 /// init_iterator - Iterates through the member/base initializer list. 745 typedef CXXBaseOrMemberInitializer **init_iterator; 746 747 /// init_const_iterator - Iterates through the memberbase initializer list. 748 typedef CXXBaseOrMemberInitializer * const * init_const_iterator; 749 750 /// begin() - Retrieve an iterator to the first initializer. 751 init_iterator begin() { return BaseOrMemberInitializers; } 752 /// begin() - Retrieve an iterator to the first initializer. 753 init_const_iterator begin() const { return BaseOrMemberInitializers; } 754 755 /// end() - Retrieve an iterator past the last initializer. 756 init_iterator end() { 757 return BaseOrMemberInitializers + NumBaseOrMemberInitializers; 758 } 759 /// end() - Retrieve an iterator past the last initializer. 760 init_const_iterator end() const { 761 return BaseOrMemberInitializers + NumBaseOrMemberInitializers; 762 } 763 764 /// getNumArgs - Determine the number of arguments used to 765 /// initialize the member or base. 766 unsigned getNumBaseOrMemberInitializers() const { 767 return NumBaseOrMemberInitializers; 768 } 769 770 void setBaseOrMemberInitializers(ASTContext &C, 771 CXXBaseOrMemberInitializer **Initializers, 772 unsigned NumInitializers); 773 774 /// isDefaultConstructor - Whether this constructor is a default 775 /// constructor (C++ [class.ctor]p5), which can be used to 776 /// default-initialize a class of this type. 777 bool isDefaultConstructor() const; 778 779 /// isCopyConstructor - Whether this constructor is a copy 780 /// constructor (C++ [class.copy]p2, which can be used to copy the 781 /// class. @p TypeQuals will be set to the qualifiers on the 782 /// argument type. For example, @p TypeQuals would be set to @c 783 /// QualType::Const for the following copy constructor: 784 /// 785 /// @code 786 /// class X { 787 /// public: 788 /// X(const X&); 789 /// }; 790 /// @endcode 791 bool isCopyConstructor(ASTContext &Context, unsigned &TypeQuals) const; 792 793 /// isCopyConstructor - Whether this constructor is a copy 794 /// constructor (C++ [class.copy]p2, which can be used to copy the 795 /// class. 796 bool isCopyConstructor(ASTContext &Context) const { 797 unsigned TypeQuals = 0; 798 return isCopyConstructor(Context, TypeQuals); 799 } 800 801 /// isConvertingConstructor - Whether this constructor is a 802 /// converting constructor (C++ [class.conv.ctor]), which can be 803 /// used for user-defined conversions. 804 bool isConvertingConstructor() const; 805 806 // Implement isa/cast/dyncast/etc. 807 static bool classof(const Decl *D) { 808 return D->getKind() == CXXConstructor; 809 } 810 static bool classof(const CXXConstructorDecl *D) { return true; } 811}; 812 813/// CXXDestructorDecl - Represents a C++ destructor within a 814/// class. For example: 815/// 816/// @code 817/// class X { 818/// public: 819/// ~X(); // represented by a CXXDestructorDecl. 820/// }; 821/// @endcode 822class CXXDestructorDecl : public CXXMethodDecl { 823 /// ImplicitlyDefined - Whether this destructor was implicitly 824 /// defined by the compiler. When false, the destructor was defined 825 /// by the user. In C++03, this flag will have the same value as 826 /// Implicit. In C++0x, however, a destructor that is 827 /// explicitly defaulted (i.e., defined with " = default") will have 828 /// @c !Implicit && ImplicitlyDefined. 829 bool ImplicitlyDefined : 1; 830 831 CXXDestructorDecl(CXXRecordDecl *RD, SourceLocation L, 832 DeclarationName N, QualType T, 833 bool isInline, bool isImplicitlyDeclared) 834 : CXXMethodDecl(CXXDestructor, RD, L, N, T, false, isInline), 835 ImplicitlyDefined(false) { 836 setImplicit(isImplicitlyDeclared); 837 } 838 839public: 840 static CXXDestructorDecl *Create(ASTContext &C, CXXRecordDecl *RD, 841 SourceLocation L, DeclarationName N, 842 QualType T, bool isInline, 843 bool isImplicitlyDeclared); 844 845 /// isImplicitlyDefined - Whether this destructor was implicitly 846 /// defined. If false, then this destructor was defined by the 847 /// user. This operation can only be invoked if the destructor has 848 /// already been defined. 849 bool isImplicitlyDefined() const { 850 assert(isThisDeclarationADefinition() && 851 "Can only get the implicit-definition flag once the destructor has been defined"); 852 return ImplicitlyDefined; 853 } 854 855 /// setImplicitlyDefined - Set whether this destructor was 856 /// implicitly defined or not. 857 void setImplicitlyDefined(bool ID) { 858 assert(isThisDeclarationADefinition() && 859 "Can only set the implicit-definition flag once the destructor has been defined"); 860 ImplicitlyDefined = ID; 861 } 862 863 // Implement isa/cast/dyncast/etc. 864 static bool classof(const Decl *D) { 865 return D->getKind() == CXXDestructor; 866 } 867 static bool classof(const CXXDestructorDecl *D) { return true; } 868}; 869 870/// CXXConversionDecl - Represents a C++ conversion function within a 871/// class. For example: 872/// 873/// @code 874/// class X { 875/// public: 876/// operator bool(); 877/// }; 878/// @endcode 879class CXXConversionDecl : public CXXMethodDecl { 880 /// Explicit - Whether this conversion function is marked 881 /// "explicit", meaning that it can only be applied when the user 882 /// explicitly wrote a cast. This is a C++0x feature. 883 bool Explicit : 1; 884 885 CXXConversionDecl(CXXRecordDecl *RD, SourceLocation L, 886 DeclarationName N, QualType T, 887 bool isInline, bool isExplicit) 888 : CXXMethodDecl(CXXConversion, RD, L, N, T, false, isInline), 889 Explicit(isExplicit) { } 890 891public: 892 static CXXConversionDecl *Create(ASTContext &C, CXXRecordDecl *RD, 893 SourceLocation L, DeclarationName N, 894 QualType T, bool isInline, 895 bool isExplicit); 896 897 /// isExplicit - Whether this is an explicit conversion operator 898 /// (C++0x only). Explicit conversion operators are only considered 899 /// when the user has explicitly written a cast. 900 bool isExplicit() const { return Explicit; } 901 902 /// getConversionType - Returns the type that this conversion 903 /// function is converting to. 904 QualType getConversionType() const { 905 return getType()->getAsFunctionType()->getResultType(); 906 } 907 908 // Implement isa/cast/dyncast/etc. 909 static bool classof(const Decl *D) { 910 return D->getKind() == CXXConversion; 911 } 912 static bool classof(const CXXConversionDecl *D) { return true; } 913}; 914 915/// LinkageSpecDecl - This represents a linkage specification. For example: 916/// extern "C" void foo(); 917/// 918class LinkageSpecDecl : public Decl, public DeclContext { 919public: 920 /// LanguageIDs - Used to represent the language in a linkage 921 /// specification. The values are part of the serialization abi for 922 /// ASTs and cannot be changed without altering that abi. To help 923 /// ensure a stable abi for this, we choose the DW_LANG_ encodings 924 /// from the dwarf standard. 925 enum LanguageIDs { lang_c = /* DW_LANG_C */ 0x0002, 926 lang_cxx = /* DW_LANG_C_plus_plus */ 0x0004 }; 927private: 928 /// Language - The language for this linkage specification. 929 LanguageIDs Language; 930 931 /// HadBraces - Whether this linkage specification had curly braces or not. 932 bool HadBraces : 1; 933 934 LinkageSpecDecl(DeclContext *DC, SourceLocation L, LanguageIDs lang, 935 bool Braces) 936 : Decl(LinkageSpec, DC, L), 937 DeclContext(LinkageSpec), Language(lang), HadBraces(Braces) { } 938 939public: 940 static LinkageSpecDecl *Create(ASTContext &C, DeclContext *DC, 941 SourceLocation L, LanguageIDs Lang, 942 bool Braces); 943 944 LanguageIDs getLanguage() const { return Language; } 945 946 /// hasBraces - Determines whether this linkage specification had 947 /// braces in its syntactic form. 948 bool hasBraces() const { return HadBraces; } 949 950 static bool classof(const Decl *D) { 951 return D->getKind() == LinkageSpec; 952 } 953 static bool classof(const LinkageSpecDecl *D) { return true; } 954 static DeclContext *castToDeclContext(const LinkageSpecDecl *D) { 955 return static_cast<DeclContext *>(const_cast<LinkageSpecDecl*>(D)); 956 } 957 static LinkageSpecDecl *castFromDeclContext(const DeclContext *DC) { 958 return static_cast<LinkageSpecDecl *>(const_cast<DeclContext*>(DC)); 959 } 960}; 961 962/// UsingDirectiveDecl - Represents C++ using-directive. For example: 963/// 964/// using namespace std; 965/// 966// NB: UsingDirectiveDecl should be Decl not NamedDecl, but we provide 967// artificial name, for all using-directives in order to store 968// them in DeclContext effectively. 969class UsingDirectiveDecl : public NamedDecl { 970 971 /// SourceLocation - Location of 'namespace' token. 972 SourceLocation NamespaceLoc; 973 974 /// \brief The source range that covers the nested-name-specifier 975 /// preceding the namespace name. 976 SourceRange QualifierRange; 977 978 /// \brief The nested-name-specifier that precedes the namespace 979 /// name, if any. 980 NestedNameSpecifier *Qualifier; 981 982 /// IdentLoc - Location of nominated namespace-name identifier. 983 // FIXME: We don't store location of scope specifier. 984 SourceLocation IdentLoc; 985 986 /// NominatedNamespace - Namespace nominated by using-directive. 987 NamespaceDecl *NominatedNamespace; 988 989 /// Enclosing context containing both using-directive and nomintated 990 /// namespace. 991 DeclContext *CommonAncestor; 992 993 /// getUsingDirectiveName - Returns special DeclarationName used by 994 /// using-directives. This is only used by DeclContext for storing 995 /// UsingDirectiveDecls in its lookup structure. 996 static DeclarationName getName() { 997 return DeclarationName::getUsingDirectiveName(); 998 } 999 1000 UsingDirectiveDecl(DeclContext *DC, SourceLocation L, 1001 SourceLocation NamespcLoc, 1002 SourceRange QualifierRange, 1003 NestedNameSpecifier *Qualifier, 1004 SourceLocation IdentLoc, 1005 NamespaceDecl *Nominated, 1006 DeclContext *CommonAncestor) 1007 : NamedDecl(Decl::UsingDirective, DC, L, getName()), 1008 NamespaceLoc(NamespcLoc), QualifierRange(QualifierRange), 1009 Qualifier(Qualifier), IdentLoc(IdentLoc), 1010 NominatedNamespace(Nominated? Nominated->getOriginalNamespace() : 0), 1011 CommonAncestor(CommonAncestor) { 1012 } 1013 1014public: 1015 /// \brief Retrieve the source range of the nested-name-specifier 1016 /// that qualifiers the namespace name. 1017 SourceRange getQualifierRange() const { return QualifierRange; } 1018 1019 /// \brief Retrieve the nested-name-specifier that qualifies the 1020 /// name of the namespace. 1021 NestedNameSpecifier *getQualifier() const { return Qualifier; } 1022 1023 /// getNominatedNamespace - Returns namespace nominated by using-directive. 1024 NamespaceDecl *getNominatedNamespace() { return NominatedNamespace; } 1025 1026 const NamespaceDecl *getNominatedNamespace() const { 1027 return const_cast<UsingDirectiveDecl*>(this)->getNominatedNamespace(); 1028 } 1029 1030 /// getCommonAncestor - returns common ancestor context of using-directive, 1031 /// and nominated by it namespace. 1032 DeclContext *getCommonAncestor() { return CommonAncestor; } 1033 const DeclContext *getCommonAncestor() const { return CommonAncestor; } 1034 1035 /// getNamespaceKeyLocation - Returns location of namespace keyword. 1036 SourceLocation getNamespaceKeyLocation() const { return NamespaceLoc; } 1037 1038 /// getIdentLocation - Returns location of identifier. 1039 SourceLocation getIdentLocation() const { return IdentLoc; } 1040 1041 static UsingDirectiveDecl *Create(ASTContext &C, DeclContext *DC, 1042 SourceLocation L, 1043 SourceLocation NamespaceLoc, 1044 SourceRange QualifierRange, 1045 NestedNameSpecifier *Qualifier, 1046 SourceLocation IdentLoc, 1047 NamespaceDecl *Nominated, 1048 DeclContext *CommonAncestor); 1049 1050 static bool classof(const Decl *D) { 1051 return D->getKind() == Decl::UsingDirective; 1052 } 1053 static bool classof(const UsingDirectiveDecl *D) { return true; } 1054 1055 // Friend for getUsingDirectiveName. 1056 friend class DeclContext; 1057}; 1058 1059/// NamespaceAliasDecl - Represents a C++ namespace alias. For example: 1060/// 1061/// @code 1062/// namespace Foo = Bar; 1063/// @endcode 1064class NamespaceAliasDecl : public NamedDecl { 1065 SourceLocation AliasLoc; 1066 1067 /// \brief The source range that covers the nested-name-specifier 1068 /// preceding the namespace name. 1069 SourceRange QualifierRange; 1070 1071 /// \brief The nested-name-specifier that precedes the namespace 1072 /// name, if any. 1073 NestedNameSpecifier *Qualifier; 1074 1075 /// IdentLoc - Location of namespace identifier. 1076 SourceLocation IdentLoc; 1077 1078 /// Namespace - The Decl that this alias points to. Can either be a 1079 /// NamespaceDecl or a NamespaceAliasDecl. 1080 NamedDecl *Namespace; 1081 1082 NamespaceAliasDecl(DeclContext *DC, SourceLocation L, 1083 SourceLocation AliasLoc, IdentifierInfo *Alias, 1084 SourceRange QualifierRange, 1085 NestedNameSpecifier *Qualifier, 1086 SourceLocation IdentLoc, NamedDecl *Namespace) 1087 : NamedDecl(Decl::NamespaceAlias, DC, L, Alias), AliasLoc(AliasLoc), 1088 QualifierRange(QualifierRange), Qualifier(Qualifier), 1089 IdentLoc(IdentLoc), Namespace(Namespace) { } 1090 1091public: 1092 /// \brief Retrieve the source range of the nested-name-specifier 1093 /// that qualifiers the namespace name. 1094 SourceRange getQualifierRange() const { return QualifierRange; } 1095 1096 /// \brief Retrieve the nested-name-specifier that qualifies the 1097 /// name of the namespace. 1098 NestedNameSpecifier *getQualifier() const { return Qualifier; } 1099 1100 NamespaceDecl *getNamespace() { 1101 if (NamespaceAliasDecl *AD = dyn_cast<NamespaceAliasDecl>(Namespace)) 1102 return AD->getNamespace(); 1103 1104 return cast<NamespaceDecl>(Namespace); 1105 } 1106 1107 const NamespaceDecl *getNamespace() const { 1108 return const_cast<NamespaceAliasDecl*>(this)->getNamespace(); 1109 } 1110 1111 /// \brief Retrieve the namespace that this alias refers to, which 1112 /// may either be a NamespaceDecl or a NamespaceAliasDecl. 1113 NamedDecl *getAliasedNamespace() const { return Namespace; } 1114 1115 static NamespaceAliasDecl *Create(ASTContext &C, DeclContext *DC, 1116 SourceLocation L, SourceLocation AliasLoc, 1117 IdentifierInfo *Alias, 1118 SourceRange QualifierRange, 1119 NestedNameSpecifier *Qualifier, 1120 SourceLocation IdentLoc, 1121 NamedDecl *Namespace); 1122 1123 static bool classof(const Decl *D) { 1124 return D->getKind() == Decl::NamespaceAlias; 1125 } 1126 static bool classof(const NamespaceAliasDecl *D) { return true; } 1127}; 1128 1129/// UsingDecl - Represents a C++ using-declaration. For example: 1130/// using someNameSpace::someIdentifier; 1131class UsingDecl : public NamedDecl { 1132 1133 /// \brief The source range that covers the nested-name-specifier 1134 /// preceding the declaration name. 1135 SourceRange NestedNameRange; 1136 /// \brief The source location of the target declaration name. 1137 SourceLocation TargetNameLocation; 1138 /// \brief The source location of the "using" location itself. 1139 SourceLocation UsingLocation; 1140 /// \brief Target declaration. 1141 NamedDecl* TargetDecl; 1142 /// \brief Target declaration. 1143 NestedNameSpecifier* TargetNestedNameDecl; 1144 1145 // Had 'typename' keyword. 1146 bool IsTypeName; 1147 1148 UsingDecl(DeclContext *DC, SourceLocation L, SourceRange NNR, 1149 SourceLocation TargetNL, SourceLocation UL, NamedDecl* Target, 1150 NestedNameSpecifier* TargetNNS, bool IsTypeNameArg) 1151 : NamedDecl(Decl::Using, DC, L, Target->getDeclName()), 1152 NestedNameRange(NNR), TargetNameLocation(TargetNL), 1153 UsingLocation(UL), TargetDecl(Target), 1154 TargetNestedNameDecl(TargetNNS), IsTypeName(IsTypeNameArg) { 1155 this->IdentifierNamespace = TargetDecl->getIdentifierNamespace(); 1156 } 1157 1158public: 1159 /// \brief Returns the source range that covers the nested-name-specifier 1160 /// preceding the namespace name. 1161 SourceRange getNestedNameRange() { return NestedNameRange; } 1162 1163 /// \brief Returns the source location of the target declaration name. 1164 SourceLocation getTargetNameLocation() { return TargetNameLocation; } 1165 1166 /// \brief Returns the source location of the "using" location itself. 1167 SourceLocation getUsingLocation() { return UsingLocation; } 1168 1169 /// \brief getTargetDecl - Returns target specified by using-decl. 1170 NamedDecl *getTargetDecl() { return TargetDecl; } 1171 const NamedDecl *getTargetDecl() const { return TargetDecl; } 1172 1173 /// \brief Get target nested name declaration. 1174 NestedNameSpecifier* getTargetNestedNameDecl() { 1175 return TargetNestedNameDecl; 1176 } 1177 1178 /// isTypeName - Return true if using decl had 'typename'. 1179 bool isTypeName() const { return IsTypeName; } 1180 1181 static UsingDecl *Create(ASTContext &C, DeclContext *DC, 1182 SourceLocation L, SourceRange NNR, SourceLocation TargetNL, 1183 SourceLocation UL, NamedDecl* Target, 1184 NestedNameSpecifier* TargetNNS, bool IsTypeNameArg); 1185 1186 static bool classof(const Decl *D) { 1187 return D->getKind() == Decl::Using; 1188 } 1189 static bool classof(const UsingDecl *D) { return true; } 1190}; 1191 1192/// StaticAssertDecl - Represents a C++0x static_assert declaration. 1193class StaticAssertDecl : public Decl { 1194 Expr *AssertExpr; 1195 StringLiteral *Message; 1196 1197 StaticAssertDecl(DeclContext *DC, SourceLocation L, 1198 Expr *assertexpr, StringLiteral *message) 1199 : Decl(StaticAssert, DC, L), AssertExpr(assertexpr), Message(message) { } 1200 1201public: 1202 static StaticAssertDecl *Create(ASTContext &C, DeclContext *DC, 1203 SourceLocation L, Expr *AssertExpr, 1204 StringLiteral *Message); 1205 1206 Expr *getAssertExpr() { return AssertExpr; } 1207 const Expr *getAssertExpr() const { return AssertExpr; } 1208 1209 StringLiteral *getMessage() { return Message; } 1210 const StringLiteral *getMessage() const { return Message; } 1211 1212 virtual ~StaticAssertDecl(); 1213 virtual void Destroy(ASTContext& C); 1214 1215 static bool classof(const Decl *D) { 1216 return D->getKind() == Decl::StaticAssert; 1217 } 1218 static bool classof(StaticAssertDecl *D) { return true; } 1219}; 1220 1221/// Insertion operator for diagnostics. This allows sending AccessSpecifier's 1222/// into a diagnostic with <<. 1223const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, 1224 AccessSpecifier AS); 1225 1226} // end namespace clang 1227 1228#endif 1229