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