DeclBase.h revision c36c540c5bfce941f3d892919394d092491211f2
10ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner//===-- DeclBase.h - Base Classes for representing declarations *- C++ -*-===// 20ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner// 30ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner// The LLVM Compiler Infrastructure 40ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner// 50ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner// This file is distributed under the University of Illinois Open Source 60ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner// License. See LICENSE.TXT for details. 70ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner// 80ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner//===----------------------------------------------------------------------===// 90ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner// 10b048c9835969c4f7fe06264748be18ed4b442116Chris Lattner// This file defines the Decl and DeclContext interfaces. 110ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner// 120ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner//===----------------------------------------------------------------------===// 130ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 140ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner#ifndef LLVM_CLANG_AST_DECLBASE_H 150ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner#define LLVM_CLANG_AST_DECLBASE_H 160ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 170ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner#include "clang/AST/Attr.h" 180ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner#include "clang/AST/Type.h" 194afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor// FIXME: Layering violation 204afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor#include "clang/Parse/AccessSpecifier.h" 2149f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattner#include "llvm/Support/PrettyStackTrace.h" 22ee219fd5f2776d8dd39d857f87304297b5ed743aChris Lattner#include "llvm/ADT/PointerUnion.h" 230ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 240ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattnernamespace clang { 2542220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidisclass DeclContext; 26ef177820100ab583b08fd3056e2a5a52ee4b1629Argyrios Kyrtzidisclass TranslationUnitDecl; 272d1c5d313cd0c229cc614e74baa4c5756a4b46f4Argyrios Kyrtzidisclass NamespaceDecl; 282a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregorclass UsingDirectiveDecl; 2944b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregorclass NamedDecl; 300ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattnerclass FunctionDecl; 31d3bb44f0f1a83cb208d3e61ee80afe6a4d20d2d8Argyrios Kyrtzidisclass CXXRecordDecl; 32b048c9835969c4f7fe06264748be18ed4b442116Chris Lattnerclass EnumDecl; 33d3bb44f0f1a83cb208d3e61ee80afe6a4d20d2d8Argyrios Kyrtzidisclass ObjCMethodDecl; 3464650af7cc4352c6c67b9bd1bf8ef3ce7471b910Douglas Gregorclass ObjCContainerDecl; 350ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattnerclass ObjCInterfaceDecl; 360701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroffclass ObjCCategoryDecl; 370701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroffclass ObjCProtocolDecl; 380701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroffclass ObjCImplementationDecl; 390701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroffclass ObjCCategoryImplDecl; 40074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregorclass LinkageSpecDecl; 4156ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroffclass BlockDecl; 4244b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregorclass DeclarationName; 43eaab20669b6a9910a5deb0110fdd8f7581d86a36Ted Kremenekclass CompoundStmt; 440eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattner} 450eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattner 460eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattnernamespace llvm { 470eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattner// DeclContext* is only 4-byte aligned on 32-bit systems. 480eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattnertemplate<> 490eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattner class PointerLikeTypeTraits<clang::DeclContext*> { 500eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattner typedef clang::DeclContext* PT; 510eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattnerpublic: 520eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattner static inline void *getAsVoidPointer(PT P) { return P; } 530eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattner static inline PT getFromVoidPointer(void *P) { 540eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattner return static_cast<PT>(P); 550eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattner } 560eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattner enum { NumLowBitsAvailable = 2 }; 570eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattner}; 580eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattner} 590eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattner 600eda3b31a672ea486fa92b9bc49a2c91be856b53Chris Lattnernamespace clang { 610ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 620ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner/// Decl - This represents one declaration (or definition), e.g. a variable, 630ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner/// typedef, function, struct, etc. 640ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner/// 650ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattnerclass Decl { 660ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattnerpublic: 6764650af7cc4352c6c67b9bd1bf8ef3ce7471b910Douglas Gregor /// \brief Lists the kind of concrete classes of Decl. 680ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner enum Kind { 6964650af7cc4352c6c67b9bd1bf8ef3ce7471b910Douglas Gregor#define DECL(Derived, Base) Derived, 7064650af7cc4352c6c67b9bd1bf8ef3ce7471b910Douglas Gregor#define DECL_RANGE(CommonBase, Start, End) \ 7164650af7cc4352c6c67b9bd1bf8ef3ce7471b910Douglas Gregor CommonBase##First = Start, CommonBase##Last = End, 7264650af7cc4352c6c67b9bd1bf8ef3ce7471b910Douglas Gregor#define LAST_DECL_RANGE(CommonBase, Start, End) \ 7364650af7cc4352c6c67b9bd1bf8ef3ce7471b910Douglas Gregor CommonBase##First = Start, CommonBase##Last = End 7464650af7cc4352c6c67b9bd1bf8ef3ce7471b910Douglas Gregor#include "clang/AST/DeclNodes.def" 750ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner }; 760ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 770ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner /// IdentifierNamespace - According to C99 6.2.3, there are four namespaces, 782ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregor /// labels, tags, members and ordinary identifiers. These are meant 792ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregor /// as bitmasks, so that searches in C++ can look into the "tag" namespace 802ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregor /// during ordinary lookup. 810ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner enum IdentifierNamespace { 822ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregor IDNS_Label = 0x1, 832ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregor IDNS_Tag = 0x2, 842ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregor IDNS_Member = 0x4, 857dda67d8decef1b3621a151488c4b83bd8372d6aDouglas Gregor IDNS_Ordinary = 0x8, 867dda67d8decef1b3621a151488c4b83bd8372d6aDouglas Gregor IDNS_Protocol = 0x10 870ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner }; 880ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 890ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner /// ObjCDeclQualifier - Qualifier used on types in method declarations 900ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner /// for remote messaging. They are meant for the arguments though and 910ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner /// applied to the Decls (ObjCMethodDecl and ParmVarDecl). 920ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner enum ObjCDeclQualifier { 930ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner OBJC_TQ_None = 0x0, 940ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner OBJC_TQ_In = 0x1, 950ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner OBJC_TQ_Inout = 0x2, 960ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner OBJC_TQ_Out = 0x4, 970ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner OBJC_TQ_Bycopy = 0x8, 980ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner OBJC_TQ_Byref = 0x10, 990ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner OBJC_TQ_Oneway = 0x20 1000ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner }; 1010ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 1020ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattnerprivate: 103244a67d911d08c3757a18ad666e4a268cf3ee285Chris Lattner /// NextDeclInContext - The next declaration within the same lexical 1044afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// DeclContext. These pointers form the linked list that is 1054afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// traversed via DeclContext's decls_begin()/decls_end(). 106244a67d911d08c3757a18ad666e4a268cf3ee285Chris Lattner Decl *NextDeclInContext; 1074afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor 1084afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor friend class DeclContext; 1094afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor 110ee219fd5f2776d8dd39d857f87304297b5ed743aChris Lattner struct MultipleDC { 111ee219fd5f2776d8dd39d857f87304297b5ed743aChris Lattner DeclContext *SemanticDC; 112ee219fd5f2776d8dd39d857f87304297b5ed743aChris Lattner DeclContext *LexicalDC; 113ee219fd5f2776d8dd39d857f87304297b5ed743aChris Lattner }; 114ee219fd5f2776d8dd39d857f87304297b5ed743aChris Lattner 115ee219fd5f2776d8dd39d857f87304297b5ed743aChris Lattner 1164afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// DeclCtx - Holds either a DeclContext* or a MultipleDC*. 1174afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// For declarations that don't contain C++ scope specifiers, it contains 1184afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// the DeclContext where the Decl was declared. 1194afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// For declarations with C++ scope specifiers, it contains a MultipleDC* 1204afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// with the context where it semantically belongs (SemanticDC) and the 1214afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// context where it was lexically declared (LexicalDC). 1224afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// e.g.: 1234afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// 1244afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// namespace A { 1254afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// void f(); // SemanticDC == LexicalDC == 'namespace A' 1264afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// } 1274afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// void A::f(); // SemanticDC == namespace 'A' 1284afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// // LexicalDC == global namespace 129ee219fd5f2776d8dd39d857f87304297b5ed743aChris Lattner llvm::PointerUnion<DeclContext*, MultipleDC*> DeclCtx; 1304afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor 131ee219fd5f2776d8dd39d857f87304297b5ed743aChris Lattner inline bool isInSemaDC() const { return DeclCtx.is<DeclContext*>(); } 132ee219fd5f2776d8dd39d857f87304297b5ed743aChris Lattner inline bool isOutOfSemaDC() const { return DeclCtx.is<MultipleDC*>(); } 1334afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor inline MultipleDC *getMultipleDC() const { 134ee219fd5f2776d8dd39d857f87304297b5ed743aChris Lattner return DeclCtx.get<MultipleDC*>(); 1354afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor } 13610d8379676f32b493740a5509e2cd7f0d6433139Chris Lattner inline DeclContext *getSemanticDC() const { 137ee219fd5f2776d8dd39d857f87304297b5ed743aChris Lattner return DeclCtx.get<DeclContext*>(); 13810d8379676f32b493740a5509e2cd7f0d6433139Chris Lattner } 13910d8379676f32b493740a5509e2cd7f0d6433139Chris Lattner 14039d7650656fdd1be879ed7d0c722cfeae95e56d5Daniel Dunbar /// Loc - The location that this decl. 14139d7650656fdd1be879ed7d0c722cfeae95e56d5Daniel Dunbar SourceLocation Loc; 14239d7650656fdd1be879ed7d0c722cfeae95e56d5Daniel Dunbar 1430ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner /// DeclKind - This indicates which class this is. 1440ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner Kind DeclKind : 8; 1450ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 1460ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner /// InvalidDecl - This indicates a semantic error occurred. 1470ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner unsigned int InvalidDecl : 1; 1480ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 1490ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner /// HasAttrs - This indicates whether the decl has attributes or not. 1500ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner unsigned int HasAttrs : 1; 151d3bb44f0f1a83cb208d3e61ee80afe6a4d20d2d8Argyrios Kyrtzidis 1526b3945f4bc757bdadd3e443180cf32c2cccb52a0Douglas Gregor /// Implicit - Whether this declaration was implicitly generated by 1536b3945f4bc757bdadd3e443180cf32c2cccb52a0Douglas Gregor /// the implementation rather than explicitly written by the user. 1546b3945f4bc757bdadd3e443180cf32c2cccb52a0Douglas Gregor bool Implicit : 1; 1556b3945f4bc757bdadd3e443180cf32c2cccb52a0Douglas Gregor 156769dbdf467681f6020ff248b969c2d41a4fdccd3Chris Lattner /// IdentifierNamespace - This specifies what IDNS_* namespace this lives in. 157769dbdf467681f6020ff248b969c2d41a4fdccd3Chris Lattner unsigned IdentifierNamespace : 5; 158769dbdf467681f6020ff248b969c2d41a4fdccd3Chris Lattner 1591329c274628cc8c4e8ad472b41d1a78c8123f611Anders Carlsson#ifndef NDEBUG 1601329c274628cc8c4e8ad472b41d1a78c8123f611Anders Carlsson void CheckAccessDeclContext() const; 1611329c274628cc8c4e8ad472b41d1a78c8123f611Anders Carlsson#else 1621329c274628cc8c4e8ad472b41d1a78c8123f611Anders Carlsson void CheckAccessDeclContext() const { } 1631329c274628cc8c4e8ad472b41d1a78c8123f611Anders Carlsson#endif 1641329c274628cc8c4e8ad472b41d1a78c8123f611Anders Carlsson 1654afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorprotected: 166d3bb44f0f1a83cb208d3e61ee80afe6a4d20d2d8Argyrios Kyrtzidis /// Access - Used by C++ decls for the access specifier. 167d3bb44f0f1a83cb208d3e61ee80afe6a4d20d2d8Argyrios Kyrtzidis // NOTE: VC++ treats enums as signed, avoid using the AccessSpecifier enum 168d3bb44f0f1a83cb208d3e61ee80afe6a4d20d2d8Argyrios Kyrtzidis unsigned Access : 2; 169d3bb44f0f1a83cb208d3e61ee80afe6a4d20d2d8Argyrios Kyrtzidis friend class CXXClassMemberWrapper; 170d3bb44f0f1a83cb208d3e61ee80afe6a4d20d2d8Argyrios Kyrtzidis 1714afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor Decl(Kind DK, DeclContext *DC, SourceLocation L) 172682bf92db408a6cbc3d37b5496a99b6ef85041ecChris Lattner : NextDeclInContext(0), DeclCtx(DC), 17339d7650656fdd1be879ed7d0c722cfeae95e56d5Daniel Dunbar Loc(L), DeclKind(DK), InvalidDecl(0), 174769dbdf467681f6020ff248b969c2d41a4fdccd3Chris Lattner HasAttrs(false), Implicit(false), 175769dbdf467681f6020ff248b969c2d41a4fdccd3Chris Lattner IdentifierNamespace(getIdentifierNamespaceForKind(DK)), Access(AS_none) { 1760ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner if (Decl::CollectingStats()) addDeclKind(DK); 1770ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner } 1781bb19638f2ec0d63ed131b51ca8d9542d1a9afeeSam Bishop 1790ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner virtual ~Decl(); 1801bb19638f2ec0d63ed131b51ca8d9542d1a9afeeSam Bishop 1814afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// setDeclContext - Set both the semantic and lexical DeclContext 1824afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// to DC. 1834afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor void setDeclContext(DeclContext *DC); 1844afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor 1851bb19638f2ec0d63ed131b51ca8d9542d1a9afeeSam Bishoppublic: 1860ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner SourceLocation getLocation() const { return Loc; } 1870ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner void setLocation(SourceLocation L) { Loc = L; } 1880ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 1890ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner Kind getKind() const { return DeclKind; } 1900ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner const char *getDeclKindName() const; 1910ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 192244a67d911d08c3757a18ad666e4a268cf3ee285Chris Lattner Decl *getNextDeclInContext() { return NextDeclInContext; } 193244a67d911d08c3757a18ad666e4a268cf3ee285Chris Lattner const Decl *getNextDeclInContext() const { return NextDeclInContext; } 19496f4468b6b1bf69bb01c1207f716a3ffaeb4a8d3Chris Lattner 1954afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor DeclContext *getDeclContext() { 19610d8379676f32b493740a5509e2cd7f0d6433139Chris Lattner if (isInSemaDC()) 19710d8379676f32b493740a5509e2cd7f0d6433139Chris Lattner return getSemanticDC(); 19810d8379676f32b493740a5509e2cd7f0d6433139Chris Lattner return getMultipleDC()->SemanticDC; 1994afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor } 2000cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner const DeclContext *getDeclContext() const { 2010cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner return const_cast<Decl*>(this)->getDeclContext(); 2020cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner } 2030cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner 2041329c274628cc8c4e8ad472b41d1a78c8123f611Anders Carlsson void setAccess(AccessSpecifier AS) { 205b8547e800f9553a72c2f3635ae2371692bd4411aAnders Carlsson Access = AS; 2061329c274628cc8c4e8ad472b41d1a78c8123f611Anders Carlsson CheckAccessDeclContext(); 2071329c274628cc8c4e8ad472b41d1a78c8123f611Anders Carlsson } 2081329c274628cc8c4e8ad472b41d1a78c8123f611Anders Carlsson 2091329c274628cc8c4e8ad472b41d1a78c8123f611Anders Carlsson AccessSpecifier getAccess() const { 2101329c274628cc8c4e8ad472b41d1a78c8123f611Anders Carlsson CheckAccessDeclContext(); 2111329c274628cc8c4e8ad472b41d1a78c8123f611Anders Carlsson return AccessSpecifier(Access); 212b8547e800f9553a72c2f3635ae2371692bd4411aAnders Carlsson } 2134afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor 21476a642ff4fce7a0648c79a1f01324a8c3880e251Chris Lattner bool hasAttrs() const { return HasAttrs; } 2150ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner void addAttr(Attr *attr); 21681abbdd848aa02c30242bd22dcc6ffe024ae2957Chris Lattner const Attr *getAttrs() const { 21781abbdd848aa02c30242bd22dcc6ffe024ae2957Chris Lattner if (!HasAttrs) return 0; // common case, no attributes. 21881abbdd848aa02c30242bd22dcc6ffe024ae2957Chris Lattner return getAttrsImpl(); // Uncommon case, out of line hash lookup. 21981abbdd848aa02c30242bd22dcc6ffe024ae2957Chris Lattner } 220a212c56e9b7533bcc2d6be90efd52ad241bf894eChris Lattner void swapAttrs(Decl *D); 2219141bee299a05349924a34a7153d7064c9e0a107Nuno Lopes void invalidateAttrs(); 2220ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 2230ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner template<typename T> const T *getAttr() const { 2240ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner for (const Attr *attr = getAttrs(); attr; attr = attr->getNext()) 2250ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner if (const T *V = dyn_cast<T>(attr)) 2260ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner return V; 2270ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner return 0; 2280ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner } 2290ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 2300ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner /// setInvalidDecl - Indicates the Decl had a semantic error. This 2310ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner /// allows for graceful error recovery. 2320ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner void setInvalidDecl() { InvalidDecl = 1; } 2330ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner bool isInvalidDecl() const { return (bool) InvalidDecl; } 2346b3945f4bc757bdadd3e443180cf32c2cccb52a0Douglas Gregor 2356b3945f4bc757bdadd3e443180cf32c2cccb52a0Douglas Gregor /// isImplicit - Indicates whether the declaration was implicitly 2366b3945f4bc757bdadd3e443180cf32c2cccb52a0Douglas Gregor /// generated by the implementation. If false, this declaration 2376b3945f4bc757bdadd3e443180cf32c2cccb52a0Douglas Gregor /// was written explicitly in the source code. 2386b3945f4bc757bdadd3e443180cf32c2cccb52a0Douglas Gregor bool isImplicit() const { return Implicit; } 2396b3945f4bc757bdadd3e443180cf32c2cccb52a0Douglas Gregor void setImplicit(bool I = true) { Implicit = I; } 2400ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 241cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor unsigned getIdentifierNamespace() const { 242769dbdf467681f6020ff248b969c2d41a4fdccd3Chris Lattner return IdentifierNamespace; 2430ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner } 244d62fdc448b3ace606c8c9c9f13e43218fa204dbfChris Lattner bool isInIdentifierNamespace(unsigned NS) const { 245d62fdc448b3ace606c8c9c9f13e43218fa204dbfChris Lattner return getIdentifierNamespace() & NS; 246d62fdc448b3ace606c8c9c9f13e43218fa204dbfChris Lattner } 247769dbdf467681f6020ff248b969c2d41a4fdccd3Chris Lattner static unsigned getIdentifierNamespaceForKind(Kind DK); 248769dbdf467681f6020ff248b969c2d41a4fdccd3Chris Lattner 249d62fdc448b3ace606c8c9c9f13e43218fa204dbfChris Lattner 2504afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// getLexicalDeclContext - The declaration context where this Decl was 2514afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// lexically declared (LexicalDC). May be different from 2524afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// getDeclContext() (SemanticDC). 2534afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// e.g.: 2544afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// 2554afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// namespace A { 2564afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// void f(); // SemanticDC == LexicalDC == 'namespace A' 2574afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// } 2584afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// void A::f(); // SemanticDC == namespace 'A' 2594afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// // LexicalDC == global namespace 26010d8379676f32b493740a5509e2cd7f0d6433139Chris Lattner DeclContext *getLexicalDeclContext() { 2614afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor if (isInSemaDC()) 26210d8379676f32b493740a5509e2cd7f0d6433139Chris Lattner return getSemanticDC(); 2634afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor return getMultipleDC()->LexicalDC; 2644afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor } 26510d8379676f32b493740a5509e2cd7f0d6433139Chris Lattner const DeclContext *getLexicalDeclContext() const { 26610d8379676f32b493740a5509e2cd7f0d6433139Chris Lattner return const_cast<Decl*>(this)->getLexicalDeclContext(); 2674afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor } 26810d8379676f32b493740a5509e2cd7f0d6433139Chris Lattner 2694afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor void setLexicalDeclContext(DeclContext *DC); 2704afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor 2714afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor // isDefinedOutsideFunctionOrMethod - This predicate returns true if this 2724afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor // scoped decl is defined outside the current function or method. This is 2734afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor // roughly global variables and functions, but also handles enums (which could 2744afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor // be defined inside or outside a function etc). 2754afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor bool isDefinedOutsideFunctionOrMethod() const; 2764afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor 27769c8f0aab655257e9e532d9d53756acf4f7a2d78Ted Kremenek // getBody - If this Decl represents a declaration for a body of code, 278792481eec23d8c1aa92173be589e2ae9d02514a5Ted Kremenek // such as a function or method definition, this method returns the top-level 27969c8f0aab655257e9e532d9d53756acf4f7a2d78Ted Kremenek // Stmt* of that body. Otherwise this method returns null. 280eaab20669b6a9910a5deb0110fdd8f7581d86a36Ted Kremenek virtual CompoundStmt* getBody() const { return 0; } 281792481eec23d8c1aa92173be589e2ae9d02514a5Ted Kremenek 2820ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner // global temp stats (until we have a per-module visitor) 2830ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner static void addDeclKind(Kind k); 2840ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner static bool CollectingStats(bool Enable = false); 2850ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner static void PrintStats(); 2860ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 287f57172b24f08a68d179675989813d5479dc87829Douglas Gregor /// isTemplateParameter - Determines whether this declartion is a 288f57172b24f08a68d179675989813d5479dc87829Douglas Gregor /// template parameter. 289f57172b24f08a68d179675989813d5479dc87829Douglas Gregor bool isTemplateParameter() const; 290f57172b24f08a68d179675989813d5479dc87829Douglas Gregor 2910ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner // Implement isa/cast/dyncast/etc. 2920ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner static bool classof(const Decl *) { return true; } 29342220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis static DeclContext *castToDeclContext(const Decl *); 29442220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis static Decl *castFromDeclContext(const DeclContext *); 2950ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 2960ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner /// Emit - Serialize this Decl to Bitcode. 2970ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner void Emit(llvm::Serializer& S) const; 2980ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 2990ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner /// Create - Deserialize a Decl from Bitcode. 300e2563ca02a519c2ad6d64dfed87d6e86c5d3c072Sam Bishop static Decl* Create(llvm::Deserializer& D, ASTContext& C); 3010ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 302bb45c512e0dfbe96bfe377ac642e726c0ba0affaSam Bishop /// Destroy - Call destructors and release memory. 30327f8a28bee33bb0e857cfe1a61c281bbc234b338Ted Kremenek virtual void Destroy(ASTContext& C); 304bb45c512e0dfbe96bfe377ac642e726c0ba0affaSam Bishop 3050ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattnerprotected: 3060ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner /// EmitImpl - Provides the subclass-specific serialization logic for 3070ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner /// serializing out a decl. 3080ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner virtual void EmitImpl(llvm::Serializer& S) const { 3090ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner // FIXME: This will eventually be a pure virtual function. 3100ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner assert (false && "Not implemented."); 3110ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner } 31281abbdd848aa02c30242bd22dcc6ffe024ae2957Chris Lattnerprivate: 31381abbdd848aa02c30242bd22dcc6ffe024ae2957Chris Lattner const Attr *getAttrsImpl() const; 31481abbdd848aa02c30242bd22dcc6ffe024ae2957Chris Lattner 3150ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner}; 3160ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 31749f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattner/// PrettyStackTraceDecl - If a crash occurs, indicate that it happened when 31849f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattner/// doing something to a specific decl. 31949f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattnerclass PrettyStackTraceDecl : public llvm::PrettyStackTraceEntry { 32049f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattner Decl *TheDecl; 32149f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattner SourceLocation Loc; 32249f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattner SourceManager &SM; 32349f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattner const char *Message; 32449f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattnerpublic: 32549f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattner PrettyStackTraceDecl(Decl *theDecl, SourceLocation L, 32649f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattner SourceManager &sm, const char *Msg) 32749f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattner : TheDecl(theDecl), Loc(L), SM(sm), Message(Msg) {} 32849f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattner 32949f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattner virtual void print(llvm::raw_ostream &OS) const; 33049f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattner}; 33149f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattner 33249f28ca787d8db7cac3c8898334f70ea55374c98Chris Lattner 333b048c9835969c4f7fe06264748be18ed4b442116Chris Lattner/// DeclContext - This is used only as base class of specific decl types that 3341ad4dd78ec53c24ea9e752b216035d7aa666fe49Argyrios Kyrtzidis/// can act as declaration contexts. These decls are (only the top classes 3351ad4dd78ec53c24ea9e752b216035d7aa666fe49Argyrios Kyrtzidis/// that directly derive from DeclContext are mentioned, not their subclasses): 3360ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner/// 337ef177820100ab583b08fd3056e2a5a52ee4b1629Argyrios Kyrtzidis/// TranslationUnitDecl 3382d1c5d313cd0c229cc614e74baa4c5756a4b46f4Argyrios Kyrtzidis/// NamespaceDecl 3390ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner/// FunctionDecl 3401ad4dd78ec53c24ea9e752b216035d7aa666fe49Argyrios Kyrtzidis/// TagDecl 341d3bb44f0f1a83cb208d3e61ee80afe6a4d20d2d8Argyrios Kyrtzidis/// ObjCMethodDecl 3421ad4dd78ec53c24ea9e752b216035d7aa666fe49Argyrios Kyrtzidis/// ObjCContainerDecl 3431ad4dd78ec53c24ea9e752b216035d7aa666fe49Argyrios Kyrtzidis/// ObjCCategoryImplDecl 3441ad4dd78ec53c24ea9e752b216035d7aa666fe49Argyrios Kyrtzidis/// ObjCImplementationDecl 345074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor/// LinkageSpecDecl 34656ee6896f2efebffb4a2cce5a7610cdf1eddbbbeSteve Naroff/// BlockDecl 3471ad4dd78ec53c24ea9e752b216035d7aa666fe49Argyrios Kyrtzidis/// 348b048c9835969c4f7fe06264748be18ed4b442116Chris Lattnerclass DeclContext { 3490ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner /// DeclKind - This indicates which class this is. 3500ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner Decl::Kind DeclKind : 8; 3510ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 352c36c540c5bfce941f3d892919394d092491211f2Douglas Gregor /// \brief Pointer to the data structure used to lookup declarations 353c36c540c5bfce941f3d892919394d092491211f2Douglas Gregor /// within this context, which is a DenseMap<DeclarationName, 354c36c540c5bfce941f3d892919394d092491211f2Douglas Gregor /// StoredDeclsList>. 355c36c540c5bfce941f3d892919394d092491211f2Douglas Gregor void* LookupPtr; 35644b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor 3576037fcba3431b47de1a994c9b286feac17894effDouglas Gregor /// FirstDecl - The first declaration stored within this declaration 3586037fcba3431b47de1a994c9b286feac17894effDouglas Gregor /// context. 3594afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor Decl *FirstDecl; 3606037fcba3431b47de1a994c9b286feac17894effDouglas Gregor 3616037fcba3431b47de1a994c9b286feac17894effDouglas Gregor /// LastDecl - The last declaration stored within this declaration 3626037fcba3431b47de1a994c9b286feac17894effDouglas Gregor /// context. FIXME: We could probably cache this value somewhere 3636037fcba3431b47de1a994c9b286feac17894effDouglas Gregor /// outside of the DeclContext, to reduce the size of DeclContext by 3646037fcba3431b47de1a994c9b286feac17894effDouglas Gregor /// another pointer. 3654afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor Decl *LastDecl; 3667643536c36b0449256d5ee2efc03a7e4a784a0b3Argyrios Kyrtzidis 3670ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattnerprotected: 3686037fcba3431b47de1a994c9b286feac17894effDouglas Gregor DeclContext(Decl::Kind K) 369c36c540c5bfce941f3d892919394d092491211f2Douglas Gregor : DeclKind(K), LookupPtr(0), FirstDecl(0), LastDecl(0) { } 37044b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor 37144b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor void DestroyDecls(ASTContext &C); 3720ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 3730ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattnerpublic: 37444b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor ~DeclContext(); 37544b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor 3769b9ca01ff3136a7539dc08a4c4e1a3dd8c8d3a7dArgyrios Kyrtzidis Decl::Kind getDeclKind() const { 3779b9ca01ff3136a7539dc08a4c4e1a3dd8c8d3a7dArgyrios Kyrtzidis return DeclKind; 3789b9ca01ff3136a7539dc08a4c4e1a3dd8c8d3a7dArgyrios Kyrtzidis } 3790a4739305a984ef9b821cedad5f4fe235eb6ef7dSteve Naroff const char *getDeclKindName() const; 3809b9ca01ff3136a7539dc08a4c4e1a3dd8c8d3a7dArgyrios Kyrtzidis 381305ec42f971a2b3e114eb35256c23e955c497a1cArgyrios Kyrtzidis /// getParent - Returns the containing DeclContext. 3820cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner DeclContext *getParent() { 383305ec42f971a2b3e114eb35256c23e955c497a1cArgyrios Kyrtzidis return cast<Decl>(this)->getDeclContext(); 384305ec42f971a2b3e114eb35256c23e955c497a1cArgyrios Kyrtzidis } 3850cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner const DeclContext *getParent() const { 3860cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner return const_cast<DeclContext*>(this)->getParent(); 387d2595ecce5f8350e485c83bfe767549a522b2802Argyrios Kyrtzidis } 3880cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner 38977407b802130b1c44b1f63b855722a5376f57bcaArgyrios Kyrtzidis /// getLexicalParent - Returns the containing lexical DeclContext. May be 39044b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// different from getParent, e.g.: 39144b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// 39244b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// namespace A { 39344b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// struct S; 39444b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// } 39544b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// struct A::S {}; // getParent() == namespace 'A' 39677407b802130b1c44b1f63b855722a5376f57bcaArgyrios Kyrtzidis /// // getLexicalParent() == translation unit 39777407b802130b1c44b1f63b855722a5376f57bcaArgyrios Kyrtzidis /// 39877407b802130b1c44b1f63b855722a5376f57bcaArgyrios Kyrtzidis DeclContext *getLexicalParent() { 3990cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner return cast<Decl>(this)->getLexicalDeclContext(); 40077407b802130b1c44b1f63b855722a5376f57bcaArgyrios Kyrtzidis } 4010cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner const DeclContext *getLexicalParent() const { 4020cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner return const_cast<DeclContext*>(this)->getLexicalParent(); 4030cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner } 4040cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner 4050ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner bool isFunctionOrMethod() const { 4060ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner switch (DeclKind) { 4070cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner case Decl::Block: 4080cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner case Decl::ObjCMethod: 4090cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner return true; 4100cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner default: 4110cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner return DeclKind >= Decl::FunctionFirst && DeclKind <= Decl::FunctionLast; 4120ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner } 4130ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner } 4140ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 415ef6e647b8d3268a765c2c4dd7f8a73cad281a8e6Argyrios Kyrtzidis bool isFileContext() const { 416ef6e647b8d3268a765c2c4dd7f8a73cad281a8e6Argyrios Kyrtzidis return DeclKind == Decl::TranslationUnit || DeclKind == Decl::Namespace; 417ef6e647b8d3268a765c2c4dd7f8a73cad281a8e6Argyrios Kyrtzidis } 418ef6e647b8d3268a765c2c4dd7f8a73cad281a8e6Argyrios Kyrtzidis 4195f2bfd4811996abb783aa6c7254c56baa6930e8cDouglas Gregor bool isTranslationUnit() const { 4205f2bfd4811996abb783aa6c7254c56baa6930e8cDouglas Gregor return DeclKind == Decl::TranslationUnit; 4215f2bfd4811996abb783aa6c7254c56baa6930e8cDouglas Gregor } 4225f2bfd4811996abb783aa6c7254c56baa6930e8cDouglas Gregor 423bcbffc46f1ad3796c4582fa1e3a9113b5aa26061Douglas Gregor bool isRecord() const { 42465100792a69a16895bd80f1d639b99e7ad903386Douglas Gregor return DeclKind >= Decl::RecordFirst && DeclKind <= Decl::RecordLast; 425c7ed9c60b8ee04b119e23441cae2cfec74536ba9Argyrios Kyrtzidis } 426c7ed9c60b8ee04b119e23441cae2cfec74536ba9Argyrios Kyrtzidis 42744b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor bool isNamespace() const { 42844b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor return DeclKind == Decl::Namespace; 42944b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor } 43044b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor 431074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor /// isTransparentContext - Determines whether this context is a 432074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor /// "transparent" context, meaning that the members declared in this 433074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor /// context are semantically declared in the nearest enclosing 434074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor /// non-transparent (opaque) context but are lexically declared in 435074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor /// this context. For example, consider the enumerators of an 436074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor /// enumeration type: 437074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor /// @code 438074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor /// enum E { 439074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor /// Val1 440074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor /// }; 441074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor /// @endcode 442074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor /// Here, E is a transparent context, so its enumerator (Val1) will 443074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor /// appear (semantically) that it is in the same context of E. 444074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor /// Examples of transparent contexts include: enumerations (except for 445074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor /// C++0x scoped enums), C++ linkage specifications, and C++0x 446074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor /// inline namespaces. 447074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor bool isTransparentContext() const; 448074149e11baf5f7db12f84efd5c34ba6e35d5cdfDouglas Gregor 449ef6e647b8d3268a765c2c4dd7f8a73cad281a8e6Argyrios Kyrtzidis bool Encloses(DeclContext *DC) const { 450ef6e647b8d3268a765c2c4dd7f8a73cad281a8e6Argyrios Kyrtzidis for (; DC; DC = DC->getParent()) 451ef6e647b8d3268a765c2c4dd7f8a73cad281a8e6Argyrios Kyrtzidis if (DC == this) 452ef6e647b8d3268a765c2c4dd7f8a73cad281a8e6Argyrios Kyrtzidis return true; 453ef6e647b8d3268a765c2c4dd7f8a73cad281a8e6Argyrios Kyrtzidis return false; 454ef6e647b8d3268a765c2c4dd7f8a73cad281a8e6Argyrios Kyrtzidis } 455ef6e647b8d3268a765c2c4dd7f8a73cad281a8e6Argyrios Kyrtzidis 45644b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// getPrimaryContext - There may be many different 45744b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// declarations of the same entity (including forward declarations 45844b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// of classes, multiple definitions of namespaces, etc.), each with 45944b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// a different set of declarations. This routine returns the 46044b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// "primary" DeclContext structure, which will contain the 46144b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// information needed to perform name lookup into this context. 4620701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff DeclContext *getPrimaryContext(); 46344b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor 464ce35607c282c845b3285d0f6e106489d8bbeba13Douglas Gregor /// getLookupContext - Retrieve the innermost non-transparent 465ce35607c282c845b3285d0f6e106489d8bbeba13Douglas Gregor /// context of this context, which corresponds to the innermost 466ce35607c282c845b3285d0f6e106489d8bbeba13Douglas Gregor /// location from which name lookup can find the entities in this 467ce35607c282c845b3285d0f6e106489d8bbeba13Douglas Gregor /// context. 4680cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner DeclContext *getLookupContext(); 4690cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner const DeclContext *getLookupContext() const { 4700cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner return const_cast<DeclContext *>(this)->getLookupContext(); 47117a9b9e3ee75f5dbb4819cc8ebf40eec8015f84aDouglas Gregor } 4720cf2b1990c82121d03a004dafe498ba43bf4b42aChris Lattner 47388b7094185b9d4fe9820c731b6936d8d37f6143eDouglas Gregor /// \brief Retrieve the nearest enclosing namespace context. 47488b7094185b9d4fe9820c731b6936d8d37f6143eDouglas Gregor DeclContext *getEnclosingNamespaceContext(); 47588b7094185b9d4fe9820c731b6936d8d37f6143eDouglas Gregor const DeclContext *getEnclosingNamespaceContext() const { 47688b7094185b9d4fe9820c731b6936d8d37f6143eDouglas Gregor return const_cast<DeclContext *>(this)->getEnclosingNamespaceContext(); 47788b7094185b9d4fe9820c731b6936d8d37f6143eDouglas Gregor } 47888b7094185b9d4fe9820c731b6936d8d37f6143eDouglas Gregor 47944b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// getNextContext - If this is a DeclContext that may have other 48044b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// DeclContexts that are semantically connected but syntactically 48144b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// different, such as C++ namespaces, this routine retrieves the 48244b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// next DeclContext in the link. Iteration through the chain of 48344b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// DeclContexts should begin at the primary DeclContext and 48444b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// continue until this function returns NULL. For example, given: 48544b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// @code 48644b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// namespace N { 48744b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// int x; 48844b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// } 48944b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// namespace N { 49044b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// int y; 49144b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// } 49244b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// @endcode 49344b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// The first occurrence of namespace N will be the primary 49444b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// DeclContext. Its getNextContext will return the second 49544b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// occurrence of namespace N. 49644b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor DeclContext *getNextContext(); 49744b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor 49844b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// decl_iterator - Iterates through the declarations stored 49944b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// within this context. 5006037fcba3431b47de1a994c9b286feac17894effDouglas Gregor class decl_iterator { 5016037fcba3431b47de1a994c9b286feac17894effDouglas Gregor /// Current - The current declaration. 5024afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor Decl *Current; 5036037fcba3431b47de1a994c9b286feac17894effDouglas Gregor 5046037fcba3431b47de1a994c9b286feac17894effDouglas Gregor public: 5054afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor typedef Decl* value_type; 5064afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor typedef Decl* reference; 5074afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor typedef Decl* pointer; 5086037fcba3431b47de1a994c9b286feac17894effDouglas Gregor typedef std::forward_iterator_tag iterator_category; 5096037fcba3431b47de1a994c9b286feac17894effDouglas Gregor typedef std::ptrdiff_t difference_type; 5106037fcba3431b47de1a994c9b286feac17894effDouglas Gregor 5116037fcba3431b47de1a994c9b286feac17894effDouglas Gregor decl_iterator() : Current(0) { } 5124afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor explicit decl_iterator(Decl *C) : Current(C) { } 5136037fcba3431b47de1a994c9b286feac17894effDouglas Gregor 5146037fcba3431b47de1a994c9b286feac17894effDouglas Gregor reference operator*() const { return Current; } 5156037fcba3431b47de1a994c9b286feac17894effDouglas Gregor pointer operator->() const { return Current; } 5166037fcba3431b47de1a994c9b286feac17894effDouglas Gregor 51796f4468b6b1bf69bb01c1207f716a3ffaeb4a8d3Chris Lattner decl_iterator& operator++() { 518244a67d911d08c3757a18ad666e4a268cf3ee285Chris Lattner Current = Current->getNextDeclInContext(); 51996f4468b6b1bf69bb01c1207f716a3ffaeb4a8d3Chris Lattner return *this; 52096f4468b6b1bf69bb01c1207f716a3ffaeb4a8d3Chris Lattner } 5216037fcba3431b47de1a994c9b286feac17894effDouglas Gregor 5226037fcba3431b47de1a994c9b286feac17894effDouglas Gregor decl_iterator operator++(int) { 5236037fcba3431b47de1a994c9b286feac17894effDouglas Gregor decl_iterator tmp(*this); 5246037fcba3431b47de1a994c9b286feac17894effDouglas Gregor ++(*this); 5256037fcba3431b47de1a994c9b286feac17894effDouglas Gregor return tmp; 5266037fcba3431b47de1a994c9b286feac17894effDouglas Gregor } 5276037fcba3431b47de1a994c9b286feac17894effDouglas Gregor 5286037fcba3431b47de1a994c9b286feac17894effDouglas Gregor friend bool operator==(decl_iterator x, decl_iterator y) { 5296037fcba3431b47de1a994c9b286feac17894effDouglas Gregor return x.Current == y.Current; 5306037fcba3431b47de1a994c9b286feac17894effDouglas Gregor } 5316037fcba3431b47de1a994c9b286feac17894effDouglas Gregor friend bool operator!=(decl_iterator x, decl_iterator y) { 5326037fcba3431b47de1a994c9b286feac17894effDouglas Gregor return x.Current != y.Current; 5336037fcba3431b47de1a994c9b286feac17894effDouglas Gregor } 5346037fcba3431b47de1a994c9b286feac17894effDouglas Gregor }; 53544b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor 53644b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// decls_begin/decls_end - Iterate over the declarations stored in 53744b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// this context. 5386037fcba3431b47de1a994c9b286feac17894effDouglas Gregor decl_iterator decls_begin() const { return decl_iterator(FirstDecl); } 5396037fcba3431b47de1a994c9b286feac17894effDouglas Gregor decl_iterator decls_end() const { return decl_iterator(); } 54044b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor 541f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor /// specific_decl_iterator - Iterates over a subrange of 542f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor /// declarations stored in a DeclContext, providing only those that 543669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// are of type SpecificDecl (or a class derived from it). This 544f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor /// iterator is used, for example, to provide iteration over just 545669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// the fields within a RecordDecl (with SpecificDecl = FieldDecl). 546f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor template<typename SpecificDecl> 547f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor class specific_decl_iterator { 548f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor /// Current - The current, underlying declaration iterator, which 549d6f0b4e97e681ea5d165125960f34b3b8c19e1dcDouglas Gregor /// will either be NULL or will point to a declaration of 550f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor /// type SpecificDecl. 551f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor DeclContext::decl_iterator Current; 552f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor 553f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor /// SkipToNextDecl - Advances the current position up to the next 554f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor /// declaration of type SpecificDecl that also meets the criteria 555f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor /// required by Acceptable. 556f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor void SkipToNextDecl() { 557669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor while (*Current && !isa<SpecificDecl>(*Current)) 558f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor ++Current; 559f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor } 560f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor 561f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor public: 562f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor typedef SpecificDecl* value_type; 563f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor typedef SpecificDecl* reference; 564f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor typedef SpecificDecl* pointer; 565f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor typedef std::iterator_traits<DeclContext::decl_iterator>::difference_type 566f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor difference_type; 567f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor typedef std::forward_iterator_tag iterator_category; 568f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor 569669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor specific_decl_iterator() : Current() { } 570f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor 571f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor /// specific_decl_iterator - Construct a new iterator over a 572d6f0b4e97e681ea5d165125960f34b3b8c19e1dcDouglas Gregor /// subset of the declarations the range [C, 573d6f0b4e97e681ea5d165125960f34b3b8c19e1dcDouglas Gregor /// end-of-declarations). If A is non-NULL, it is a pointer to a 574d6f0b4e97e681ea5d165125960f34b3b8c19e1dcDouglas Gregor /// member function of SpecificDecl that should return true for 575d6f0b4e97e681ea5d165125960f34b3b8c19e1dcDouglas Gregor /// all of the SpecificDecl instances that will be in the subset 576d6f0b4e97e681ea5d165125960f34b3b8c19e1dcDouglas Gregor /// of iterators. For example, if you want Objective-C instance 577d6f0b4e97e681ea5d165125960f34b3b8c19e1dcDouglas Gregor /// methods, SpecificDecl will be ObjCMethodDecl and A will be 578d6f0b4e97e681ea5d165125960f34b3b8c19e1dcDouglas Gregor /// &ObjCMethodDecl::isInstanceMethod. 579669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor explicit specific_decl_iterator(DeclContext::decl_iterator C) : Current(C) { 580f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor SkipToNextDecl(); 581f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor } 582f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor 5836037fcba3431b47de1a994c9b286feac17894effDouglas Gregor reference operator*() const { return cast<SpecificDecl>(*Current); } 5846037fcba3431b47de1a994c9b286feac17894effDouglas Gregor pointer operator->() const { return cast<SpecificDecl>(*Current); } 585f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor 586f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor specific_decl_iterator& operator++() { 587f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor ++Current; 588f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor SkipToNextDecl(); 589f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor return *this; 590f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor } 591f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor 592f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor specific_decl_iterator operator++(int) { 593f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor specific_decl_iterator tmp(*this); 594f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor ++(*this); 595f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor return tmp; 596f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor } 597f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor 598f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor friend bool 599f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor operator==(const specific_decl_iterator& x, const specific_decl_iterator& y) { 600f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor return x.Current == y.Current; 601f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor } 602f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor 603f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor friend bool 604f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor operator!=(const specific_decl_iterator& x, const specific_decl_iterator& y) { 605f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor return x.Current != y.Current; 606f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor } 607f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor }; 608f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor 609669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// \brief Iterates over a filtered subrange of declarations stored 610669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// in a DeclContext. 611669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// 612669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// This iterator visits only those declarations that are of type 613669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// SpecificDecl (or a class derived from it) and that meet some 614669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// additional run-time criteria. This iterator is used, for 615669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// example, to provide access to the instance methods within an 616669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// Objective-C interface (with SpecificDecl = ObjCMethodDecl and 617669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// Acceptable = ObjCMethodDecl::isInstanceMethod). 618669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor template<typename SpecificDecl, bool (SpecificDecl::*Acceptable)() const> 619669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor class filtered_decl_iterator { 620669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// Current - The current, underlying declaration iterator, which 621669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// will either be NULL or will point to a declaration of 622669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// type SpecificDecl. 623669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor DeclContext::decl_iterator Current; 624669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor 625669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// SkipToNextDecl - Advances the current position up to the next 626669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// declaration of type SpecificDecl that also meets the criteria 627669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// required by Acceptable. 628669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor void SkipToNextDecl() { 629669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor while (*Current && 630669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor (!isa<SpecificDecl>(*Current) || 631669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor (Acceptable && !(cast<SpecificDecl>(*Current)->*Acceptable)()))) 632669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor ++Current; 633669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor } 634669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor 635669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor public: 636669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor typedef SpecificDecl* value_type; 637669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor typedef SpecificDecl* reference; 638669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor typedef SpecificDecl* pointer; 639669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor typedef std::iterator_traits<DeclContext::decl_iterator>::difference_type 640669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor difference_type; 641669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor typedef std::forward_iterator_tag iterator_category; 642669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor 643669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor filtered_decl_iterator() : Current() { } 644669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor 645669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// specific_decl_iterator - Construct a new iterator over a 646669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// subset of the declarations the range [C, 647669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// end-of-declarations). If A is non-NULL, it is a pointer to a 648669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// member function of SpecificDecl that should return true for 649669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// all of the SpecificDecl instances that will be in the subset 650669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// of iterators. For example, if you want Objective-C instance 651669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// methods, SpecificDecl will be ObjCMethodDecl and A will be 652669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor /// &ObjCMethodDecl::isInstanceMethod. 653669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor explicit filtered_decl_iterator(DeclContext::decl_iterator C) : Current(C) { 654669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor SkipToNextDecl(); 655669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor } 656669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor 657669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor reference operator*() const { return cast<SpecificDecl>(*Current); } 658669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor pointer operator->() const { return cast<SpecificDecl>(*Current); } 659669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor 660669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor filtered_decl_iterator& operator++() { 661669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor ++Current; 662669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor SkipToNextDecl(); 663669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor return *this; 664669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor } 665669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor 666669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor filtered_decl_iterator operator++(int) { 667669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor filtered_decl_iterator tmp(*this); 668669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor ++(*this); 669669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor return tmp; 670669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor } 671669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor 672669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor friend bool 673669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor operator==(const filtered_decl_iterator& x, const filtered_decl_iterator& y) { 674669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor return x.Current == y.Current; 675669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor } 676669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor 677669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor friend bool 678669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor operator!=(const filtered_decl_iterator& x, const filtered_decl_iterator& y) { 679669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor return x.Current != y.Current; 680669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor } 681669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor }; 682669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor 68340f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// @brief Add the declaration D into this context. 68440f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// 68540f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// This routine should be invoked when the declaration D has first 68640f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// been declared, to place D into the context where it was 68740f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// (lexically) defined. Every declaration must be added to one 68840f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// (and only one!) context, where it can be visited via 68940f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// [decls_begin(), decls_end()). Once a declaration has been added 69040f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// to its lexical context, the corresponding DeclContext owns the 69140f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// declaration. 69240f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// 69340f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// If D is also a NamedDecl, it will be made visible within its 69440f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// semantic context via makeDeclVisibleInContext. 6954afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor void addDecl(Decl *D); 69644b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor 69744b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// lookup_iterator - An iterator that provides access to the results 69844b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// of looking up a name within this context. 6994afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor typedef NamedDecl **lookup_iterator; 70044b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor 70144b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// lookup_const_iterator - An iterator that provides non-mutable 70244b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// access to the results of lookup up a name within this context. 7034afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor typedef NamedDecl * const * lookup_const_iterator; 70444b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor 70544b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor typedef std::pair<lookup_iterator, lookup_iterator> lookup_result; 70644b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor typedef std::pair<lookup_const_iterator, lookup_const_iterator> 70744b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor lookup_const_result; 70844b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor 70944b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// lookup - Find the declarations (if any) with the given Name in 71044b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor /// this context. Returns a range of iterators that contains all of 71140f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// the declarations with this name, with object, function, member, 71240f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// and enumerator names preceding any tag name. Note that this 71340f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// routine will not look into parent contexts. 7140701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff lookup_result lookup(DeclarationName Name); 7150701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff lookup_const_result lookup(DeclarationName Name) const; 71644b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor 71740f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// @brief Makes a declaration visible within this context. 71840f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// 71940f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// This routine makes the declaration D visible to name lookup 72040f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// within this context and, if this is a transparent context, 72140f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// within its parent contexts up to the first enclosing 72240f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// non-transparent context. Making a declaration visible within a 72340f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// context does not transfer ownership of a declaration, and a 72440f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// declaration can be visible in many contexts that aren't its 72540f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// lexical context. 72640f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// 72740f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// If D is a redeclaration of an existing declaration that is 72840f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// visible from this context, as determined by 72940f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// NamedDecl::declarationReplaces, the previous declaration will be 73040f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor /// replaced with D. 73140f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor void makeDeclVisibleInContext(NamedDecl *D); 7327643536c36b0449256d5ee2efc03a7e4a784a0b3Argyrios Kyrtzidis 7332a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregor /// udir_iterator - Iterates through the using-directives stored 7342a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregor /// within this context. 7352a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregor typedef UsingDirectiveDecl * const * udir_iterator; 7362a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregor 7372a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregor typedef std::pair<udir_iterator, udir_iterator> udir_iterator_range; 7382a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregor 7392a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregor udir_iterator_range getUsingDirectives() const; 7402a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregor 7412a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregor udir_iterator using_directives_begin() const { 7422a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregor return getUsingDirectives().first; 7432a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregor } 7442a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregor 7452a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregor udir_iterator using_directives_end() const { 7462a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregor return getUsingDirectives().second; 7472a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregor } 7482a3009a432bdcec59e6383d7b2b17494d6f91649Douglas Gregor 749c2ee10d79f70036af652a395ac1f8273f3d04e12Douglas Gregor // Low-level accessors 750c2ee10d79f70036af652a395ac1f8273f3d04e12Douglas Gregor 751c2ee10d79f70036af652a395ac1f8273f3d04e12Douglas Gregor /// \brief Retrieve the internal representation of the lookup structure. 752c36c540c5bfce941f3d892919394d092491211f2Douglas Gregor void* getLookupPtr() const { return LookupPtr; } 753c2ee10d79f70036af652a395ac1f8273f3d04e12Douglas Gregor 7543d7641e090cf113dec64306a1597d3e4523e2a55Argyrios Kyrtzidis static bool classof(const Decl *D); 755b048c9835969c4f7fe06264748be18ed4b442116Chris Lattner static bool classof(const DeclContext *D) { return true; } 75664650af7cc4352c6c67b9bd1bf8ef3ce7471b910Douglas Gregor#define DECL_CONTEXT(Name) \ 75764650af7cc4352c6c67b9bd1bf8ef3ce7471b910Douglas Gregor static bool classof(const Name##Decl *D) { return true; } 75864650af7cc4352c6c67b9bd1bf8ef3ce7471b910Douglas Gregor#include "clang/AST/DeclNodes.def" 7597643536c36b0449256d5ee2efc03a7e4a784a0b3Argyrios Kyrtzidis 7607643536c36b0449256d5ee2efc03a7e4a784a0b3Argyrios Kyrtzidisprivate: 76140f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor void buildLookup(DeclContext *DCtx); 76240f4e69002af9623a1f959bd57b99afda186a6a7Douglas Gregor void makeDeclVisibleInContextImpl(NamedDecl *D); 76344b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor 7647643536c36b0449256d5ee2efc03a7e4a784a0b3Argyrios Kyrtzidis void EmitOutRec(llvm::Serializer& S) const; 7657643536c36b0449256d5ee2efc03a7e4a784a0b3Argyrios Kyrtzidis void ReadOutRec(llvm::Deserializer& D, ASTContext& C); 7667643536c36b0449256d5ee2efc03a7e4a784a0b3Argyrios Kyrtzidis 7677643536c36b0449256d5ee2efc03a7e4a784a0b3Argyrios Kyrtzidis friend class Decl; 7680ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner}; 7690ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 770f57172b24f08a68d179675989813d5479dc87829Douglas Gregorinline bool Decl::isTemplateParameter() const { 771f57172b24f08a68d179675989813d5479dc87829Douglas Gregor return getKind() == TemplateTypeParm || getKind() == NonTypeTemplateParm; 772f57172b24f08a68d179675989813d5479dc87829Douglas Gregor} 773f57172b24f08a68d179675989813d5479dc87829Douglas Gregor 7744afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorinline bool Decl::isDefinedOutsideFunctionOrMethod() const { 7754afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor if (getDeclContext()) 7764afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor return !getDeclContext()->getLookupContext()->isFunctionOrMethod(); 77796f4468b6b1bf69bb01c1207f716a3ffaeb4a8d3Chris Lattner return true; 7784afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor} 7794afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor 7800ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner} // end clang. 7810ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 7820ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattnernamespace llvm { 7830ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 78442220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis/// Implement a isa_impl_wrap specialization to check whether a DeclContext is 78542220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis/// a specific Decl. 78642220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidistemplate<class ToTy> 78742220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidisstruct isa_impl_wrap<ToTy, 78842220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis const ::clang::DeclContext,const ::clang::DeclContext> { 78942220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis static bool doit(const ::clang::DeclContext &Val) { 79042220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis return ToTy::classof(::clang::Decl::castFromDeclContext(&Val)); 7910ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner } 7920ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner}; 79342220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidistemplate<class ToTy> 79442220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidisstruct isa_impl_wrap<ToTy, ::clang::DeclContext, ::clang::DeclContext> 79542220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis : public isa_impl_wrap<ToTy, 79642220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis const ::clang::DeclContext,const ::clang::DeclContext> {}; 7970ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 79842220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis/// Implement cast_convert_val for Decl -> DeclContext conversions. 7990ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattnertemplate<class FromTy> 80042220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidisstruct cast_convert_val< ::clang::DeclContext, FromTy, FromTy> { 801b048c9835969c4f7fe06264748be18ed4b442116Chris Lattner static ::clang::DeclContext &doit(const FromTy &Val) { 80242220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis return *FromTy::castToDeclContext(&Val); 8030ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner } 8040ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner}; 8050ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 8060ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattnertemplate<class FromTy> 80742220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidisstruct cast_convert_val< ::clang::DeclContext, FromTy*, FromTy*> { 808b048c9835969c4f7fe06264748be18ed4b442116Chris Lattner static ::clang::DeclContext *doit(const FromTy *Val) { 80942220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis return FromTy::castToDeclContext(Val); 8100ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner } 8110ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner}; 81242220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis 81344b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregortemplate<class FromTy> 81444b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregorstruct cast_convert_val< const ::clang::DeclContext, FromTy, FromTy> { 81544b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor static const ::clang::DeclContext &doit(const FromTy &Val) { 81644b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor return *FromTy::castToDeclContext(&Val); 81744b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor } 81844b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor}; 81944b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor 82044b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregortemplate<class FromTy> 82144b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregorstruct cast_convert_val< const ::clang::DeclContext, FromTy*, FromTy*> { 82244b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor static const ::clang::DeclContext *doit(const FromTy *Val) { 82344b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor return FromTy::castToDeclContext(Val); 82444b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor } 82544b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor}; 82644b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor 82742220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis/// Implement cast_convert_val for DeclContext -> Decl conversions. 82842220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidistemplate<class ToTy> 82942220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidisstruct cast_convert_val<ToTy, 83042220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis const ::clang::DeclContext,const ::clang::DeclContext> { 83142220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis static ToTy &doit(const ::clang::DeclContext &Val) { 83242220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis return *reinterpret_cast<ToTy*>(ToTy::castFromDeclContext(&Val)); 83342220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis } 83442220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis}; 83542220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidistemplate<class ToTy> 83642220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidisstruct cast_convert_val<ToTy, ::clang::DeclContext, ::clang::DeclContext> 83742220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis : public cast_convert_val<ToTy, 83842220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis const ::clang::DeclContext,const ::clang::DeclContext> {}; 83942220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis 84042220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidistemplate<class ToTy> 84142220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidisstruct cast_convert_val<ToTy, 84242220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis const ::clang::DeclContext*, const ::clang::DeclContext*> { 84342220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis static ToTy *doit(const ::clang::DeclContext *Val) { 84442220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis return reinterpret_cast<ToTy*>(ToTy::castFromDeclContext(Val)); 84542220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis } 84642220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis}; 84742220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidistemplate<class ToTy> 84842220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidisstruct cast_convert_val<ToTy, ::clang::DeclContext*, ::clang::DeclContext*> 84942220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis : public cast_convert_val<ToTy, 85042220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis const ::clang::DeclContext*,const ::clang::DeclContext*> {}; 8510ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 8520ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner} // end namespace llvm 8530ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner 8540ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner#endif 855