DeclObjC.h revision 6fb0aee4f9dc261bbec72e1283ad8dc0557a6d96
1980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//===--- DeclObjC.h - Classes for representing declarations -----*- C++ -*-===// 2980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff// 3980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff// The LLVM Compiler Infrastructure 4980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff// 50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source 60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details. 7980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff// 8980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//===----------------------------------------------------------------------===// 9980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff// 10980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff// This file defines the DeclObjC interface and subclasses. 11980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff// 12980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//===----------------------------------------------------------------------===// 13980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 14980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#ifndef LLVM_CLANG_AST_DECLOBJC_H 15980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#define LLVM_CLANG_AST_DECLOBJC_H 16980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 17980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#include "clang/AST/Decl.h" 186ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson#include "llvm/ADT/STLExtras.h" 19980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 20980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffnamespace clang { 21980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass Expr; 22980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass Stmt; 23980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass FunctionDecl; 24980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass AttributeList; 2560f8c868ffb346b78451a3eccaecd0461d2ae498Fariborz Jahanianclass RecordDecl; 26a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCIvarDecl; 27a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCMethodDecl; 28a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCProtocolDecl; 29a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCCategoryDecl; 30a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCPropertyDecl; 31f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanianclass ObjCPropertyImplDecl; 3268835718c4125f2f66740cd04de7088645ec695dChris Lattner 33793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerclass ObjCListBase { 34793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner void operator=(const ObjCListBase &); // DO NOT IMPLEMENT 35793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner ObjCListBase(const ObjCListBase&); // DO NOT IMPLEMENT 36793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerprotected: 37793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner /// List is an array of pointers to objects that are not owned by this object. 38793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner void **List; 393db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner unsigned NumElts; 40793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner 413db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattnerpublic: 42793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner ObjCListBase() : List(0), NumElts(0) {} 43793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner ~ObjCListBase() { 4488cf7a16902a9189d16653e1061cfda333187b58Chris Lattner assert(List == 0 && "Destroy should have been called before dtor"); 453db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner } 46793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner 4738af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void Destroy(ASTContext &Ctx); 48e881483a3bc22ffad62367501aa09ad8508fe363Chris Lattner 49793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner unsigned size() const { return NumElts; } 50793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner bool empty() const { return NumElts == 0; } 51793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner 52793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerprotected: 5338af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void set(void *const* InList, unsigned Elts, ASTContext &Ctx); 54793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner}; 553db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner 563db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner 57793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// ObjCList - This is a simple template class used to hold various lists of 58793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// decls etc, which is heavily used by the ObjC front-end. This only use case 59793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// this supports is setting the list all at once and then reading elements out 60793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// of it. 61793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnertemplate <typename T> 62793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerclass ObjCList : public ObjCListBase { 63793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerpublic: 6438af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void set(T* const* InList, unsigned Elts, ASTContext &Ctx) { 6538af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner ObjCListBase::set(reinterpret_cast<void*const*>(InList), Elts, Ctx); 66793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner } 67793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner 68793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner typedef T* const * iterator; 69793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner iterator begin() const { return (iterator)List; } 70793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner iterator end() const { return (iterator)List+NumElts; } 713db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner 72793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner T* operator[](unsigned Idx) const { 73793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner assert(Idx < NumElts && "Invalid access"); 74793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner return (T*)List[Idx]; 753db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner } 763db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner}; 773db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner 783db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner 7958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 80a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCMethodDecl - Represents an instance or class method declaration. 8158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// ObjC methods can be declared within 4 contexts: class interfaces, 8258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// categories, protocols, and class implementations. While C++ member 8358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// functions leverage C syntax, Objective-C method syntax is modeled after 8458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Smalltalk (using colons to specify argument types/expressions). 8558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Here are some brief examples: 8658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// 8758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Setter/getter instance methods: 8858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// - (void)setMenu:(NSMenu *)menu; 8958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// - (NSMenu *)menu; 9058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// 9158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Instance method that takes 2 NSView arguments: 9258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// - (void)replaceSubview:(NSView *)oldView with:(NSView *)newView; 9358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// 9458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Getter class method: 9558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// + (NSMenu *)defaultMenu; 9658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// 9758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// A selector represents a unique name for a method. The selector names for 9858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// the above methods are setMenu:, menu, replaceSubview:with:, and defaultMenu. 9958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// 1004afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCMethodDecl : public NamedDecl, public DeclContext { 10158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroffpublic: 10258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff enum ImplementationControl { None, Required, Optional }; 10358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroffprivate: 10458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff /// Bitfields must be first fields in this class so they pack with those 10558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff /// declared in class Decl. 10658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff /// instance (true) or class (false) method. 10758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff bool IsInstance : 1; 10858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff bool IsVariadic : 1; 10958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 1104607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian // Synthesized declaration method for a property setter/getter 1114607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian bool IsSynthesized : 1; 1124607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian 113ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek // NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum 11458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff /// @required/@optional 115ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek unsigned DeclImplementation : 2; 11658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 117ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek // NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum 11858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff /// in, inout, etc. 119ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek unsigned objcDeclQualifier : 6; 12058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 12158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff // Type of this method. 12258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff QualType MethodDeclType; 1232073216a1075767b5d25c23d1462b7034686d94dChris Lattner /// ParamInfo - List of pointers to VarDecls for the formal parameters of this 1242073216a1075767b5d25c23d1462b7034686d94dChris Lattner /// Method. 1252073216a1075767b5d25c23d1462b7034686d94dChris Lattner ObjCList<ParmVarDecl> ParamInfo; 12658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 12758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff /// List of attributes for this method declaration. 12858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff SourceLocation EndLoc; // the location of the ';' or '{'. 12958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 13058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff // The following are only used for method definitions, null otherwise. 13158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff // FIXME: space savings opportunity, consider a sub-class. 13258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff Stmt *Body; 133451318c08a6342c10b8986060386fd9274418437Daniel Dunbar 134451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// SelfDecl - Decl for the implicit self parameter. This is lazily 135451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// constructed by createImplicitParams. 1364111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner ImplicitParamDecl *SelfDecl; 137451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// CmdDecl - Decl for the implicit _cmd parameter. This is lazily 138451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// constructed by createImplicitParams. 1394111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner ImplicitParamDecl *CmdDecl; 1406c4ae5de0c356777446f823b573821fb95560d91Chris Lattner 141a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc, 14258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff Selector SelInfo, QualType T, 1430701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff DeclContext *contextDecl, 144f6414927e67e27d9324d8d179c5f7ea620443924Daniel Dunbar bool isInstance = true, 14558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff bool isVariadic = false, 1464607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian bool isSynthesized = false, 14758cce3b0dcbdcc95b7e713795834b4cb2c8a008aChris Lattner ImplementationControl impControl = None) 1484afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor : NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo), 149b048c9835969c4f7fe06264748be18ed4b442116Chris Lattner DeclContext(ObjCMethod), 15058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff IsInstance(isInstance), IsVariadic(isVariadic), 1514607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian IsSynthesized(isSynthesized), 15258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None), 1532e1cd4264d363ca869bf37ef160902f211d21b8cDouglas Gregor MethodDeclType(T), 1544111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner EndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) {} 1558a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek 1562073216a1075767b5d25c23d1462b7034686d94dChris Lattner virtual ~ObjCMethodDecl() {} 1571c8a413c1e00636c77666ddf1e3b0311f3fa8c81Ted Kremenek 1586c4ae5de0c356777446f823b573821fb95560d91Chris Lattnerpublic: 1598a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek 1608a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek /// Destroy - Call destructors and release memory. 1618a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek virtual void Destroy(ASTContext& C); 1626c4ae5de0c356777446f823b573821fb95560d91Chris Lattner 1630ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner static ObjCMethodDecl *Create(ASTContext &C, 1640ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner SourceLocation beginLoc, 1656c4ae5de0c356777446f823b573821fb95560d91Chris Lattner SourceLocation endLoc, Selector SelInfo, 1660701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff QualType T, DeclContext *contextDecl, 167f6414927e67e27d9324d8d179c5f7ea620443924Daniel Dunbar bool isInstance = true, 1686c4ae5de0c356777446f823b573821fb95560d91Chris Lattner bool isVariadic = false, 1694607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian bool isSynthesized = false, 170b06fa3b86951b9f179c99c3768331536c32e902dChris Lattner ImplementationControl impControl = None); 17158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 172ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek ObjCDeclQualifier getObjCDeclQualifier() const { 173ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek return ObjCDeclQualifier(objcDeclQualifier); 174ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek } 175a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek void setObjCDeclQualifier(ObjCDeclQualifier QV) { objcDeclQualifier = QV; } 17658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 17758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff // Location information, modeled after the Stmt API. 17858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff SourceLocation getLocStart() const { return getLocation(); } 17958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff SourceLocation getLocEnd() const { return EndLoc; } 18053c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setEndLoc(SourceLocation Loc) { EndLoc = Loc; } 1819776ba0d844cf9f6888e871e3fd246ae782f76f4Daniel Dunbar SourceRange getSourceRange() const { 1829776ba0d844cf9f6888e871e3fd246ae782f76f4Daniel Dunbar return SourceRange(getLocation(), EndLoc); 1839776ba0d844cf9f6888e871e3fd246ae782f76f4Daniel Dunbar } 1843e0a540b6d846178857289ec0eb8470a278d11a3Steve Naroff 1855619688510185081cbb4621d703daf7ee24cf39aChris Lattner ObjCInterfaceDecl *getClassInterface(); 1865619688510185081cbb4621d703daf7ee24cf39aChris Lattner const ObjCInterfaceDecl *getClassInterface() const { 1875619688510185081cbb4621d703daf7ee24cf39aChris Lattner return const_cast<ObjCMethodDecl*>(this)->getClassInterface(); 188e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner } 18958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 1902e1cd4264d363ca869bf37ef160902f211d21b8cDouglas Gregor Selector getSelector() const { return getDeclName().getObjCSelector(); } 191faf5e779d16bb4590f2a97e1c7ded255eddd90f3Fariborz Jahanian unsigned getSynthesizedMethodSize() const; 19258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff QualType getResultType() const { return MethodDeclType; } 19353c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setResultType(QualType T) { MethodDeclType = T; } 19458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 195d57f635d520e8cb5b93d3d770ff58db06c62de54Chris Lattner // Iterator access to formal parameters. 1962073216a1075767b5d25c23d1462b7034686d94dChris Lattner unsigned param_size() const { return ParamInfo.size(); } 1972073216a1075767b5d25c23d1462b7034686d94dChris Lattner typedef ObjCList<ParmVarDecl>::iterator param_iterator; 1982073216a1075767b5d25c23d1462b7034686d94dChris Lattner param_iterator param_begin() const { return ParamInfo.begin(); } 1992073216a1075767b5d25c23d1462b7034686d94dChris Lattner param_iterator param_end() const { return ParamInfo.end(); } 20089951a86b594513c2a013532ed45d197413b1087Chris Lattner 20153c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setMethodParams(ASTContext &C, ParmVarDecl *const *List, unsigned Num) { 20238af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner ParamInfo.set(List, Num, C); 2032073216a1075767b5d25c23d1462b7034686d94dChris Lattner } 2044111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner 2056ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson // Iterator access to parameter types. 2066ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson typedef std::const_mem_fun_t<QualType, ParmVarDecl> deref_fun; 2076ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson typedef llvm::mapped_iterator<param_iterator, deref_fun> arg_type_iterator; 2086ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson 2096ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson arg_type_iterator arg_type_begin() const { 2106ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson return llvm::map_iterator(param_begin(), deref_fun(&ParmVarDecl::getType)); 2116ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson } 2126ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson arg_type_iterator arg_type_end() const { 2136ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson return llvm::map_iterator(param_end(), deref_fun(&ParmVarDecl::getType)); 2146ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson } 2156ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson 216451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// createImplicitParams - Used to lazily create the self and cmd 217451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// implict parameters. This must be called prior to using getSelfDecl() 218451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// or getCmdDecl(). The call is ignored if the implicit paramters 219451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// have already been created. 220fef30b55230064d334a669a065a1c9acdb87cdfeFariborz Jahanian void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID); 221451318c08a6342c10b8986060386fd9274418437Daniel Dunbar 2224111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner ImplicitParamDecl * getSelfDecl() const { return SelfDecl; } 22353c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setSelfDecl(ImplicitParamDecl *SD) { SelfDecl = SD; } 2244111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner ImplicitParamDecl * getCmdDecl() const { return CmdDecl; } 22553c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setCmdDecl(ImplicitParamDecl *CD) { CmdDecl = CD; } 22658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 227f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor bool isInstanceMethod() const { return IsInstance; } 22853c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setInstanceMethod(bool isInst) { IsInstance = isInst; } 22958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff bool isVariadic() const { return IsVariadic; } 23053c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setVariadic(bool isVar) { IsVariadic = isVar; } 23158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 232f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor bool isClassMethod() const { return !IsInstance; } 233f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor 2344607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian bool isSynthesized() const { return IsSynthesized; } 23553c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setSynthesized(bool isSynth) { IsSynthesized = isSynth; } 2364607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian 23758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff // Related to protocols declared in @protocol 23858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff void setDeclImplementation(ImplementationControl ic) { 23958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff DeclImplementation = ic; 24058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff } 24158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff ImplementationControl getImplementationControl() const { 242ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek return ImplementationControl(DeclImplementation); 24358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff } 244792481eec23d8c1aa92173be589e2ae9d02514a5Ted Kremenek 2456fb0aee4f9dc261bbec72e1283ad8dc0557a6d96Argyrios Kyrtzidis virtual Stmt *getBody() const { 246d3a413d3b8eb39bcee5944bc545d9997c1abe492Sebastian Redl return (Stmt*) Body; 2477297134f128423fce2e88f92421ed135bded7d4eDouglas Gregor } 2486fb0aee4f9dc261bbec72e1283ad8dc0557a6d96Argyrios Kyrtzidis CompoundStmt *getCompoundBody() { return (CompoundStmt*)Body; } 249d3a413d3b8eb39bcee5944bc545d9997c1abe492Sebastian Redl void setBody(Stmt *B) { Body = B; } 25058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 25158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff // Implement isa/cast/dyncast/etc. 252a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const Decl *D) { return D->getKind() == ObjCMethod; } 253a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCMethodDecl *D) { return true; } 25442220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis static DeclContext *castToDeclContext(const ObjCMethodDecl *D) { 25542220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis return static_cast<DeclContext *>(const_cast<ObjCMethodDecl*>(D)); 25642220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis } 25742220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis static ObjCMethodDecl *castFromDeclContext(const DeclContext *DC) { 25842220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis return static_cast<ObjCMethodDecl *>(const_cast<DeclContext*>(DC)); 25942220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis } 26058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff}; 261e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 262f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor/// ObjCMethodList - a linked list of methods with different signatures. 263f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregorstruct ObjCMethodList { 264f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor ObjCMethodDecl *Method; 265f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor ObjCMethodList *Next; 266f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor 267f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor ObjCMethodList() { 268f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor Method = 0; 269f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor Next = 0; 270f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor } 271f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor ObjCMethodList(ObjCMethodDecl *M, ObjCMethodList *C) { 272f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor Method = M; 273f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor Next = C; 274f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor } 275f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor}; 276f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor 277e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff/// ObjCContainerDecl - Represents a container for method declarations. 278e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff/// Current sub-classes are ObjCInterfaceDecl, ObjCCategoryDecl, and 2790701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff/// ObjCProtocolDecl. 2800701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff/// FIXME: Use for ObjC implementation decls. 281e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff/// 2824afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCContainerDecl : public NamedDecl, public DeclContext { 283e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff SourceLocation AtEndLoc; // marks the end of the method container. 284e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroffpublic: 285e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 286d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor ObjCContainerDecl(Kind DK, DeclContext *DC, SourceLocation L, 287d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor IdentifierInfo *Id) 2884afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor : NamedDecl(DK, DC, L, Id), DeclContext(DK) {} 289e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 2900b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner virtual ~ObjCContainerDecl() {} 29109c4719788a5cea09897525e528fa00420f1677bSteve Naroff 29293983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff // Iterator access to properties. 29393983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff typedef specific_decl_iterator<ObjCPropertyDecl> prop_iterator; 2946ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor prop_iterator prop_begin(ASTContext &Context) const { 2956ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor return prop_iterator(decls_begin(Context)); 29693983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff } 2976ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor prop_iterator prop_end(ASTContext &Context) const { 2986ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor return prop_iterator(decls_end(Context)); 29909c4719788a5cea09897525e528fa00420f1677bSteve Naroff } 30009c4719788a5cea09897525e528fa00420f1677bSteve Naroff 3010701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff // Iterator access to instance/class methods. 302f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor typedef specific_decl_iterator<ObjCMethodDecl> method_iterator; 3036ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor method_iterator meth_begin(ASTContext &Context) const { 3046ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor return method_iterator(decls_begin(Context)); 3057ed4faca5162b3ab85be7f7e57aa40e6ec170971Ted Kremenek } 3066ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor method_iterator meth_end(ASTContext &Context) const { 3076ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor return method_iterator(decls_end(Context)); 3087ed4faca5162b3ab85be7f7e57aa40e6ec170971Ted Kremenek } 3090701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff 310669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor typedef filtered_decl_iterator<ObjCMethodDecl, 311669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor &ObjCMethodDecl::isInstanceMethod> 312669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor instmeth_iterator; 3136ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor instmeth_iterator instmeth_begin(ASTContext &Context) const { 3146ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor return instmeth_iterator(decls_begin(Context)); 315e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff } 3166ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor instmeth_iterator instmeth_end(ASTContext &Context) const { 3176ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor return instmeth_iterator(decls_end(Context)); 318e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff } 319e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 320669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor typedef filtered_decl_iterator<ObjCMethodDecl, 321669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor &ObjCMethodDecl::isClassMethod> 322669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor classmeth_iterator; 3236ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor classmeth_iterator classmeth_begin(ASTContext &Context) const { 3246ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor return classmeth_iterator(decls_begin(Context)); 325e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff } 3266ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor classmeth_iterator classmeth_end(ASTContext &Context) const { 3276ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor return classmeth_iterator(decls_end(Context)); 3280701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff } 3290701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff 3300701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff // Get the local instance/class method declared in this interface. 3316ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor ObjCMethodDecl *getInstanceMethod(ASTContext &Context, Selector Sel) const; 3326ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor ObjCMethodDecl *getClassMethod(ASTContext &Context, Selector Sel) const; 333496b5a894c5ec5425de53909f5aac3fb4771a2ecFariborz Jahanian ObjCIvarDecl *getIvarDecl(ASTContext &Context, IdentifierInfo *Id) const; 3346ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor 3356ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor ObjCMethodDecl * 3366ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor getMethod(ASTContext &Context, Selector Sel, bool isInstance) const { 3376ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor return isInstance ? getInstanceMethod(Context, Sel) 3386ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor : getClassMethod(Context, Sel); 33953df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner } 340b31cb7f1752ea011fd06ac9574ce24667d11cbdbFariborz Jahanian 3416ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor ObjCPropertyDecl *FindPropertyDeclaration(ASTContext &Context, 3426ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor IdentifierInfo *PropertyId) const; 34393983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff 344e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff // Marks the end of the container. 345e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff SourceLocation getAtEndLoc() const { return AtEndLoc; } 3460701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff void setAtEndLoc(SourceLocation L) { AtEndLoc = L; } 34709c4719788a5cea09897525e528fa00420f1677bSteve Naroff 34809c4719788a5cea09897525e528fa00420f1677bSteve Naroff // Implement isa/cast/dyncast/etc. 34909c4719788a5cea09897525e528fa00420f1677bSteve Naroff static bool classof(const Decl *D) { 35009c4719788a5cea09897525e528fa00420f1677bSteve Naroff return D->getKind() >= ObjCContainerFirst && 35109c4719788a5cea09897525e528fa00420f1677bSteve Naroff D->getKind() <= ObjCContainerLast; 35209c4719788a5cea09897525e528fa00420f1677bSteve Naroff } 35309c4719788a5cea09897525e528fa00420f1677bSteve Naroff static bool classof(const ObjCContainerDecl *D) { return true; } 35409c4719788a5cea09897525e528fa00420f1677bSteve Naroff 35509c4719788a5cea09897525e528fa00420f1677bSteve Naroff static DeclContext *castToDeclContext(const ObjCContainerDecl *D) { 35609c4719788a5cea09897525e528fa00420f1677bSteve Naroff return static_cast<DeclContext *>(const_cast<ObjCContainerDecl*>(D)); 35709c4719788a5cea09897525e528fa00420f1677bSteve Naroff } 35809c4719788a5cea09897525e528fa00420f1677bSteve Naroff static ObjCContainerDecl *castFromDeclContext(const DeclContext *DC) { 35909c4719788a5cea09897525e528fa00420f1677bSteve Naroff return static_cast<ObjCContainerDecl *>(const_cast<DeclContext*>(DC)); 36009c4719788a5cea09897525e528fa00420f1677bSteve Naroff } 361e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff}; 362e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 363a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCInterfaceDecl - Represents an ObjC class declaration. For example: 3640c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 3650c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// // MostPrimitive declares no super class (not particularly useful). 3660c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @interface MostPrimitive 3670c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// // no instance variables or methods. 3680c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end 3690c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 370fd5de471478a507dd2495c4ea9bcab801ea5fa65Chris Lattner/// // NSResponder inherits from NSObject & implements NSCoding (a protocol). 3710c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @interface NSResponder : NSObject <NSCoding> 372a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// { // instance variables are represented by ObjCIvarDecl. 3730c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id nextResponder; // nextResponder instance variable. 3740c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// } 3750c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSResponder *)nextResponder; // return a pointer to NSResponder. 3760c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (void)mouseMoved:(NSEvent *)theEvent; // return void, takes a pointer 3770c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end // to an NSEvent. 3780c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 3790c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Unlike C/C++, forward class declarations are accomplished with @class. 3800c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Unlike C/C++, @class allows for a list of classes to be forward declared. 3810c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Unlike C++, ObjC is a single-rooted class model. In Cocoa, classes 3820c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// typically inherit from NSObject (an exception is NSProxy). 3830c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 3840701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroffclass ObjCInterfaceDecl : public ObjCContainerDecl { 3853110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff /// TypeForDecl - This indicates the Type object that represents this 3863110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff /// TypeDecl. It is a cache maintained by ASTContext::getObjCInterfaceType 3873b3a45858c6b2a45114e91902c3bf3c4b7f5f302Daniel Dunbar mutable Type *TypeForDecl; 3883110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff friend class ASTContext; 389980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 390980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff /// Class's super class. 391a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *SuperClass; 392980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 393980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff /// Protocols referenced in interface header declaration 3943db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner ObjCList<ObjCProtocolDecl> ReferencedProtocols; 395980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 396e881483a3bc22ffad62367501aa09ad8508fe363Chris Lattner /// Instance variables in the interface. 397e881483a3bc22ffad62367501aa09ad8508fe363Chris Lattner ObjCList<ObjCIvarDecl> IVars; 398980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 399980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff /// List of categories defined for this class. 400a8ff9f455d94d9609766cfd5186b6e21dc2102f1Chris Lattner /// FIXME: Why is this a linked list?? 401a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCCategoryDecl *CategoryList; 40282a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian 4033a3ca1b35a7121aea0bf465a192dce748465e10fFariborz Jahanian bool ForwardDecl:1; // declared with @class. 4043a3ca1b35a7121aea0bf465a192dce748465e10fFariborz Jahanian bool InternalInterface:1; // true - no @interface for @implementation 40560fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff 406d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff SourceLocation ClassLoc; // location of the class identifier. 407d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff SourceLocation SuperClassLoc; // location of the super class identifier. 408f908a87299d278164540f90b5b6e6cab7b14fb41Steve Naroff SourceLocation EndLoc; // marks the '>', '}', or identifier. 4090e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattner 410d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor ObjCInterfaceDecl(DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, 4110b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner SourceLocation CLoc, bool FD, bool isInternal); 4128a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek 413e881483a3bc22ffad62367501aa09ad8508fe363Chris Lattner virtual ~ObjCInterfaceDecl() {} 4148a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek 4150e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattnerpublic: 4160e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattner 4178a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek /// Destroy - Call destructors and release memory. 4188a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek virtual void Destroy(ASTContext& C); 4198a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek 420d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCInterfaceDecl *Create(ASTContext &C, DeclContext *DC, 4210ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner SourceLocation atLoc, 422d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff IdentifierInfo *Id, 423d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff SourceLocation ClassLoc = SourceLocation(), 4240e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattner bool ForwardDecl = false, 4250e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattner bool isInternal = false); 4263db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner const ObjCList<ObjCProtocolDecl> &getReferencedProtocols() const { 4277ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian return ReferencedProtocols; 4287ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian } 429980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 430559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian ObjCCategoryDecl *FindCategoryDeclaration(IdentifierInfo *CategoryId) const; 4313db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner 4323db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner typedef ObjCList<ObjCProtocolDecl>::iterator protocol_iterator; 4333db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();} 4343db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner protocol_iterator protocol_end() const { return ReferencedProtocols.end(); } 435291be393aa33759e6e34b6429c5ffa206ba50115Douglas Gregor unsigned protocol_size() const { return ReferencedProtocols.size(); } 436291be393aa33759e6e34b6429c5ffa206ba50115Douglas Gregor 437e881483a3bc22ffad62367501aa09ad8508fe363Chris Lattner typedef ObjCList<ObjCIvarDecl>::iterator ivar_iterator; 438e881483a3bc22ffad62367501aa09ad8508fe363Chris Lattner ivar_iterator ivar_begin() const { return IVars.begin(); } 439e881483a3bc22ffad62367501aa09ad8508fe363Chris Lattner ivar_iterator ivar_end() const { return IVars.end(); } 440e881483a3bc22ffad62367501aa09ad8508fe363Chris Lattner unsigned ivar_size() const { return IVars.size(); } 441e881483a3bc22ffad62367501aa09ad8508fe363Chris Lattner bool ivar_empty() const { return IVars.empty(); } 442e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 44338af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner /// setProtocolList - Set the list of protocols that this interface 444b752f289026ad8e5f44851b20e009a27ed61eefcChris Lattner /// implements. 44538af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void setProtocolList(ObjCProtocolDecl *const* List, unsigned Num, 44638af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner ASTContext &C) { 44738af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner ReferencedProtocols.set(List, Num, C); 4483db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner } 449b752f289026ad8e5f44851b20e009a27ed61eefcChris Lattner 45038af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void setIVarList(ObjCIvarDecl * const *List, unsigned Num, ASTContext &C) { 45138af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner IVars.set(List, Num, C); 452e881483a3bc22ffad62367501aa09ad8508fe363Chris Lattner } 453980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 454768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff bool isForwardDecl() const { return ForwardDecl; } 455768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff void setForwardDecl(bool val) { ForwardDecl = val; } 456980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 457a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *getSuperClass() const { return SuperClass; } 458a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; } 459980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 460a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCCategoryDecl* getCategoryList() const { return CategoryList; } 461a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek void setCategoryList(ObjCCategoryDecl *category) { 46253efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner CategoryList = category; 463980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff } 46453efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner 46553efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner /// isSuperClassOf - Return true if this class is the specified class or is a 46653efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner /// super class of the specified interface class. 46753efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner bool isSuperClassOf(const ObjCInterfaceDecl *I) const { 46853efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner // If RHS is derived from LHS it is OK; else it is not OK. 46953efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner while (I != NULL) { 47053efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner if (this == I) 47153efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner return true; 47253efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner I = I->getSuperClass(); 47353efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner } 47453efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner return false; 47553efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner } 47653efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner 4776ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor ObjCIvarDecl *lookupInstanceVariable(ASTContext &Context, 4786ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor IdentifierInfo *IVarName, 47968a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner ObjCInterfaceDecl *&ClassDeclared); 4806ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor ObjCIvarDecl *lookupInstanceVariable(ASTContext &Context, 4816ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor IdentifierInfo *IVarName) { 48268a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner ObjCInterfaceDecl *ClassDeclared; 4836ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor return lookupInstanceVariable(Context, IVarName, ClassDeclared); 48468a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner } 48568a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner 48694a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff // Lookup a method. First, we search locally. If a method isn't 48794a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff // found, we search referenced protocols and class categories. 4886ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor ObjCMethodDecl *lookupInstanceMethod(ASTContext &Context, Selector Sel); 4896ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor ObjCMethodDecl *lookupClassMethod(ASTContext &Context, Selector Sel); 490cd1876207f5564beba74e4b2524b664bdba0ba9fFariborz Jahanian ObjCInterfaceDecl *lookupInheritedClass(const IdentifierInfo *ICName); 49160fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff 492f908a87299d278164540f90b5b6e6cab7b14fb41Steve Naroff // Location information, modeled after the Stmt API. 49360fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff SourceLocation getLocStart() const { return getLocation(); } // '@'interface 494f908a87299d278164540f90b5b6e6cab7b14fb41Steve Naroff SourceLocation getLocEnd() const { return EndLoc; } 495f908a87299d278164540f90b5b6e6cab7b14fb41Steve Naroff void setLocEnd(SourceLocation LE) { EndLoc = LE; }; 49660fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff 49733feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff void setClassLoc(SourceLocation Loc) { ClassLoc = Loc; } 498d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff SourceLocation getClassLoc() const { return ClassLoc; } 499d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff void setSuperClassLoc(SourceLocation Loc) { SuperClassLoc = Loc; } 500d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff SourceLocation getSuperClassLoc() const { return SuperClassLoc; } 501e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 50228e71cf851b73a67604735a9a95aef800b144e2eSteve Naroff /// isImplicitInterfaceDecl - check that this is an implicitly declared 503a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek /// ObjCInterfaceDecl node. This is for legacy objective-c @implementation 5044b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian /// declaration without an @interface declaration. 50533feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff bool isImplicitInterfaceDecl() const { return InternalInterface; } 50633feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff void setImplicitInterfaceDecl(bool val) { InternalInterface = val; } 5074b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian 50833feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff // Low-level accessor 50933feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff Type *getTypeForDecl() const { return TypeForDecl; } 5103b3a45858c6b2a45114e91902c3bf3c4b7f5f302Daniel Dunbar void setTypeForDecl(Type *TD) const { TypeForDecl = TD; } 51133feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff 512a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const Decl *D) { return D->getKind() == ObjCInterface; } 513a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCInterfaceDecl *D) { return true; } 514980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 515980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 516a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCIvarDecl - Represents an ObjC instance variable. In general, ObjC 5170c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// instance variables are identical to C. The only exception is Objective-C 5180c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// supports C++ style access control. For example: 5190c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 5200c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @interface IvarExample : NSObject 5210c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// { 522f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek/// id defaultToProtected; 5230c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @public: 5240c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id canBePublic; // same as C++. 5250c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @protected: 5260c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id canBeProtected; // same as C++. 5270c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @package: 5280c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id canBePackage; // framework visibility (not available in C++). 5290c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// } 5300c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 531a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCIvarDecl : public FieldDecl { 5320e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattnerpublic: 533980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff enum AccessControl { 534980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff None, Private, Protected, Public, Package 535980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff }; 536f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek 537b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenekprivate: 5380c00aac5d618f39afc406c5b2e07642930af1d56Argyrios Kyrtzidis ObjCIvarDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, 5390c00aac5d618f39afc406c5b2e07642930af1d56Argyrios Kyrtzidis QualType T, AccessControl ac, Expr *BW) 5400c00aac5d618f39afc406c5b2e07642930af1d56Argyrios Kyrtzidis : FieldDecl(ObjCIvar, DC, L, Id, T, BW, /*Mutable=*/false), 54144b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor DeclAccess(ac) {} 542b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenek 543b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenekpublic: 5440c00aac5d618f39afc406c5b2e07642930af1d56Argyrios Kyrtzidis static ObjCIvarDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, 545b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenek IdentifierInfo *Id, QualType T, 546b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenek AccessControl ac, Expr *BW = NULL); 547b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenek 548980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff void setAccessControl(AccessControl ac) { DeclAccess = ac; } 549f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek 550ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek AccessControl getAccessControl() const { return AccessControl(DeclAccess); } 551f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek 552f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek AccessControl getCanonicalAccessControl() const { 553f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek return DeclAccess == None ? Protected : AccessControl(DeclAccess); 554f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek } 555980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 556980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff // Implement isa/cast/dyncast/etc. 557a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const Decl *D) { return D->getKind() == ObjCIvar; } 558a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCIvarDecl *D) { return true; } 559980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffprivate: 560ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek // NOTE: VC++ treats enums as signed, avoid using the AccessControl enum 561ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek unsigned DeclAccess : 3; 562980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 563980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 56401e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek 56501e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek/// ObjCAtDefsFieldDecl - Represents a field declaration created by an 56601e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek/// @defs(...). 56701e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenekclass ObjCAtDefsFieldDecl : public FieldDecl { 56801e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenekprivate: 56944b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor ObjCAtDefsFieldDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, 57001e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek QualType T, Expr *BW) 5714afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor : FieldDecl(ObjCAtDefsField, DC, L, Id, T, BW, /*Mutable=*/false) {} 57201e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek 57301e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenekpublic: 57444b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor static ObjCAtDefsFieldDecl *Create(ASTContext &C, DeclContext *DC, 57544b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor SourceLocation L, 57601e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek IdentifierInfo *Id, QualType T, 57701e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek Expr *BW); 57801e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek 57901e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek virtual void Destroy(ASTContext& C); 58001e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek 58101e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek // Implement isa/cast/dyncast/etc. 58201e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek static bool classof(const Decl *D) { return D->getKind() == ObjCAtDefsField; } 58301e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek static bool classof(const ObjCAtDefsFieldDecl *D) { return true; } 58401e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek}; 585980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 586a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCProtocolDecl - Represents a protocol declaration. ObjC protocols 5870c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// declare a pure abstract type (i.e no instance variables are permitted). 5880c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Protocols orginally drew inspiration from C++ pure virtual functions (a C++ 5890c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// feature with nice semantics and lousy syntax:-). Here is an example: 5900c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 591eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// @protocol NSDraggingInfo <refproto1, refproto2> 5920c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSWindow *)draggingDestinationWindow; 5930c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSImage *)draggedImage; 5940c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end 5950c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 596eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// This says that NSDraggingInfo requires two methods and requires everything 597eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// that the two "referenced protocols" 'refproto1' and 'refproto2' require as 598eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// well. 599eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// 6000c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @interface ImplementsNSDraggingInfo : NSObject <NSDraggingInfo> 6010c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end 6020c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 603a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjC protocols inspired Java interfaces. Unlike Java, ObjC classes and 6040c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// protocols are in distinct namespaces. For example, Cocoa defines both 6050c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// an NSObject protocol and class (which isn't allowed in Java). As a result, 6060c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// protocols are referenced using angle brackets as follows: 6070c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 6080c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id <NSDraggingInfo> anyObjectThatImplementsNSDraggingInfo; 6090c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 610e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroffclass ObjCProtocolDecl : public ObjCContainerDecl { 611780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner /// Referenced protocols 612780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner ObjCList<ObjCProtocolDecl> ReferencedProtocols; 613980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 614980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff bool isForwardProtoDecl; // declared with @protocol. 615423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff 616423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff SourceLocation EndLoc; // marks the '>' or identifier. 617cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattner 618d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor ObjCProtocolDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id) 619d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor : ObjCContainerDecl(ObjCProtocol, DC, L, Id), 620c858105d41602a2dadb2efbc1af80a7b791ebac3Chris Lattner isForwardProtoDecl(true) { 621cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattner } 6221c8a413c1e00636c77666ddf1e3b0311f3fa8c81Ted Kremenek 6234a323d94e50c8f570cbfaf0392e68215b8ca87bfChris Lattner virtual ~ObjCProtocolDecl() {} 6241c8a413c1e00636c77666ddf1e3b0311f3fa8c81Ted Kremenek 625cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattnerpublic: 626d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCProtocolDecl *Create(ASTContext &C, DeclContext *DC, 627d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor SourceLocation L, IdentifierInfo *Id); 628cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattner 629411280e5b25ba7dcd7c8a82a5c23880fe7632a3cChris Lattner /// Destroy - Call destructors and release memory. 630411280e5b25ba7dcd7c8a82a5c23880fe7632a3cChris Lattner virtual void Destroy(ASTContext& C); 631411280e5b25ba7dcd7c8a82a5c23880fe7632a3cChris Lattner 632780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner const ObjCList<ObjCProtocolDecl> &getReferencedProtocols() const { 633780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner return ReferencedProtocols; 634980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff } 635dbc933701d20918add13b6a3c9d47ff8c75419cfDaniel Dunbar typedef ObjCList<ObjCProtocolDecl>::iterator protocol_iterator; 636780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();} 637780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner protocol_iterator protocol_end() const { return ReferencedProtocols.end(); } 63830833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff unsigned protocol_size() const { return ReferencedProtocols.size(); } 639780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner 64038af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner /// setProtocolList - Set the list of protocols that this interface 641780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner /// implements. 64238af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num, 64338af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner ASTContext &C) { 64438af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner ReferencedProtocols.set(List, Num, C); 645aebf0cba02c014ac8b19d615c654248e0e93779fFariborz Jahanian } 646aebf0cba02c014ac8b19d615c654248e0e93779fFariborz Jahanian 64791b0b0cf6b537cbcbca0038c7032f87161a41d31Steve Naroff ObjCProtocolDecl *lookupProtocolNamed(IdentifierInfo *PName); 64891b0b0cf6b537cbcbca0038c7032f87161a41d31Steve Naroff 64994a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff // Lookup a method. First, we search locally. If a method isn't 65094a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff // found, we search referenced protocols and class categories. 6516ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor ObjCMethodDecl *lookupInstanceMethod(ASTContext &Context, Selector Sel); 6526ab3524f72a6e64aa04973fa9433b5559abb3525Douglas Gregor ObjCMethodDecl *lookupClassMethod(ASTContext &Context, Selector Sel); 653a66793ee8d2589ead81739d9b8a968650db3d452Fariborz Jahanian 654768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff bool isForwardDecl() const { return isForwardProtoDecl; } 655768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff void setForwardDecl(bool val) { isForwardProtoDecl = val; } 656980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 657423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff // Location information, modeled after the Stmt API. 658423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff SourceLocation getLocStart() const { return getLocation(); } // '@'protocol 659423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff SourceLocation getLocEnd() const { return EndLoc; } 660423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff void setLocEnd(SourceLocation LE) { EndLoc = LE; }; 661423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff 662a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const Decl *D) { return D->getKind() == ObjCProtocol; } 663a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCProtocolDecl *D) { return true; } 664980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 665980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 666a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCClassDecl - Specifies a list of forward class declarations. For example: 66706ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff/// 66806ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff/// @class NSCursor, NSImage, NSPasteboard, NSWindow; 6690c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 6704afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCClassDecl : public Decl { 67167956052ea5fb0cd7f443de96a11f9a0176dc681Chris Lattner ObjCList<ObjCInterfaceDecl> ForwardDecls; 67261f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner 673d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor ObjCClassDecl(DeclContext *DC, SourceLocation L, 67438af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner ObjCInterfaceDecl *const *Elts, unsigned nElts, ASTContext &C); 67567956052ea5fb0cd7f443de96a11f9a0176dc681Chris Lattner virtual ~ObjCClassDecl() {} 67661f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattnerpublic: 677400d95fb7bb9fac609f8613862b84f3a2a7d510fTed Kremenek 678400d95fb7bb9fac609f8613862b84f3a2a7d510fTed Kremenek /// Destroy - Call destructors and release memory. 679400d95fb7bb9fac609f8613862b84f3a2a7d510fTed Kremenek virtual void Destroy(ASTContext& C); 680400d95fb7bb9fac609f8613862b84f3a2a7d510fTed Kremenek 681d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCClassDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, 68230833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff ObjCInterfaceDecl *const *Elts = 0, 68330833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff unsigned nElts = 0); 68461f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner 68567956052ea5fb0cd7f443de96a11f9a0176dc681Chris Lattner typedef ObjCList<ObjCInterfaceDecl>::iterator iterator; 68667956052ea5fb0cd7f443de96a11f9a0176dc681Chris Lattner iterator begin() const { return ForwardDecls.begin(); } 68767956052ea5fb0cd7f443de96a11f9a0176dc681Chris Lattner iterator end() const { return ForwardDecls.end(); } 68830833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff unsigned size() const { return ForwardDecls.size(); } 68930833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff 69030833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff /// setClassList - Set the list of forward classes. 69130833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff void setClassList(ASTContext &C, ObjCInterfaceDecl*const*List, unsigned Num) { 69230833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff ForwardDecls.set(List, Num, C); 69330833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff } 694400d95fb7bb9fac609f8613862b84f3a2a7d510fTed Kremenek 695a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const Decl *D) { return D->getKind() == ObjCClass; } 696a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCClassDecl *D) { return true; } 69706ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff}; 69806ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff 699a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCForwardProtocolDecl - Specifies a list of forward protocol declarations. 70006ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff/// For example: 70106ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff/// 7020c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @protocol NSTextInput, NSChangeSpelling, NSDraggingInfo; 7030c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 7044afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCForwardProtocolDecl : public Decl { 70507fa7749da805969f2ed467a4eb5b405a4ff9a23Chris Lattner ObjCList<ObjCProtocolDecl> ReferencedProtocols; 70661f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner 707d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L, 70838af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner ObjCProtocolDecl *const *Elts, unsigned nElts, 70938af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner ASTContext &C); 71007fa7749da805969f2ed467a4eb5b405a4ff9a23Chris Lattner virtual ~ObjCForwardProtocolDecl() {} 71105ac3ef08f9d06e0a4439073c9edabf7f912f946Ted Kremenek 71261f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattnerpublic: 713d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCForwardProtocolDecl *Create(ASTContext &C, DeclContext *DC, 714d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor SourceLocation L, 71530833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff ObjCProtocolDecl *const *Elts = 0, 71630833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff unsigned Num = 0); 71761f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner 7180b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner /// Destroy - Call destructors and release memory. 7190b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner virtual void Destroy(ASTContext& C); 7209fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner 72130833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff typedef ObjCList<ObjCProtocolDecl>::iterator protocol_iterator; 72230833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();} 72330833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff protocol_iterator protocol_end() const { return ReferencedProtocols.end(); } 72430833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff unsigned protocol_size() const { return ReferencedProtocols.size(); } 72530833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff 72630833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff /// setProtocolList - Set the list of forward protocols. 72730833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num, 72830833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff ASTContext &C) { 72930833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff ReferencedProtocols.set(List, Num, C); 73030833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff } 73106ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff static bool classof(const Decl *D) { 732a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek return D->getKind() == ObjCForwardProtocol; 73306ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff } 734a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCForwardProtocolDecl *D) { return true; } 735980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 736980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 737a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCCategoryDecl - Represents a category declaration. A category allows 7380c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// you to add methods to an existing class (without subclassing or modifying 7390c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// the original class interface or implementation:-). Categories don't allow 7400c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// you to add instance data. The following example adds "myMethod" to all 7410c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// NSView's within a process: 7420c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 7430c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @interface NSView (MyViewMethods) 7440c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - myMethod; 7450c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end 7460c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 7470c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Cateogries also allow you to split the implementation of a class across 7480c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// several files (a feature more naturally supported in C++). 7490c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 7500c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Categories were originally inspired by dynamic languages such as Common 75168c82cf61228102aba1194efef222fa1478af2a8Chris Lattner/// Lisp and Smalltalk. More traditional class-based languages (C++, Java) 7520c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// don't support this level of dynamism, which is both powerful and dangerous. 7530c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 754e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroffclass ObjCCategoryDecl : public ObjCContainerDecl { 755980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff /// Interface belonging to this category 756a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *ClassInterface; 757980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 75868c82cf61228102aba1194efef222fa1478af2a8Chris Lattner /// referenced protocols in this category. 759780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner ObjCList<ObjCProtocolDecl> ReferencedProtocols; 760980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 761a8ff9f455d94d9609766cfd5186b6e21dc2102f1Chris Lattner /// Next category belonging to this class. 762a8ff9f455d94d9609766cfd5186b6e21dc2102f1Chris Lattner /// FIXME: this should not be a singly-linked list. Move storage elsewhere. 763a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCCategoryDecl *NextClassCategory; 764ca3adf7e8cac8c9fbaf592b1e5c2be6f082de7baFariborz Jahanian 765423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff SourceLocation EndLoc; // marks the '>' or identifier. 76661f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner 767d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor ObjCCategoryDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id) 768d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor : ObjCContainerDecl(ObjCCategory, DC, L, Id), 7692f0fe337f499c78710b718324b25510670d885b1Chris Lattner ClassInterface(0), NextClassCategory(0){ 770a906135721c350435319347d2672bbb3bf494f91Chris Lattner } 77161f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattnerpublic: 77261f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner 773d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCCategoryDecl *Create(ASTContext &C, DeclContext *DC, 7740ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner SourceLocation L, IdentifierInfo *Id); 77561f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner 776e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner ObjCInterfaceDecl *getClassInterface() { return ClassInterface; } 777e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } 778a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek void setClassInterface(ObjCInterfaceDecl *IDecl) { ClassInterface = IDecl; } 779980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 78038af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner /// setProtocolList - Set the list of protocols that this interface 781f7b2c98c16dfb2261ea57d40a1d5bc4738e73175Chris Lattner /// implements. 78238af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num, 78338af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner ASTContext &C) { 78438af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner ReferencedProtocols.set(List, Num, C); 785780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner } 786980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 787780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner const ObjCList<ObjCProtocolDecl> &getReferencedProtocols() const { 788780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner return ReferencedProtocols; 7898f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian } 790780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner 791a8ff9f455d94d9609766cfd5186b6e21dc2102f1Chris Lattner typedef ObjCList<ObjCProtocolDecl>::iterator protocol_iterator; 792780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();} 793780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner protocol_iterator protocol_end() const { return ReferencedProtocols.end(); } 79430833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff unsigned protocol_size() const { return ReferencedProtocols.size(); } 795780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner 796a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCCategoryDecl *getNextClassCategory() const { return NextClassCategory; } 79730833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff void setNextClassCategory(ObjCCategoryDecl *Cat) { 79830833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff NextClassCategory = Cat; 79930833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff } 800980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff void insertNextClassCategory() { 8013d58138992b9bc7b34aaa680f3ddf3971292eb7dSteve Naroff NextClassCategory = ClassInterface->getCategoryList(); 8023d58138992b9bc7b34aaa680f3ddf3971292eb7dSteve Naroff ClassInterface->setCategoryList(this); 803980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff } 804423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff // Location information, modeled after the Stmt API. 805423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff SourceLocation getLocStart() const { return getLocation(); } // '@'interface 806423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff SourceLocation getLocEnd() const { return EndLoc; } 807423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff void setLocEnd(SourceLocation LE) { EndLoc = LE; }; 808423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff 809a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const Decl *D) { return D->getKind() == ObjCCategory; } 810a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCCategoryDecl *D) { return true; } 811980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 8120c6b6243d3efd958c17943130e2a773653511edcSteve Naroff 8138fc463adf0116fdcbff86e9cca11955aad1649feDouglas Gregorclass ObjCImplDecl : public NamedDecl, public DeclContext { 8148f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian /// Class interface for this category implementation 815a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *ClassInterface; 8163aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner 817e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff SourceLocation EndLoc; 818cddc88800bbd1213ec70ae5153c6a7f2e380fd8dChris Lattner 8193aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattnerprotected: 8203aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner ObjCImplDecl(Kind DK, DeclContext *DC, SourceLocation L, 8213aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner ObjCInterfaceDecl *classInterface) 8228fc463adf0116fdcbff86e9cca11955aad1649feDouglas Gregor : NamedDecl(DK, DC, L, 8238fc463adf0116fdcbff86e9cca11955aad1649feDouglas Gregor classInterface? classInterface->getDeclName() 8248fc463adf0116fdcbff86e9cca11955aad1649feDouglas Gregor : DeclarationName()), 8258fc463adf0116fdcbff86e9cca11955aad1649feDouglas Gregor DeclContext(DK), ClassInterface(classInterface) {} 8263aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner 82775c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattnerpublic: 828cddc88800bbd1213ec70ae5153c6a7f2e380fd8dChris Lattner virtual ~ObjCImplDecl() {} 829cddc88800bbd1213ec70ae5153c6a7f2e380fd8dChris Lattner 830e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } 831e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner ObjCInterfaceDecl *getClassInterface() { return ClassInterface; } 8322c2d43c557beca1b4ba4bd743f33978aecb46a97Douglas Gregor void setClassInterface(ObjCInterfaceDecl *IFace) { ClassInterface = IFace; } 8332c2d43c557beca1b4ba4bd743f33978aecb46a97Douglas Gregor 834653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor void addInstanceMethod(ASTContext &Context, ObjCMethodDecl *method) { 8352c2d43c557beca1b4ba4bd743f33978aecb46a97Douglas Gregor // FIXME: Context should be set correctly before we get here. 836653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor method->setLexicalDeclContext(this); 837653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor addDecl(Context, method); 838e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff } 839653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor void addClassMethod(ASTContext &Context, ObjCMethodDecl *method) { 8402c2d43c557beca1b4ba4bd743f33978aecb46a97Douglas Gregor // FIXME: Context should be set correctly before we get here. 841653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor method->setLexicalDeclContext(this); 842653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor addDecl(Context, method); 84353df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner } 844f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian 845653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor // Get the local instance/class method declared in this interface. 846653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor ObjCMethodDecl *getInstanceMethod(ASTContext &Context, Selector Sel) const; 847653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor ObjCMethodDecl *getClassMethod(ASTContext &Context, Selector Sel) const; 848653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor ObjCMethodDecl *getMethod(ASTContext &Context, Selector Sel, 849653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor bool isInstance) const { 850653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor return isInstance ? getInstanceMethod(Context, Sel) 851653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor : getClassMethod(Context, Sel); 852f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian } 8533aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner 854653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor void addPropertyImplementation(ASTContext &Context, 855653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor ObjCPropertyImplDecl *property); 856ae6f6fd1527a1da84679a6f0439dec3bbbd6ca7bFariborz Jahanian 857653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor ObjCPropertyImplDecl *FindPropertyImplDecl(ASTContext &Context, 858653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor IdentifierInfo *propertyId) const; 859653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor ObjCPropertyImplDecl *FindPropertyImplIvarDecl(ASTContext &Context, 860653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor IdentifierInfo *ivarId) const; 861653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor 862653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor // Iterator access to properties. 863653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor typedef specific_decl_iterator<ObjCPropertyImplDecl> propimpl_iterator; 864653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor propimpl_iterator propimpl_begin(ASTContext &Context) const { 865653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor return propimpl_iterator(decls_begin(Context)); 866559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian } 867653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor propimpl_iterator propimpl_end(ASTContext &Context) const { 868653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor return propimpl_iterator(decls_end(Context)); 869559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian } 870653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor 871653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor typedef filtered_decl_iterator<ObjCMethodDecl, 872653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor &ObjCMethodDecl::isInstanceMethod> 873ab4c4d5e5ececa77aae7e291fafcba3049319cdcChris Lattner instmeth_iterator; 874653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor instmeth_iterator instmeth_begin(ASTContext &Context) const { 875653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor return instmeth_iterator(decls_begin(Context)); 876653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor } 877653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor instmeth_iterator instmeth_end(ASTContext &Context) const { 878653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor return instmeth_iterator(decls_end(Context)); 879653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor } 880653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor 881653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor typedef filtered_decl_iterator<ObjCMethodDecl, 882653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor &ObjCMethodDecl::isClassMethod> 883ab4c4d5e5ececa77aae7e291fafcba3049319cdcChris Lattner classmeth_iterator; 884653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor classmeth_iterator classmeth_begin(ASTContext &Context) const { 885653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor return classmeth_iterator(decls_begin(Context)); 886653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor } 887653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor classmeth_iterator classmeth_end(ASTContext &Context) const { 888653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor return classmeth_iterator(decls_end(Context)); 889653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor } 890653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor 891e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff // Location information, modeled after the Stmt API. 892e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff SourceLocation getLocStart() const { return getLocation(); } 893e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff SourceLocation getLocEnd() const { return EndLoc; } 894e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff void setLocEnd(SourceLocation LE) { EndLoc = LE; }; 8953aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner}; 8963aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner 8973aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// ObjCCategoryImplDecl - An object of this class encapsulates a category 8983aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @implementation declaration. If a category class has declaration of a 8993aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// property, its implementation must be specified in the category's 9003aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @implementation declaration. Example: 9013aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @interface I @end 9023aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @interface I(CATEGORY) 9033aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @property int p1, d1; 9043aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @end 9053aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @implementation I(CATEGORY) 9063aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @dynamic p1,d1; 9073aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @end 9083aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// 9093aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// ObjCCategoryImplDecl 9103aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattnerclass ObjCCategoryImplDecl : public ObjCImplDecl { 9113aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner // Category name 9123aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner IdentifierInfo *Id; 9133aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner 9143aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner ObjCCategoryImplDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, 9153aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner ObjCInterfaceDecl *classInterface) 9163aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner : ObjCImplDecl(ObjCCategoryImpl, DC, L, classInterface), Id(Id) {} 9173aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattnerpublic: 9183aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner static ObjCCategoryImplDecl *Create(ASTContext &C, DeclContext *DC, 9193aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner SourceLocation L, IdentifierInfo *Id, 9203aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner ObjCInterfaceDecl *classInterface); 9213aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner 9223aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner /// getIdentifier - Get the identifier that names the class 9233aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner /// interface associated with this implementation. 9243aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner IdentifierInfo *getIdentifier() const { 9253aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner return Id; 9263aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner } 92710b0e1fa3aabd8877dbbc0df1f2414e04afd5fddDouglas Gregor void setIdentifier(IdentifierInfo *II) { Id = II; } 92810b0e1fa3aabd8877dbbc0df1f2414e04afd5fddDouglas Gregor 9293aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner /// getNameAsCString - Get the name of identifier for the class 9303aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner /// interface associated with this implementation as a C string 9313aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner /// (const char*). 9323aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner const char *getNameAsCString() const { 933cddc88800bbd1213ec70ae5153c6a7f2e380fd8dChris Lattner return Id ? Id->getName() : ""; 9343aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner } 9353aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner 9363aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner /// @brief Get the name of the class associated with this interface. 9373aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner std::string getNameAsString() const { 938cddc88800bbd1213ec70ae5153c6a7f2e380fd8dChris Lattner return Id ? Id->getName() : ""; 9393aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner } 9403aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner 941a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const Decl *D) { return D->getKind() == ObjCCategoryImpl;} 942a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCCategoryImplDecl *D) { return true; } 943b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff static DeclContext *castToDeclContext(const ObjCCategoryImplDecl *D) { 944b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff return static_cast<DeclContext *>(const_cast<ObjCCategoryImplDecl*>(D)); 945b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff } 946b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff static ObjCCategoryImplDecl *castFromDeclContext(const DeclContext *DC) { 947b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff return static_cast<ObjCCategoryImplDecl *>(const_cast<DeclContext*>(DC)); 948b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff } 9498f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian}; 9508f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian 951a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCImplementationDecl - Represents a class definition - this is where 9520c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// method definitions are specified. For example: 9530c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 95498abf4bd3526a00a0e5cf71a9462c181f97b1c81Fariborz Jahanian/// @code 9550c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @implementation MyClass 9560c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (void)myMethod { /* do something */ } 9570c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end 95898abf4bd3526a00a0e5cf71a9462c181f97b1c81Fariborz Jahanian/// @endcode 9590c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 9600c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Typically, instance variables are specified in the class interface, 961ec0d7a6f4b0699cc9960e6d9fee0f957c64d1cf9Douglas Gregor/// *not* in the implementation. Nevertheless (for legacy reasons), we 96253df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner/// allow instance variables to be specified in the implementation. When 96353df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner/// specified, they need to be *identical* to the interface. 9640c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 9653aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattnerclass ObjCImplementationDecl : public ObjCImplDecl { 966980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff /// Implementation Class's super class. 967a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *SuperClass; 968980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 9694afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor ObjCImplementationDecl(DeclContext *DC, SourceLocation L, 970a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *classInterface, 971a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *superDecl) 9723aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner : ObjCImplDecl(ObjCImplementation, DC, L, classInterface), 9733aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner SuperClass(superDecl){} 97475c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattnerpublic: 975d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCImplementationDecl *Create(ASTContext &C, DeclContext *DC, 9764afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor SourceLocation L, 97775c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattner ObjCInterfaceDecl *classInterface, 97875c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattner ObjCInterfaceDecl *superDecl); 97975c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattner 9804afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// getIdentifier - Get the identifier that names the class 9814afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// interface associated with this implementation. 9824afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor IdentifierInfo *getIdentifier() const { 9834afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor return getClassInterface()->getIdentifier(); 9844afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor } 9854afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor 9864afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// getNameAsCString - Get the name of identifier for the class 9874afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// interface associated with this implementation as a C string 9884afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// (const char*). 9894afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor const char *getNameAsCString() const { 9904afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor assert(getIdentifier() && "Name is not a simple identifier"); 9914afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor return getIdentifier()->getName(); 9924afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor } 9934afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor 9944afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// @brief Get the name of the class associated with this interface. 9954afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor std::string getNameAsString() const { 9964afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor return getClassInterface()->getNameAsString(); 9974afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor } 9984afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor 999e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner const ObjCInterfaceDecl *getSuperClass() const { return SuperClass; } 1000e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner ObjCInterfaceDecl *getSuperClass() { return SuperClass; } 1001980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 1002f3a7af901231535191d14cb524d58f22907ac4d2Chris Lattner void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; } 10033aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner 10048f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator; 10058f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor ivar_iterator ivar_begin(ASTContext &Context) const { 10068f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor return ivar_iterator(decls_begin(Context)); 10078f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor } 10088f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor ivar_iterator ivar_end(ASTContext &Context) const { 10098f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor return ivar_iterator(decls_end(Context)); 10108f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor } 10118f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor unsigned ivar_size(ASTContext &Context) const { 10128f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor return std::distance(ivar_begin(Context), ivar_end(Context)); 10138f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor } 10148f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor bool ivar_empty(ASTContext &Context) const { 10158f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor return ivar_begin(Context) == ivar_end(Context); 10168f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor } 10170157c5144513438bb74aebf50d18f95df4104acbChris Lattner 1018980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff static bool classof(const Decl *D) { 1019a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek return D->getKind() == ObjCImplementation; 1020980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff } 1021a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCImplementationDecl *D) { return true; } 1022b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff static DeclContext *castToDeclContext(const ObjCImplementationDecl *D) { 1023b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff return static_cast<DeclContext *>(const_cast<ObjCImplementationDecl*>(D)); 1024b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff } 1025b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff static ObjCImplementationDecl *castFromDeclContext(const DeclContext *DC) { 1026b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff return static_cast<ObjCImplementationDecl *>(const_cast<DeclContext*>(DC)); 1027b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff } 1028980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 1029243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian 1030a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is 1031243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian/// declared as @compatibility_alias alias class. 10324afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCCompatibleAliasDecl : public NamedDecl { 1033243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian /// Class that this is an alias of. 1034a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *AliasedClass; 1035243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian 1036d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor ObjCCompatibleAliasDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, 1037e8043c39176e7f253fbd92982b077eca6bf2fd59Steve Naroff ObjCInterfaceDecl* aliasedClass) 10384afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor : NamedDecl(ObjCCompatibleAlias, DC, L, Id), AliasedClass(aliasedClass) {} 1039f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattnerpublic: 1040d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCCompatibleAliasDecl *Create(ASTContext &C, DeclContext *DC, 10410ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner SourceLocation L, IdentifierInfo *Id, 1042f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner ObjCInterfaceDecl* aliasedClass); 1043f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner 1044f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner const ObjCInterfaceDecl *getClassInterface() const { return AliasedClass; } 1045f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner ObjCInterfaceDecl *getClassInterface() { return AliasedClass; } 104630833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff void setClassInterface(ObjCInterfaceDecl *D) { AliasedClass = D; } 1047980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 1048243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian static bool classof(const Decl *D) { 10498a934233d1582b5bde9d270bc0705aa81e471a79Chris Lattner return D->getKind() == ObjCCompatibleAlias; 1050243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian } 1051a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCCompatibleAliasDecl *D) { return true; } 1052243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian 1053243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian}; 10541de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian 10551de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian/// ObjCPropertyDecl - Represents one property declaration in an interface. 10561de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian/// For example: 10571de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian/// @property (assign, readwrite) int MyProperty; 10581de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian/// 10594afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCPropertyDecl : public NamedDecl { 106082a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanianpublic: 1061a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner enum PropertyAttributeKind { 1062a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner OBJC_PR_noattr = 0x00, 1063a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner OBJC_PR_readonly = 0x01, 1064a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner OBJC_PR_getter = 0x02, 1065a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner OBJC_PR_assign = 0x04, 1066a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner OBJC_PR_readwrite = 0x08, 1067a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner OBJC_PR_retain = 0x10, 1068a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner OBJC_PR_copy = 0x20, 1069a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner OBJC_PR_nonatomic = 0x40, 1070a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner OBJC_PR_setter = 0x80 1071a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner }; 1072af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar 1073af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar enum SetterKind { Assign, Retain, Copy }; 107446b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian enum PropertyControl { None, Required, Optional }; 107582a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanianprivate: 1076dae1a1a2aa4f245b1958dc8db6089f24c575ef13Fariborz Jahanian QualType DeclType; 1077ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek unsigned PropertyAttributes : 8; 107882a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian 107946b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian // @required/@optional 108046b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian unsigned PropertyImplementation : 2; 108146b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian 10825251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian Selector GetterName; // getter name of NULL if no getter 10835251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian Selector SetterName; // setter name of NULL if no setter 108482a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian 108533de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian ObjCMethodDecl *GetterMethodDecl; // Declaration of getter instance method 108633de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian ObjCMethodDecl *SetterMethodDecl; // Declaration of setter instance method 1087af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian ObjCIvarDecl *PropertyIvarDecl; // Synthesize ivar for this property 108833de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian 1089d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, 1090d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor QualType T) 10914afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor : NamedDecl(ObjCProperty, DC, L, Id), DeclType(T), 109233de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian PropertyAttributes(OBJC_PR_noattr), PropertyImplementation(None), 109333de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian GetterName(Selector()), 109433de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian SetterName(Selector()), 1095af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian GetterMethodDecl(0), SetterMethodDecl(0) , PropertyIvarDecl(0) {} 1096f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattnerpublic: 1097d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC, 1098d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor SourceLocation L, 109946b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian IdentifierInfo *Id, QualType T, 110046b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian PropertyControl propControl = None); 1101dae1a1a2aa4f245b1958dc8db6089f24c575ef13Fariborz Jahanian QualType getType() const { return DeclType; } 110270e5a14c6076d63833c62d1d6d628c26309897c1Douglas Gregor void setType(QualType T) { DeclType = T; } 110370e5a14c6076d63833c62d1d6d628c26309897c1Douglas Gregor 1104a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner PropertyAttributeKind getPropertyAttributes() const { 1105f4af5154571e0c5eadb19df10e65464766ef6683Chris Lattner return PropertyAttributeKind(PropertyAttributes); 1106f4af5154571e0c5eadb19df10e65464766ef6683Chris Lattner } 1107564576b225386cbff375351597dd5e2a92872d38Fariborz Jahanian void setPropertyAttributes(PropertyAttributeKind PRVal) { 1108a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner PropertyAttributes |= PRVal; 110982a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian } 1110394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar 11118cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian void makeitReadWriteAttribute(void) { 11128cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian PropertyAttributes &= ~OBJC_PR_readonly; 11138cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian PropertyAttributes |= OBJC_PR_readwrite; 11148cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian } 11158cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian 1116af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar // Helper methods for accessing attributes. 1117af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar 1118af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar /// isReadOnly - Return true iff the property has a setter. 1119394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar bool isReadOnly() const { 1120394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar return (PropertyAttributes & OBJC_PR_readonly); 1121394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar } 1122af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar 1123af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar /// getSetterKind - Return the method used for doing assignment in 1124af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar /// the property setter. This is only valid if the property has been 1125af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar /// defined to have a setter. 1126af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar SetterKind getSetterKind() const { 1127af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar if (PropertyAttributes & OBJC_PR_retain) 1128af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar return Retain; 1129af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar if (PropertyAttributes & OBJC_PR_copy) 1130af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar return Copy; 1131af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar return Assign; 1132af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar } 1133af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar 11345251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian Selector getGetterName() const { return GetterName; } 11355251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian void setGetterName(Selector Sel) { GetterName = Sel; } 113682a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian 11375251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian Selector getSetterName() const { return SetterName; } 11385251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian void setSetterName(Selector Sel) { SetterName = Sel; } 113982a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian 114033de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian ObjCMethodDecl *getGetterMethodDecl() const { return GetterMethodDecl; } 114133de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian void setGetterMethodDecl(ObjCMethodDecl *gDecl) { GetterMethodDecl = gDecl; } 114233de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian 114333de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian ObjCMethodDecl *getSetterMethodDecl() const { return SetterMethodDecl; } 114433de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian void setSetterMethodDecl(ObjCMethodDecl *gDecl) { SetterMethodDecl = gDecl; } 114533de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian 114646b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian // Related to @optional/@required declared in @protocol 114746b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian void setPropertyImplementation(PropertyControl pc) { 114846b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian PropertyImplementation = pc; 114946b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian } 115046b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian PropertyControl getPropertyImplementation() const { 115146b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian return PropertyControl(PropertyImplementation); 115246b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian } 115346b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian 1154af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian void setPropertyIvarDecl(ObjCIvarDecl *Ivar) { 1155af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian PropertyIvarDecl = Ivar; 1156af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian } 1157af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian ObjCIvarDecl *getPropertyIvarDecl() const { 1158af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian return PropertyIvarDecl; 1159af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian } 1160af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian 116182a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian static bool classof(const Decl *D) { 1162670aa9d7639278f507930e95dc89c12032ab7c7eSam Bishop return D->getKind() == ObjCProperty; 116382a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian } 1164a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCPropertyDecl *D) { return true; } 116582a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian}; 1166980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 116761d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian/// ObjCPropertyImplDecl - Represents implementation declaration of a property 116861d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian/// in a class or category implementation block. For example: 116961d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian/// @synthesize prop1 = ivar1; 117061d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian/// 11714afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCPropertyImplDecl : public Decl { 117261d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanianpublic: 11739f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar enum Kind { 11749f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar Synthesize, 11759f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar Dynamic 117661d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian }; 117761d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanianprivate: 1178559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian SourceLocation AtLoc; // location of @synthesize or @dynamic 117961d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian /// Property declaration being implemented 118061d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian ObjCPropertyDecl *PropertyDecl; 1181be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek 118261d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian /// Null for @dynamic. Required for @synthesize. 118361d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian ObjCIvarDecl *PropertyIvarDecl; 1184be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek 1185d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor ObjCPropertyImplDecl(DeclContext *DC, SourceLocation atLoc, SourceLocation L, 1186628b96f34e93b643b6e15e75eabb8d96079a7e27Fariborz Jahanian ObjCPropertyDecl *property, 11879f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar Kind PK, 1188628b96f34e93b643b6e15e75eabb8d96079a7e27Fariborz Jahanian ObjCIvarDecl *ivarDecl) 1189af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian : Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc), 1190d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor PropertyDecl(property), PropertyIvarDecl(ivarDecl) { 11919f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar assert (PK == Dynamic || PropertyIvarDecl); 11929f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar } 1193628b96f34e93b643b6e15e75eabb8d96079a7e27Fariborz Jahanian 11949f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbarpublic: 1195d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCPropertyImplDecl *Create(ASTContext &C, DeclContext *DC, 1196d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor SourceLocation atLoc, SourceLocation L, 1197628b96f34e93b643b6e15e75eabb8d96079a7e27Fariborz Jahanian ObjCPropertyDecl *property, 11989f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar Kind PK, 1199628b96f34e93b643b6e15e75eabb8d96079a7e27Fariborz Jahanian ObjCIvarDecl *ivarDecl); 120061d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian 1201d40910b581b09c937a8c1fdcde9b8ec724398fb9Steve Naroff SourceLocation getLocStart() const { return AtLoc; } 12028818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor void setAtLoc(SourceLocation Loc) { AtLoc = Loc; } 1203d40910b581b09c937a8c1fdcde9b8ec724398fb9Steve Naroff 1204be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek ObjCPropertyDecl *getPropertyDecl() const { 1205be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek return PropertyDecl; 1206be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek } 12078818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor void setPropertyDecl(ObjCPropertyDecl *Prop) { PropertyDecl = Prop; } 12088818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor 12099f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar Kind getPropertyImplementation() const { 12109f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar return PropertyIvarDecl ? Synthesize : Dynamic; 1211be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek } 121261d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian 1213af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar ObjCIvarDecl *getPropertyIvarDecl() const { 1214be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek return PropertyIvarDecl; 1215be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek } 12168818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor void setPropertyIvarDecl(ObjCIvarDecl *Ivar) { PropertyIvarDecl = Ivar; } 12178818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor 121861d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian static bool classof(const Decl *D) { 121961d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian return D->getKind() == ObjCPropertyImpl; 122061d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian } 122161d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian static bool classof(const ObjCPropertyImplDecl *D) { return true; } 122261d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian}; 122361d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian 1224980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff} // end namespace clang 1225980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#endif 1226