DeclObjC.h revision db8264e4c5ffd7af6fbad4ca4306bd382bb02691
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; 2460f8c868ffb346b78451a3eccaecd0461d2ae498Fariborz Jahanianclass RecordDecl; 25a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCIvarDecl; 26a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCMethodDecl; 27a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCProtocolDecl; 28a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCCategoryDecl; 29a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCPropertyDecl; 30f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanianclass ObjCPropertyImplDecl; 31cbb67480094b3bcb5b715acd827cbad55e2a204cSean Huntclass CXXCtorInitializer; 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 unsigned size() const { return NumElts; } 44793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner bool empty() const { return NumElts == 0; } 451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 46793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerprotected: 4738af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void set(void *const* InList, unsigned Elts, ASTContext &Ctx); 48793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner}; 491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 51793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// ObjCList - This is a simple template class used to hold various lists of 52793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// decls etc, which is heavily used by the ObjC front-end. This only use case 53793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// this supports is setting the list all at once and then reading elements out 54793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// of it. 55793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnertemplate <typename T> 56793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerclass ObjCList : public ObjCListBase { 57793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerpublic: 5838af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void set(T* const* InList, unsigned Elts, ASTContext &Ctx) { 5938af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner ObjCListBase::set(reinterpret_cast<void*const*>(InList), Elts, Ctx); 60793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner } 611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 62793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner typedef T* const * iterator; 63793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner iterator begin() const { return (iterator)List; } 64793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner iterator end() const { return (iterator)List+NumElts; } 651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 66793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner T* operator[](unsigned Idx) const { 67793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner assert(Idx < NumElts && "Invalid access"); 68793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner return (T*)List[Idx]; 693db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner } 703db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner}; 713db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner 7218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor/// \brief A list of Objective-C protocols, along with the source 7318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor/// locations at which they were referenced. 7418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregorclass ObjCProtocolList : public ObjCList<ObjCProtocolDecl> { 7518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor SourceLocation *Locations; 7618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor 7718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor using ObjCList<ObjCProtocolDecl>::set; 7818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor 7918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregorpublic: 8018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor ObjCProtocolList() : ObjCList<ObjCProtocolDecl>(), Locations(0) { } 8118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor 8218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor typedef const SourceLocation *loc_iterator; 8318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor loc_iterator loc_begin() const { return Locations; } 8418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor loc_iterator loc_end() const { return Locations + size(); } 8518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor 8618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor void set(ObjCProtocolDecl* const* InList, unsigned Elts, 8718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const SourceLocation *Locs, ASTContext &Ctx); 8818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor}; 891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 91a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCMethodDecl - Represents an instance or class method declaration. 9258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// ObjC methods can be declared within 4 contexts: class interfaces, 9358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// categories, protocols, and class implementations. While C++ member 941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// functions leverage C syntax, Objective-C method syntax is modeled after 951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// Smalltalk (using colons to specify argument types/expressions). 9658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Here are some brief examples: 9758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// 9858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Setter/getter instance methods: 9958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// - (void)setMenu:(NSMenu *)menu; 1001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// - (NSMenu *)menu; 1011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 10258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Instance method that takes 2 NSView arguments: 10358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// - (void)replaceSubview:(NSView *)oldView with:(NSView *)newView; 10458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// 10558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Getter class method: 10658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// + (NSMenu *)defaultMenu; 10758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// 10858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// A selector represents a unique name for a method. The selector names for 10958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// the above methods are setMenu:, menu, replaceSubview:with:, and defaultMenu. 11058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// 1114afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCMethodDecl : public NamedDecl, public DeclContext { 11258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroffpublic: 11358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff enum ImplementationControl { None, Required, Optional }; 11458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroffprivate: 11585f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall // The conventional meaning of this method; an ObjCMethodFamily. 11685f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall // This is not serialized; instead, it is computed on demand and 11785f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall // cached. 11885f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall mutable unsigned Family : ObjCMethodFamilyBitWidth; 11985f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall 12058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff /// instance (true) or class (false) method. 12185f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall unsigned IsInstance : 1; 12285f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall unsigned IsVariadic : 1; 1231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1244607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian // Synthesized declaration method for a property setter/getter 12585f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall unsigned IsSynthesized : 1; 1263fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian 1273fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian // Method has a definition. 12885f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall unsigned IsDefined : 1; 1291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 130ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek // NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum 13158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff /// @required/@optional 132ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek unsigned DeclImplementation : 2; 1331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 134ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek // NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum 13558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff /// in, inout, etc. 136ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek unsigned objcDeclQualifier : 6; 1371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 138926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor /// \brief Indicates whether this method has a related result type. 139926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor unsigned RelatedResultType : 1; 140926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor 1417732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian // Number of args separated by ':' in a method declaration. 1427732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian unsigned NumSelectorArgs; 1437732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian 1444bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor // Result type of this method. 14558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff QualType MethodDeclType; 1464bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor 1474bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor // Type source information for the result type. 1484bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor TypeSourceInfo *ResultTInfo; 1494bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor 1502073216a1075767b5d25c23d1462b7034686d94dChris Lattner /// ParamInfo - List of pointers to VarDecls for the formal parameters of this 1512073216a1075767b5d25c23d1462b7034686d94dChris Lattner /// Method. 1522073216a1075767b5d25c23d1462b7034686d94dChris Lattner ObjCList<ParmVarDecl> ParamInfo; 1531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff /// List of attributes for this method declaration. 155a2e85ada1dfef36201a31f6646bc4ea3bd76a89aArgyrios Kyrtzidis SourceLocation EndLoc; // the location of the ';' or '}'. 1561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff // The following are only used for method definitions, null otherwise. 15858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff // FIXME: space savings opportunity, consider a sub-class. 15958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff Stmt *Body; 160451318c08a6342c10b8986060386fd9274418437Daniel Dunbar 161451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// SelfDecl - Decl for the implicit self parameter. This is lazily 162451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// constructed by createImplicitParams. 1634111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner ImplicitParamDecl *SelfDecl; 164451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// CmdDecl - Decl for the implicit _cmd parameter. This is lazily 165451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// constructed by createImplicitParams. 1664111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner ImplicitParamDecl *CmdDecl; 1671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 168a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc, 16958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff Selector SelInfo, QualType T, 1704bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor TypeSourceInfo *ResultTInfo, 1710701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff DeclContext *contextDecl, 172f6414927e67e27d9324d8d179c5f7ea620443924Daniel Dunbar bool isInstance = true, 17358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff bool isVariadic = false, 1744607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian bool isSynthesized = false, 1753fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian bool isDefined = false, 1767732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian ImplementationControl impControl = None, 177926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor bool HasRelatedResultType = false, 1787732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian unsigned numSelectorArgs = 0) 1794afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor : NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo), 18085f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall DeclContext(ObjCMethod), Family(InvalidObjCMethodFamily), 18158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff IsInstance(isInstance), IsVariadic(isVariadic), 1824607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian IsSynthesized(isSynthesized), 1833fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian IsDefined(isDefined), 18458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None), 185926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor RelatedResultType(HasRelatedResultType), NumSelectorArgs(numSelectorArgs), 186926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor MethodDeclType(T), ResultTInfo(ResultTInfo), 1874111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner EndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) {} 1888a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek 18957ea6bee79cc60ba20c7886b453f40f380dce1b1Argyrios Kyrtzidis /// \brief A definition will return its interface declaration. 19057ea6bee79cc60ba20c7886b453f40f380dce1b1Argyrios Kyrtzidis /// An interface declaration will return its definition. 19157ea6bee79cc60ba20c7886b453f40f380dce1b1Argyrios Kyrtzidis /// Otherwise it will return itself. 192da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor virtual ObjCMethodDecl *getNextRedeclaration(); 193da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor 1946c4ae5de0c356777446f823b573821fb95560d91Chris Lattnerpublic: 1950ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner static ObjCMethodDecl *Create(ASTContext &C, 1961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation beginLoc, 1976c4ae5de0c356777446f823b573821fb95560d91Chris Lattner SourceLocation endLoc, Selector SelInfo, 1984bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor QualType T, 1994bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor TypeSourceInfo *ResultTInfo, 2004bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor DeclContext *contextDecl, 201f6414927e67e27d9324d8d179c5f7ea620443924Daniel Dunbar bool isInstance = true, 2026c4ae5de0c356777446f823b573821fb95560d91Chris Lattner bool isVariadic = false, 2034607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian bool isSynthesized = false, 2043fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian bool isDefined = false, 2057732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian ImplementationControl impControl = None, 206926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor bool HasRelatedResultType = false, 2077732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian unsigned numSelectorArgs = 0); 208e7f9d301a10b4b3223e91d9be4362b44cba0a212Argyrios Kyrtzidis 209da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor virtual ObjCMethodDecl *getCanonicalDecl(); 21013e635c55eb23f736d38abf9c954801bd6482db4Ted Kremenek const ObjCMethodDecl *getCanonicalDecl() const { 21113e635c55eb23f736d38abf9c954801bd6482db4Ted Kremenek return const_cast<ObjCMethodDecl*>(this)->getCanonicalDecl(); 21213e635c55eb23f736d38abf9c954801bd6482db4Ted Kremenek } 213e7f9d301a10b4b3223e91d9be4362b44cba0a212Argyrios Kyrtzidis 214ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek ObjCDeclQualifier getObjCDeclQualifier() const { 215ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek return ObjCDeclQualifier(objcDeclQualifier); 216ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek } 217a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek void setObjCDeclQualifier(ObjCDeclQualifier QV) { objcDeclQualifier = QV; } 2181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 219926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor /// \brief Determine whether this method has a result type that is related 220926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor /// to the message receiver's type. 221926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor bool hasRelatedResultType() const { return RelatedResultType; } 222926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor 223926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor /// \brief Note whether this method has a related result type. 224926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor void SetRelatedResultType(bool RRT = true) { RelatedResultType = RRT; } 225926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor 2267732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian unsigned getNumSelectorArgs() const { return NumSelectorArgs; } 2277732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian void setNumSelectorArgs(unsigned numSelectorArgs) { 2287732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian NumSelectorArgs = numSelectorArgs; 2297732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian } 2307732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian 23158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff // Location information, modeled after the Stmt API. 23258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff SourceLocation getLocStart() const { return getLocation(); } 23358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff SourceLocation getLocEnd() const { return EndLoc; } 23453c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setEndLoc(SourceLocation Loc) { EndLoc = Loc; } 235da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor virtual SourceRange getSourceRange() const { 2361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return SourceRange(getLocation(), EndLoc); 2379776ba0d844cf9f6888e871e3fd246ae782f76f4Daniel Dunbar } 2381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2395619688510185081cbb4621d703daf7ee24cf39aChris Lattner ObjCInterfaceDecl *getClassInterface(); 2405619688510185081cbb4621d703daf7ee24cf39aChris Lattner const ObjCInterfaceDecl *getClassInterface() const { 2415619688510185081cbb4621d703daf7ee24cf39aChris Lattner return const_cast<ObjCMethodDecl*>(this)->getClassInterface(); 242e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner } 2431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2442e1cd4264d363ca869bf37ef160902f211d21b8cDouglas Gregor Selector getSelector() const { return getDeclName().getObjCSelector(); } 2453a082d81006e7a2e01a6e431a22e21c78490ff8fAnders Carlsson 24658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff QualType getResultType() const { return MethodDeclType; } 24753c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setResultType(QualType T) { MethodDeclType = T; } 2481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2495291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor /// \brief Determine the type of an expression that sends a message to this 2505291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor /// function. 2515291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor QualType getSendResultType() const { 2526398235d7890a81b785ea5af3b6e66d86bf184ccDouglas Gregor return getResultType().getNonLValueExprType(getASTContext()); 2535291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor } 2545291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor 2554bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor TypeSourceInfo *getResultTypeSourceInfo() const { return ResultTInfo; } 2564bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor void setResultTypeSourceInfo(TypeSourceInfo *TInfo) { ResultTInfo = TInfo; } 2574bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor 258d57f635d520e8cb5b93d3d770ff58db06c62de54Chris Lattner // Iterator access to formal parameters. 2592073216a1075767b5d25c23d1462b7034686d94dChris Lattner unsigned param_size() const { return ParamInfo.size(); } 2602073216a1075767b5d25c23d1462b7034686d94dChris Lattner typedef ObjCList<ParmVarDecl>::iterator param_iterator; 2612073216a1075767b5d25c23d1462b7034686d94dChris Lattner param_iterator param_begin() const { return ParamInfo.begin(); } 2622073216a1075767b5d25c23d1462b7034686d94dChris Lattner param_iterator param_end() const { return ParamInfo.end(); } 2637732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian // This method returns and of the parameters which are part of the selector 2647732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian // name mangling requirements. 2657732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian param_iterator sel_param_end() const { 2667732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian return ParamInfo.begin() + NumSelectorArgs; 2677732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian } 26889951a86b594513c2a013532ed45d197413b1087Chris Lattner 2694ecb25fa94897b2c03510292acace710e5262ba5Fariborz Jahanian void setMethodParams(ASTContext &C, ParmVarDecl *const *List, unsigned Num, 2704ecb25fa94897b2c03510292acace710e5262ba5Fariborz Jahanian unsigned numSelectorArgs) { 27138af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner ParamInfo.set(List, Num, C); 2724ecb25fa94897b2c03510292acace710e5262ba5Fariborz Jahanian NumSelectorArgs = numSelectorArgs; 2732073216a1075767b5d25c23d1462b7034686d94dChris Lattner } 2744111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner 2756ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson // Iterator access to parameter types. 2766ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson typedef std::const_mem_fun_t<QualType, ParmVarDecl> deref_fun; 2776ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson typedef llvm::mapped_iterator<param_iterator, deref_fun> arg_type_iterator; 2786ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson 2796ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson arg_type_iterator arg_type_begin() const { 2806ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson return llvm::map_iterator(param_begin(), deref_fun(&ParmVarDecl::getType)); 2816ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson } 2826ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson arg_type_iterator arg_type_end() const { 2836ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson return llvm::map_iterator(param_end(), deref_fun(&ParmVarDecl::getType)); 2846ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson } 2851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 286451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// createImplicitParams - Used to lazily create the self and cmd 287451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// implict parameters. This must be called prior to using getSelfDecl() 288451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// or getCmdDecl(). The call is ignored if the implicit paramters 289451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// have already been created. 290fef30b55230064d334a669a065a1c9acdb87cdfeFariborz Jahanian void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID); 291451318c08a6342c10b8986060386fd9274418437Daniel Dunbar 2924111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner ImplicitParamDecl * getSelfDecl() const { return SelfDecl; } 29353c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setSelfDecl(ImplicitParamDecl *SD) { SelfDecl = SD; } 2944111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner ImplicitParamDecl * getCmdDecl() const { return CmdDecl; } 29553c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setCmdDecl(ImplicitParamDecl *CD) { CmdDecl = CD; } 2961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 29785f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall /// Determines the family of this method. 29885f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall ObjCMethodFamily getMethodFamily() const; 29985f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall 300f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor bool isInstanceMethod() const { return IsInstance; } 30153c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setInstanceMethod(bool isInst) { IsInstance = isInst; } 30258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff bool isVariadic() const { return IsVariadic; } 30353c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setVariadic(bool isVar) { IsVariadic = isVar; } 3041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 305f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor bool isClassMethod() const { return !IsInstance; } 306f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor 3074607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian bool isSynthesized() const { return IsSynthesized; } 30853c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setSynthesized(bool isSynth) { IsSynthesized = isSynth; } 3093fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian 3103fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian bool isDefined() const { return IsDefined; } 3113fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian void setDefined(bool isDefined) { IsDefined = isDefined; } 3121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 31358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff // Related to protocols declared in @protocol 3141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void setDeclImplementation(ImplementationControl ic) { 3151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump DeclImplementation = ic; 31658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff } 3171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ImplementationControl getImplementationControl() const { 3181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return ImplementationControl(DeclImplementation); 31958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff } 320792481eec23d8c1aa92173be589e2ae9d02514a5Ted Kremenek 321da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor virtual Stmt *getBody() const { 3221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return (Stmt*) Body; 3237297134f128423fce2e88f92421ed135bded7d4eDouglas Gregor } 3246fb0aee4f9dc261bbec72e1283ad8dc0557a6d96Argyrios Kyrtzidis CompoundStmt *getCompoundBody() { return (CompoundStmt*)Body; } 325d3a413d3b8eb39bcee5944bc545d9997c1abe492Sebastian Redl void setBody(Stmt *B) { Body = B; } 32658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 32766570b230941651245accbc5680b60e904eb993cArgyrios Kyrtzidis /// \brief Returns whether this specific method is a definition. 32866570b230941651245accbc5680b60e904eb993cArgyrios Kyrtzidis bool isThisDeclarationADefinition() const { return Body; } 32966570b230941651245accbc5680b60e904eb993cArgyrios Kyrtzidis 33058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff // Implement isa/cast/dyncast/etc. 33180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 332a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCMethodDecl *D) { return true; } 33380cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCMethod; } 33442220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis static DeclContext *castToDeclContext(const ObjCMethodDecl *D) { 33542220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis return static_cast<DeclContext *>(const_cast<ObjCMethodDecl*>(D)); 33642220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis } 33742220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis static ObjCMethodDecl *castFromDeclContext(const DeclContext *DC) { 33842220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis return static_cast<ObjCMethodDecl *>(const_cast<DeclContext*>(DC)); 33942220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis } 34058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff}; 341e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 342e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff/// ObjCContainerDecl - Represents a container for method declarations. 343aecae629269fae3bf484baf1d109e9a89d14eeadArgyrios Kyrtzidis/// Current sub-classes are ObjCInterfaceDecl, ObjCCategoryDecl, 3441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// ObjCProtocolDecl, and ObjCImplDecl. 345e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff/// 3464afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCContainerDecl : public NamedDecl, public DeclContext { 347782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek // These two locations in the range mark the end of the method container. 348782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek // The first points to the '@' token, and the second to the 'end' token. 349782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek SourceRange AtEnd; 350e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroffpublic: 351e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 3521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ObjCContainerDecl(Kind DK, DeclContext *DC, SourceLocation L, 353d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor IdentifierInfo *Id) 3544afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor : NamedDecl(DK, DC, L, Id), DeclContext(DK) {} 355e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 35693983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff // Iterator access to properties. 35793983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff typedef specific_decl_iterator<ObjCPropertyDecl> prop_iterator; 3581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump prop_iterator prop_begin() const { 35917945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return prop_iterator(decls_begin()); 36093983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff } 3611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump prop_iterator prop_end() const { 36217945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return prop_iterator(decls_end()); 36309c4719788a5cea09897525e528fa00420f1677bSteve Naroff } 3641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3650701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff // Iterator access to instance/class methods. 366f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor typedef specific_decl_iterator<ObjCMethodDecl> method_iterator; 3671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump method_iterator meth_begin() const { 36817945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return method_iterator(decls_begin()); 3697ed4faca5162b3ab85be7f7e57aa40e6ec170971Ted Kremenek } 3701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump method_iterator meth_end() const { 37117945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return method_iterator(decls_end()); 3727ed4faca5162b3ab85be7f7e57aa40e6ec170971Ted Kremenek } 3730701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff 3741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump typedef filtered_decl_iterator<ObjCMethodDecl, 3751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump &ObjCMethodDecl::isInstanceMethod> 376669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor instmeth_iterator; 37717945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis instmeth_iterator instmeth_begin() const { 37817945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return instmeth_iterator(decls_begin()); 379e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff } 38017945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis instmeth_iterator instmeth_end() const { 38117945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return instmeth_iterator(decls_end()); 382e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff } 383e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 3841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump typedef filtered_decl_iterator<ObjCMethodDecl, 3851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump &ObjCMethodDecl::isClassMethod> 386669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor classmeth_iterator; 38717945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis classmeth_iterator classmeth_begin() const { 38817945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return classmeth_iterator(decls_begin()); 389e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff } 39017945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis classmeth_iterator classmeth_end() const { 39117945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return classmeth_iterator(decls_end()); 3920701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff } 3930701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff 3940701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff // Get the local instance/class method declared in this interface. 395467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis ObjCMethodDecl *getMethod(Selector Sel, bool isInstance) const; 396467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis ObjCMethodDecl *getInstanceMethod(Selector Sel) const { 397467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis return getMethod(Sel, true/*isInstance*/); 39853df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner } 399467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis ObjCMethodDecl *getClassMethod(Selector Sel) const { 400467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis return getMethod(Sel, false/*isInstance*/); 401467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis } 402467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis ObjCIvarDecl *getIvarDecl(IdentifierInfo *Id) const; 4031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 40417945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const; 40593983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff 406e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff // Marks the end of the container. 407782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek SourceRange getAtEndRange() const { 408782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek return AtEnd; 409782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek } 410782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek void setAtEndRange(SourceRange atEnd) { 411782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek AtEnd = atEnd; 412782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek } 413ddfd4c9eda34765b08fae4cb31ad5a365face107Argyrios Kyrtzidis 414da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor virtual SourceRange getSourceRange() const { 415782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek return SourceRange(getLocation(), getAtEndRange().getEnd()); 416ddfd4c9eda34765b08fae4cb31ad5a365face107Argyrios Kyrtzidis } 4171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 41809c4719788a5cea09897525e528fa00420f1677bSteve Naroff // Implement isa/cast/dyncast/etc. 41980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 42009c4719788a5cea09897525e528fa00420f1677bSteve Naroff static bool classof(const ObjCContainerDecl *D) { return true; } 42180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { 4229a55591af3e5506b95a9718e15380129fbfc5ebcSean Hunt return K >= firstObjCContainer && 4239a55591af3e5506b95a9718e15380129fbfc5ebcSean Hunt K <= lastObjCContainer; 42480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall } 42509c4719788a5cea09897525e528fa00420f1677bSteve Naroff 42609c4719788a5cea09897525e528fa00420f1677bSteve Naroff static DeclContext *castToDeclContext(const ObjCContainerDecl *D) { 42709c4719788a5cea09897525e528fa00420f1677bSteve Naroff return static_cast<DeclContext *>(const_cast<ObjCContainerDecl*>(D)); 42809c4719788a5cea09897525e528fa00420f1677bSteve Naroff } 42909c4719788a5cea09897525e528fa00420f1677bSteve Naroff static ObjCContainerDecl *castFromDeclContext(const DeclContext *DC) { 43009c4719788a5cea09897525e528fa00420f1677bSteve Naroff return static_cast<ObjCContainerDecl *>(const_cast<DeclContext*>(DC)); 43109c4719788a5cea09897525e528fa00420f1677bSteve Naroff } 432e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff}; 433e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 434a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCInterfaceDecl - Represents an ObjC class declaration. For example: 4350c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 4360c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// // MostPrimitive declares no super class (not particularly useful). 4371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// @interface MostPrimitive 4380c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// // no instance variables or methods. 4390c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end 4400c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 4411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// // NSResponder inherits from NSObject & implements NSCoding (a protocol). 4420c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @interface NSResponder : NSObject <NSCoding> 443a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// { // instance variables are represented by ObjCIvarDecl. 4440c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id nextResponder; // nextResponder instance variable. 4450c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// } 4460c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSResponder *)nextResponder; // return a pointer to NSResponder. 4470c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (void)mouseMoved:(NSEvent *)theEvent; // return void, takes a pointer 4480c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end // to an NSEvent. 4490c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 4500c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Unlike C/C++, forward class declarations are accomplished with @class. 4510c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Unlike C/C++, @class allows for a list of classes to be forward declared. 4520c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Unlike C++, ObjC is a single-rooted class model. In Cocoa, classes 4530c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// typically inherit from NSObject (an exception is NSProxy). 4540c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 455deacbdca554298ccdf636f19c6094a8825ec6b34Douglas Gregorclass ObjCInterfaceDecl : public ObjCContainerDecl { 4563110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff /// TypeForDecl - This indicates the Type object that represents this 4573110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff /// TypeDecl. It is a cache maintained by ASTContext::getObjCInterfaceType 458f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall mutable const Type *TypeForDecl; 4593110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff friend class ASTContext; 4601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 461980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff /// Class's super class. 462a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *SuperClass; 4631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 46453b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek /// Protocols referenced in the @interface declaration 46518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor ObjCProtocolList ReferencedProtocols; 46653b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 46753b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek /// Protocols reference in both the @interface and class extensions. 46853b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek ObjCList<ObjCProtocolDecl> AllReferencedProtocols; 4691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4708c99d88a6cfa14fc2edab819d5e4325c973b2809Douglas Gregor /// \brief List of categories and class extensions defined for this class. 4718c99d88a6cfa14fc2edab819d5e4325c973b2809Douglas Gregor /// 4728c99d88a6cfa14fc2edab819d5e4325c973b2809Douglas Gregor /// Categories are stored as a linked list in the AST, since the categories 4738c99d88a6cfa14fc2edab819d5e4325c973b2809Douglas Gregor /// and class extensions come long after the initial interface declaration, 474fc8f0e14ad142ed811e90fbd9a30e419e301c717Chris Lattner /// and we avoid dynamically-resized arrays in the AST wherever possible. 475a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCCategoryDecl *CategoryList; 4762c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian 4772c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian /// IvarList - List of all ivars defined by this class; including class 4782c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian /// extensions and implementation. This list is built lazily. 4792c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian ObjCIvarDecl *IvarList; 4801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4813a3ca1b35a7121aea0bf465a192dce748465e10fFariborz Jahanian bool ForwardDecl:1; // declared with @class. 4823a3ca1b35a7121aea0bf465a192dce748465e10fFariborz Jahanian bool InternalInterface:1; // true - no @interface for @implementation 48326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 48426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor /// \brief Indicates that the contents of this Objective-C class will be 48526ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor /// completed by the external AST source when required. 48626ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor mutable bool ExternallyCompleted : 1; 48726ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 488d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff SourceLocation ClassLoc; // location of the class identifier. 489d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff SourceLocation SuperClassLoc; // location of the super class identifier. 490f908a87299d278164540f90b5b6e6cab7b14fb41Steve Naroff SourceLocation EndLoc; // marks the '>', '}', or identifier. 4910e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattner 492d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor ObjCInterfaceDecl(DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, 493deacbdca554298ccdf636f19c6094a8825ec6b34Douglas Gregor SourceLocation CLoc, bool FD, bool isInternal); 4941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 49526ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor void LoadExternalDefinition() const; 4960e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattnerpublic: 497d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCInterfaceDecl *Create(ASTContext &C, DeclContext *DC, 4980ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner SourceLocation atLoc, 4991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump IdentifierInfo *Id, 500deacbdca554298ccdf636f19c6094a8825ec6b34Douglas Gregor SourceLocation ClassLoc = SourceLocation(), 5010e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattner bool ForwardDecl = false, 5020e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattner bool isInternal = false); 50326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 50426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor /// \brief Indicate that this Objective-C class is complete, but that 50526ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor /// the external AST source will be responsible for filling in its contents 50626ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor /// when a complete class is required. 50726ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor void setExternallyCompleted(); 50826ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 50918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const ObjCProtocolList &getReferencedProtocols() const { 51026ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor if (ExternallyCompleted) 51126ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 51226ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 5131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return ReferencedProtocols; 5147ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian } 5158a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis 5168a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis ObjCImplementationDecl *getImplementation() const; 5178a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis void setImplementation(ObjCImplementationDecl *ImplD); 5188a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis 519559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian ObjCCategoryDecl *FindCategoryDeclaration(IdentifierInfo *CategoryId) const; 5201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5211cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis // Get the local instance/class method declared in a category. 5221cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis ObjCMethodDecl *getCategoryInstanceMethod(Selector Sel) const; 5231cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis ObjCMethodDecl *getCategoryClassMethod(Selector Sel) const; 5241cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis ObjCMethodDecl *getCategoryMethod(Selector Sel, bool isInstance) const { 5251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return isInstance ? getInstanceMethod(Sel) 5261cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis : getClassMethod(Sel); 5271cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis } 5283db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner 52918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor typedef ObjCProtocolList::iterator protocol_iterator; 53053b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 53153b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek protocol_iterator protocol_begin() const { 53226ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor if (ExternallyCompleted) 53326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 53426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 53553b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek return ReferencedProtocols.begin(); 53653b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek } 53753b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek protocol_iterator protocol_end() const { 53826ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor if (ExternallyCompleted) 53926ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 54026ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 54153b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek return ReferencedProtocols.end(); 54253b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek } 54353b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 54418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor typedef ObjCProtocolList::loc_iterator protocol_loc_iterator; 54553b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 54618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor protocol_loc_iterator protocol_loc_begin() const { 54726ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor if (ExternallyCompleted) 54826ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 54926ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 55018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor return ReferencedProtocols.loc_begin(); 55118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor } 55253b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 55318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor protocol_loc_iterator protocol_loc_end() const { 55426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor if (ExternallyCompleted) 55526ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 55626ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 55718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor return ReferencedProtocols.loc_end(); 55818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor } 55953b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 56053b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek typedef ObjCList<ObjCProtocolDecl>::iterator all_protocol_iterator; 56153b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 56253b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek all_protocol_iterator all_referenced_protocol_begin() const { 56326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor if (ExternallyCompleted) 56426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 56526ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 56653b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek return AllReferencedProtocols.empty() ? protocol_begin() 56753b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek : AllReferencedProtocols.begin(); 56853b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek } 56953b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek all_protocol_iterator all_referenced_protocol_end() const { 57026ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor if (ExternallyCompleted) 57126ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 57226ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 57353b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek return AllReferencedProtocols.empty() ? protocol_end() 57453b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek : AllReferencedProtocols.end(); 57553b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek } 576291be393aa33759e6e34b6429c5ffa206ba50115Douglas Gregor 57711062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator; 57853b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 579db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose ivar_iterator ivar_begin() const { return ivar_iterator(decls_begin()); } 58011062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian ivar_iterator ivar_end() const { return ivar_iterator(decls_end()); } 58153b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 58211062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian unsigned ivar_size() const { 58311062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian return std::distance(ivar_begin(), ivar_end()); 58411062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian } 58553b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 58611062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian bool ivar_empty() const { return ivar_begin() == ivar_end(); } 5872c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian 588db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose ObjCIvarDecl *all_declared_ivar_begin(); 589db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose const ObjCIvarDecl *all_declared_ivar_begin() const { 590db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose // Even though this modifies IvarList, it's conceptually const: 591db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose // the ivar chain is essentially a cached property of ObjCInterfaceDecl. 592db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose return const_cast<ObjCInterfaceDecl *>(this)->all_declared_ivar_begin(); 593db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose } 5942c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian void setIvarList(ObjCIvarDecl *ivar) { IvarList = ivar; } 5952c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian 59638af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner /// setProtocolList - Set the list of protocols that this interface 597b752f289026ad8e5f44851b20e009a27ed61eefcChris Lattner /// implements. 59838af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void setProtocolList(ObjCProtocolDecl *const* List, unsigned Num, 59918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const SourceLocation *Locs, ASTContext &C) { 60018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor ReferencedProtocols.set(List, Num, Locs, C); 6013db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner } 6021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 603339798eae1eb61c50ca68766ed028c0a16d0a284Fariborz Jahanian /// mergeClassExtensionProtocolList - Merge class extension's protocol list 604339798eae1eb61c50ca68766ed028c0a16d0a284Fariborz Jahanian /// into the protocol list for this class. 60518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor void mergeClassExtensionProtocolList(ObjCProtocolDecl *const* List, 60618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor unsigned Num, 60718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor ASTContext &C); 608339798eae1eb61c50ca68766ed028c0a16d0a284Fariborz Jahanian 609768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff bool isForwardDecl() const { return ForwardDecl; } 610768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff void setForwardDecl(bool val) { ForwardDecl = val; } 6111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 61226ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor ObjCInterfaceDecl *getSuperClass() const { 61326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor if (ExternallyCompleted) 61426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 61526ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 61626ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor return SuperClass; 61726ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor } 61826ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 619a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; } 6201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 62126ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor ObjCCategoryDecl* getCategoryList() const { 62226ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor if (ExternallyCompleted) 62326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 62426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 62526ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor return CategoryList; 62626ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor } 62726ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 6281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void setCategoryList(ObjCCategoryDecl *category) { 62953efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner CategoryList = category; 630980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff } 63180aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian 63280aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian ObjCCategoryDecl* getFirstClassExtension() const; 63337cafb077ad5b170acae77e566638603011ef4c0Ted Kremenek 63437cafb077ad5b170acae77e566638603011ef4c0Ted Kremenek ObjCPropertyDecl 63537cafb077ad5b170acae77e566638603011ef4c0Ted Kremenek *FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId) const; 63637cafb077ad5b170acae77e566638603011ef4c0Ted Kremenek 63753efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner /// isSuperClassOf - Return true if this class is the specified class or is a 63853efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner /// super class of the specified interface class. 63953efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner bool isSuperClassOf(const ObjCInterfaceDecl *I) const { 64053efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner // If RHS is derived from LHS it is OK; else it is not OK. 64153efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner while (I != NULL) { 64253efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner if (this == I) 64353efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner return true; 64453efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner I = I->getSuperClass(); 64553efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner } 64653efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner return false; 64753efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner } 6481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6497263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian /// isArcWeakrefUnavailable - Checks for a class or one of its super classes 6507263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian /// to be incompatible with __weak references. Returns true if it is. 6517263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian bool isArcWeakrefUnavailable() const { 6527263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian const ObjCInterfaceDecl *Class = this; 6537263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian while (Class) { 6547263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian if (Class->hasAttr<ArcWeakrefUnavailableAttr>()) 6557263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian return true; 6567263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian Class = Class->getSuperClass(); 6577263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian } 6587263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian return false; 6597263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian } 6607263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian 66117945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName, 66268a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner ObjCInterfaceDecl *&ClassDeclared); 66317945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName) { 66468a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner ObjCInterfaceDecl *ClassDeclared; 66517945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return lookupInstanceVariable(IVarName, ClassDeclared); 66668a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner } 66768a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner 66894a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff // Lookup a method. First, we search locally. If a method isn't 66994a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff // found, we search referenced protocols and class categories. 670aa5420c1e36ab8e0e4bb87239d8b73a3a8ce75dbArgyrios Kyrtzidis ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance) const; 671aa5420c1e36ab8e0e4bb87239d8b73a3a8ce75dbArgyrios Kyrtzidis ObjCMethodDecl *lookupInstanceMethod(Selector Sel) const { 672aa5420c1e36ab8e0e4bb87239d8b73a3a8ce75dbArgyrios Kyrtzidis return lookupMethod(Sel, true/*isInstance*/); 673aa5420c1e36ab8e0e4bb87239d8b73a3a8ce75dbArgyrios Kyrtzidis } 674aa5420c1e36ab8e0e4bb87239d8b73a3a8ce75dbArgyrios Kyrtzidis ObjCMethodDecl *lookupClassMethod(Selector Sel) const { 675aa5420c1e36ab8e0e4bb87239d8b73a3a8ce75dbArgyrios Kyrtzidis return lookupMethod(Sel, false/*isInstance*/); 676aa5420c1e36ab8e0e4bb87239d8b73a3a8ce75dbArgyrios Kyrtzidis } 677cd1876207f5564beba74e4b2524b664bdba0ba9fFariborz Jahanian ObjCInterfaceDecl *lookupInheritedClass(const IdentifierInfo *ICName); 678d789d3d985e28c9404e62157af46dcb7331920e0Steve Naroff 679d789d3d985e28c9404e62157af46dcb7331920e0Steve Naroff // Lookup a method in the classes implementation hierarchy. 68074b2756bc1f1f5f7c189996fe7e4cd3efef70263Fariborz Jahanian ObjCMethodDecl *lookupPrivateMethod(const Selector &Sel, bool Instance=true); 68160fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff 682ddfd4c9eda34765b08fae4cb31ad5a365face107Argyrios Kyrtzidis // Location information, modeled after the Stmt API. 68360fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff SourceLocation getLocStart() const { return getLocation(); } // '@'interface 684f908a87299d278164540f90b5b6e6cab7b14fb41Steve Naroff SourceLocation getLocEnd() const { return EndLoc; } 6857177dee8aee4b432911c91f1b788963bec0cac9fDaniel Dunbar void setLocEnd(SourceLocation LE) { EndLoc = LE; } 6861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 68733feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff void setClassLoc(SourceLocation Loc) { ClassLoc = Loc; } 688d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff SourceLocation getClassLoc() const { return ClassLoc; } 689d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff void setSuperClassLoc(SourceLocation Loc) { SuperClassLoc = Loc; } 690d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff SourceLocation getSuperClassLoc() const { return SuperClassLoc; } 6911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 69228e71cf851b73a67604735a9a95aef800b144e2eSteve Naroff /// isImplicitInterfaceDecl - check that this is an implicitly declared 693a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek /// ObjCInterfaceDecl node. This is for legacy objective-c @implementation 6944b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian /// declaration without an @interface declaration. 69533feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff bool isImplicitInterfaceDecl() const { return InternalInterface; } 69633feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff void setImplicitInterfaceDecl(bool val) { InternalInterface = val; } 6971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6980fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian /// ClassImplementsProtocol - Checks that 'lProto' protocol 6990fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian /// has been implemented in IDecl class, its super class or categories (if 7000fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian /// lookupCategory is true). 7010fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, 7020fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian bool lookupCategory, 7030fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian bool RHSIsQualifiedID = false); 7041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 70533feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff // Low-level accessor 706f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const Type *getTypeForDecl() const { return TypeForDecl; } 707f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall void setTypeForDecl(const Type *TD) const { TypeForDecl = TD; } 70833feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff 70980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 710a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCInterfaceDecl *D) { return true; } 71180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCInterface; } 71253b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 71353b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek friend class ASTDeclReader; 71453b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek friend class ASTDeclWriter; 715980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 716980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 717a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCIvarDecl - Represents an ObjC instance variable. In general, ObjC 7180c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// instance variables are identical to C. The only exception is Objective-C 7190c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// supports C++ style access control. For example: 7200c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 7210c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @interface IvarExample : NSObject 7220c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// { 723f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek/// id defaultToProtected; 7240c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @public: 7250c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id canBePublic; // same as C++. 7260c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @protected: 7270c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id canBeProtected; // same as C++. 7280c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @package: 7290c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id canBePackage; // framework visibility (not available in C++). 7300c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// } 7310c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 732a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCIvarDecl : public FieldDecl { 7330e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattnerpublic: 734980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff enum AccessControl { 735980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff None, Private, Protected, Public, Package 736980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff }; 7371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 738b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenekprivate: 739ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara ObjCIvarDecl(ObjCContainerDecl *DC, SourceLocation StartLoc, 740ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara SourceLocation IdLoc, IdentifierInfo *Id, 741ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW, 742ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian bool synthesized) 743ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara : FieldDecl(ObjCIvar, DC, StartLoc, IdLoc, Id, T, TInfo, BW, 7447a614d8380297fcd2bc23986241905d97222948cRichard Smith /*Mutable=*/false, /*HasInit=*/false), 745ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara NextIvar(0), DeclAccess(ac), Synthesized(synthesized) {} 7461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 747b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenekpublic: 748a06549226f45d5b72169a3d054415616dd1014a2Daniel Dunbar static ObjCIvarDecl *Create(ASTContext &C, ObjCContainerDecl *DC, 749ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara SourceLocation StartLoc, SourceLocation IdLoc, 750ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara IdentifierInfo *Id, QualType T, 751a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall TypeSourceInfo *TInfo, 752ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian AccessControl ac, Expr *BW = NULL, 753ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian bool synthesized=false); 7541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 75527a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar /// \brief Return the class interface that this ivar is logically contained 75627a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar /// in; this is either the interface where the ivar was declared, or the 75727a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar /// interface the ivar is conceptually a part of in the case of synthesized 75827a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar /// ivars. 75927a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar const ObjCInterfaceDecl *getContainingInterface() const; 7602c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian 7612c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian ObjCIvarDecl *getNextIvar() { return NextIvar; } 762db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose const ObjCIvarDecl *getNextIvar() const { return NextIvar; } 7632c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian void setNextIvar(ObjCIvarDecl *ivar) { NextIvar = ivar; } 76427a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar 765980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff void setAccessControl(AccessControl ac) { DeclAccess = ac; } 766f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek 767ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek AccessControl getAccessControl() const { return AccessControl(DeclAccess); } 768f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek 769f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek AccessControl getCanonicalAccessControl() const { 770f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek return DeclAccess == None ? Protected : AccessControl(DeclAccess); 771f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek } 7721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 773ac0021ba802e193e0f9f8207768c7862c7603bc0Fariborz Jahanian void setSynthesize(bool synth) { Synthesized = synth; } 774ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian bool getSynthesize() const { return Synthesized; } 775ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian 776980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff // Implement isa/cast/dyncast/etc. 77780cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 778a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCIvarDecl *D) { return true; } 77980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCIvar; } 780980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffprivate: 7812c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian /// NextIvar - Next Ivar in the list of ivars declared in class; class's 7822c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian /// extensions and class's implementation 7832c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian ObjCIvarDecl *NextIvar; 7842c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian 785ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek // NOTE: VC++ treats enums as signed, avoid using the AccessControl enum 786ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek unsigned DeclAccess : 3; 787ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian unsigned Synthesized : 1; 788980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 789980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 7901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 79101e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek/// ObjCAtDefsFieldDecl - Represents a field declaration created by an 79201e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek/// @defs(...). 79301e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenekclass ObjCAtDefsFieldDecl : public FieldDecl { 79401e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenekprivate: 795ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara ObjCAtDefsFieldDecl(DeclContext *DC, SourceLocation StartLoc, 796ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara SourceLocation IdLoc, IdentifierInfo *Id, 79701e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek QualType T, Expr *BW) 798ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara : FieldDecl(ObjCAtDefsField, DC, StartLoc, IdLoc, Id, T, 799a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall /*TInfo=*/0, // FIXME: Do ObjCAtDefs have declarators ? 8007a614d8380297fcd2bc23986241905d97222948cRichard Smith BW, /*Mutable=*/false, /*HasInit=*/false) {} 8011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 80201e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenekpublic: 80344b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor static ObjCAtDefsFieldDecl *Create(ASTContext &C, DeclContext *DC, 804ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara SourceLocation StartLoc, 805ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara SourceLocation IdLoc, IdentifierInfo *Id, 806ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara QualType T, Expr *BW); 8071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 80801e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek // Implement isa/cast/dyncast/etc. 80980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 81001e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek static bool classof(const ObjCAtDefsFieldDecl *D) { return true; } 81180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCAtDefsField; } 81201e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek}; 813980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 814a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCProtocolDecl - Represents a protocol declaration. ObjC protocols 8151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// declare a pure abstract type (i.e no instance variables are permitted). 816fc8f0e14ad142ed811e90fbd9a30e419e301c717Chris Lattner/// Protocols originally drew inspiration from C++ pure virtual functions (a C++ 8170c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// feature with nice semantics and lousy syntax:-). Here is an example: 8180c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 819eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// @protocol NSDraggingInfo <refproto1, refproto2> 8200c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSWindow *)draggingDestinationWindow; 8210c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSImage *)draggedImage; 8220c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end 8230c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 824eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// This says that NSDraggingInfo requires two methods and requires everything 825eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// that the two "referenced protocols" 'refproto1' and 'refproto2' require as 826eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// well. 827eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// 8280c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @interface ImplementsNSDraggingInfo : NSObject <NSDraggingInfo> 8290c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end 8300c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 831a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjC protocols inspired Java interfaces. Unlike Java, ObjC classes and 8320c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// protocols are in distinct namespaces. For example, Cocoa defines both 8331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// an NSObject protocol and class (which isn't allowed in Java). As a result, 8340c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// protocols are referenced using angle brackets as follows: 8350c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 8360c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id <NSDraggingInfo> anyObjectThatImplementsNSDraggingInfo; 8370c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 838e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroffclass ObjCProtocolDecl : public ObjCContainerDecl { 839780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner /// Referenced protocols 84018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor ObjCProtocolList ReferencedProtocols; 8411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 842980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff bool isForwardProtoDecl; // declared with @protocol. 8431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 844423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff SourceLocation EndLoc; // marks the '>' or identifier. 8451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 846d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor ObjCProtocolDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id) 8471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump : ObjCContainerDecl(ObjCProtocol, DC, L, Id), 848c858105d41602a2dadb2efbc1af80a7b791ebac3Chris Lattner isForwardProtoDecl(true) { 849cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattner } 8501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 851cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattnerpublic: 8521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static ObjCProtocolDecl *Create(ASTContext &C, DeclContext *DC, 853d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor SourceLocation L, IdentifierInfo *Id); 854cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattner 85518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const ObjCProtocolList &getReferencedProtocols() const { 856780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner return ReferencedProtocols; 857980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff } 85818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor typedef ObjCProtocolList::iterator protocol_iterator; 859780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();} 860780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner protocol_iterator protocol_end() const { return ReferencedProtocols.end(); } 86118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor typedef ObjCProtocolList::loc_iterator protocol_loc_iterator; 86218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor protocol_loc_iterator protocol_loc_begin() const { 86318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor return ReferencedProtocols.loc_begin(); 86418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor } 86518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor protocol_loc_iterator protocol_loc_end() const { 86618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor return ReferencedProtocols.loc_end(); 86718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor } 86830833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff unsigned protocol_size() const { return ReferencedProtocols.size(); } 8691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 87038af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner /// setProtocolList - Set the list of protocols that this interface 871780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner /// implements. 87238af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num, 87318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const SourceLocation *Locs, ASTContext &C) { 87418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor ReferencedProtocols.set(List, Num, Locs, C); 875aebf0cba02c014ac8b19d615c654248e0e93779fFariborz Jahanian } 8761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 87791b0b0cf6b537cbcbca0038c7032f87161a41d31Steve Naroff ObjCProtocolDecl *lookupProtocolNamed(IdentifierInfo *PName); 8781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 87994a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff // Lookup a method. First, we search locally. If a method isn't 88094a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff // found, we search referenced protocols and class categories. 881094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance) const; 882094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis ObjCMethodDecl *lookupInstanceMethod(Selector Sel) const { 883094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis return lookupMethod(Sel, true/*isInstance*/); 884094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis } 885094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis ObjCMethodDecl *lookupClassMethod(Selector Sel) const { 886094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis return lookupMethod(Sel, false/*isInstance*/); 887094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis } 888d789d3d985e28c9404e62157af46dcb7331920e0Steve Naroff 889768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff bool isForwardDecl() const { return isForwardProtoDecl; } 890768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff void setForwardDecl(bool val) { isForwardProtoDecl = val; } 891980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 8921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump // Location information, modeled after the Stmt API. 893423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff SourceLocation getLocStart() const { return getLocation(); } // '@'protocol 894423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff SourceLocation getLocEnd() const { return EndLoc; } 8957177dee8aee4b432911c91f1b788963bec0cac9fDaniel Dunbar void setLocEnd(SourceLocation LE) { EndLoc = LE; } 8961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 89780cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 898a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCProtocolDecl *D) { return true; } 89980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCProtocol; } 900980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 9011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 902a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCClassDecl - Specifies a list of forward class declarations. For example: 90306ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff/// 90406ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff/// @class NSCursor, NSImage, NSPasteboard, NSWindow; 9050c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 9064afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCClassDecl : public Decl { 907321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenekpublic: 908321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek class ObjCClassRef { 909321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek ObjCInterfaceDecl *ID; 910321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek SourceLocation L; 911321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek public: 912321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek ObjCClassRef(ObjCInterfaceDecl *d, SourceLocation l) : ID(d), L(l) {} 913321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek SourceLocation getLocation() const { return L; } 914321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek ObjCInterfaceDecl *getInterface() const { return ID; } 915321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek }; 916321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenekprivate: 917321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek ObjCClassRef *ForwardDecls; 918321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek unsigned NumDecls; 9191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ObjCClassDecl(DeclContext *DC, SourceLocation L, 921321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek ObjCInterfaceDecl *const *Elts, const SourceLocation *Locs, 922321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek unsigned nElts, ASTContext &C); 92361f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattnerpublic: 924d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCClassDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, 9251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ObjCInterfaceDecl *const *Elts = 0, 926321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek const SourceLocation *Locs = 0, 92730833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff unsigned nElts = 0); 9282dbdd622d02d1bfbe1e5bcf421b07b74c7a748f1Ted Kremenek 929da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor virtual SourceRange getSourceRange() const; 9301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 931321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek typedef const ObjCClassRef* iterator; 932321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek iterator begin() const { return ForwardDecls; } 933321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek iterator end() const { return ForwardDecls + NumDecls; } 934321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek unsigned size() const { return NumDecls; } 93530833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff 93630833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff /// setClassList - Set the list of forward classes. 937321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek void setClassList(ASTContext &C, ObjCInterfaceDecl*const*List, 938321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek const SourceLocation *Locs, unsigned Num); 9391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 94080cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 941a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCClassDecl *D) { return true; } 94280cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCClass; } 94306ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff}; 94406ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff 945a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCForwardProtocolDecl - Specifies a list of forward protocol declarations. 94606ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff/// For example: 9471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 9480c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @protocol NSTextInput, NSChangeSpelling, NSDraggingInfo; 9491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 9504afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCForwardProtocolDecl : public Decl { 95118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor ObjCProtocolList ReferencedProtocols; 9521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 953d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L, 95438af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner ObjCProtocolDecl *const *Elts, unsigned nElts, 95518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const SourceLocation *Locs, ASTContext &C); 9561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 95761f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattnerpublic: 958d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCForwardProtocolDecl *Create(ASTContext &C, DeclContext *DC, 9591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation L, 96018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor ObjCProtocolDecl *const *Elts, 96118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor unsigned Num, 96218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const SourceLocation *Locs); 96318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor 96418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor static ObjCForwardProtocolDecl *Create(ASTContext &C, DeclContext *DC, 96518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor SourceLocation L) { 96618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor return Create(C, DC, L, 0, 0, 0); 96718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor } 96861f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner 96918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor typedef ObjCProtocolList::iterator protocol_iterator; 97030833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();} 97130833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff protocol_iterator protocol_end() const { return ReferencedProtocols.end(); } 97218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor typedef ObjCProtocolList::loc_iterator protocol_loc_iterator; 97318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor protocol_loc_iterator protocol_loc_begin() const { 97418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor return ReferencedProtocols.loc_begin(); 97518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor } 97618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor protocol_loc_iterator protocol_loc_end() const { 97718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor return ReferencedProtocols.loc_end(); 97818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor } 97918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor 98030833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff unsigned protocol_size() const { return ReferencedProtocols.size(); } 98130833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff 98230833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff /// setProtocolList - Set the list of forward protocols. 98330833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num, 98418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const SourceLocation *Locs, ASTContext &C) { 98518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor ReferencedProtocols.set(List, Num, Locs, C); 98630833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff } 98780cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 988a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCForwardProtocolDecl *D) { return true; } 98980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCForwardProtocol; } 990980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 991980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 992a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCCategoryDecl - Represents a category declaration. A category allows 9930c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// you to add methods to an existing class (without subclassing or modifying 9941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// the original class interface or implementation:-). Categories don't allow 9950c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// you to add instance data. The following example adds "myMethod" to all 9960c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// NSView's within a process: 9970c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 9980c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @interface NSView (MyViewMethods) 9990c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - myMethod; 10000c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end 10010c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 100233ced0b8550f3e7169f326944731ee02e9338659Douglas Gregor/// Categories also allow you to split the implementation of a class across 10030c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// several files (a feature more naturally supported in C++). 10040c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 10050c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Categories were originally inspired by dynamic languages such as Common 10061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// Lisp and Smalltalk. More traditional class-based languages (C++, Java) 10070c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// don't support this level of dynamism, which is both powerful and dangerous. 10080c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 1009e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroffclass ObjCCategoryDecl : public ObjCContainerDecl { 1010980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff /// Interface belonging to this category 1011a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *ClassInterface; 10121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 101368c82cf61228102aba1194efef222fa1478af2a8Chris Lattner /// referenced protocols in this category. 101418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor ObjCProtocolList ReferencedProtocols; 10151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1016a8ff9f455d94d9609766cfd5186b6e21dc2102f1Chris Lattner /// Next category belonging to this class. 1017a8ff9f455d94d9609766cfd5186b6e21dc2102f1Chris Lattner /// FIXME: this should not be a singly-linked list. Move storage elsewhere. 1018a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCCategoryDecl *NextClassCategory; 10191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1020000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian /// true of class extension has at least one bitfield ivar. 1021000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian bool HasSynthBitfield : 1; 1022000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian 10233db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor /// \brief The location of the '@' in '@interface' 10243db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor SourceLocation AtLoc; 10253db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor 10263db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor /// \brief The location of the category name in this declaration. 10273db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor SourceLocation CategoryNameLoc; 10281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 10293db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor ObjCCategoryDecl(DeclContext *DC, SourceLocation AtLoc, 10303db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, 10313db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor IdentifierInfo *Id) 10323db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor : ObjCContainerDecl(ObjCCategory, DC, ClassNameLoc, Id), 1033000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian ClassInterface(0), NextClassCategory(0), HasSynthBitfield(false), 1034000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian AtLoc(AtLoc), CategoryNameLoc(CategoryNameLoc) { 1035a906135721c350435319347d2672bbb3bf494f91Chris Lattner } 103661f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattnerpublic: 10371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1038d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCCategoryDecl *Create(ASTContext &C, DeclContext *DC, 10393db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor SourceLocation AtLoc, 10403db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor SourceLocation ClassNameLoc, 10413db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor SourceLocation CategoryNameLoc, 10423db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor IdentifierInfo *Id); 10431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1044e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner ObjCInterfaceDecl *getClassInterface() { return ClassInterface; } 1045e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } 1046a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek void setClassInterface(ObjCInterfaceDecl *IDecl) { ClassInterface = IDecl; } 10478a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis 10488a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis ObjCCategoryImplDecl *getImplementation() const; 10498a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis void setImplementation(ObjCCategoryImplDecl *ImplD); 10508a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis 105138af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner /// setProtocolList - Set the list of protocols that this interface 1052f7b2c98c16dfb2261ea57d40a1d5bc4738e73175Chris Lattner /// implements. 105338af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num, 105418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const SourceLocation *Locs, ASTContext &C) { 105518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor ReferencedProtocols.set(List, Num, Locs, C); 1056780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner } 10571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 105818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const ObjCProtocolList &getReferencedProtocols() const { 1059780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner return ReferencedProtocols; 10608f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian } 10611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 106218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor typedef ObjCProtocolList::iterator protocol_iterator; 1063780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();} 1064780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner protocol_iterator protocol_end() const { return ReferencedProtocols.end(); } 106530833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff unsigned protocol_size() const { return ReferencedProtocols.size(); } 106618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor typedef ObjCProtocolList::loc_iterator protocol_loc_iterator; 106718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor protocol_loc_iterator protocol_loc_begin() const { 106818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor return ReferencedProtocols.loc_begin(); 106918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor } 107018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor protocol_loc_iterator protocol_loc_end() const { 107118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor return ReferencedProtocols.loc_end(); 107218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor } 10731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1074a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCCategoryDecl *getNextClassCategory() const { return NextClassCategory; } 107530833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff void setNextClassCategory(ObjCCategoryDecl *Cat) { 107630833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff NextClassCategory = Cat; 107730833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff } 1078980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff void insertNextClassCategory() { 10793d58138992b9bc7b34aaa680f3ddf3971292eb7dSteve Naroff NextClassCategory = ClassInterface->getCategoryList(); 10803d58138992b9bc7b34aaa680f3ddf3971292eb7dSteve Naroff ClassInterface->setCategoryList(this); 10815e9888c2786bfffa6879a08ff40f5a11545eec23Douglas Gregor ClassInterface->setChangedSinceDeserialization(true); 1082980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff } 10833db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor 108425760611365be23556b32332f8a66ae21ea93ecfFariborz Jahanian bool IsClassExtension() const { return getIdentifier() == 0; } 108580aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian const ObjCCategoryDecl *getNextClassExtension() const; 108625760611365be23556b32332f8a66ae21ea93ecfFariborz Jahanian 1087000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian bool hasSynthBitfield() const { return HasSynthBitfield; } 1088000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian void setHasSynthBitfield (bool val) { HasSynthBitfield = val; } 1089000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian 10900e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator; 10910e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian ivar_iterator ivar_begin() const { 10920e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian return ivar_iterator(decls_begin()); 10930e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian } 10940e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian ivar_iterator ivar_end() const { 10950e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian return ivar_iterator(decls_end()); 10960e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian } 10970e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian unsigned ivar_size() const { 10980e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian return std::distance(ivar_begin(), ivar_end()); 10990e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian } 11000e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian bool ivar_empty() const { 11010e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian return ivar_begin() == ivar_end(); 11020e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian } 11030e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian 11043db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor SourceLocation getAtLoc() const { return AtLoc; } 11053db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor void setAtLoc(SourceLocation At) { AtLoc = At; } 11063db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor 11073db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; } 11083db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor void setCategoryNameLoc(SourceLocation Loc) { CategoryNameLoc = Loc; } 11093db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor 1110da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor virtual SourceRange getSourceRange() const { 11113db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor return SourceRange(AtLoc, getAtEndRange().getEnd()); 11123db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor } 11131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 111480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 1115a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCCategoryDecl *D) { return true; } 111680cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCCategory; } 1117980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 11180c6b6243d3efd958c17943130e2a773653511edcSteve Naroff 1119aecae629269fae3bf484baf1d109e9a89d14eeadArgyrios Kyrtzidisclass ObjCImplDecl : public ObjCContainerDecl { 11200d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff /// Class interface for this class/category implementation 1121a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *ClassInterface; 11221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 11233aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattnerprotected: 11243aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner ObjCImplDecl(Kind DK, DeclContext *DC, SourceLocation L, 11253aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner ObjCInterfaceDecl *classInterface) 11261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump : ObjCContainerDecl(DK, DC, L, 11271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump classInterface? classInterface->getIdentifier() : 0), 1128aecae629269fae3bf484baf1d109e9a89d14eeadArgyrios Kyrtzidis ClassInterface(classInterface) {} 11291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 113075c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattnerpublic: 1131e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } 1132e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner ObjCInterfaceDecl *getClassInterface() { return ClassInterface; } 11338a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis void setClassInterface(ObjCInterfaceDecl *IFace); 11342c2d43c557beca1b4ba4bd743f33978aecb46a97Douglas Gregor 11351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void addInstanceMethod(ObjCMethodDecl *method) { 11362c2d43c557beca1b4ba4bd743f33978aecb46a97Douglas Gregor // FIXME: Context should be set correctly before we get here. 1137653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor method->setLexicalDeclContext(this); 11381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump addDecl(method); 1139e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff } 11401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void addClassMethod(ObjCMethodDecl *method) { 11412c2d43c557beca1b4ba4bd743f33978aecb46a97Douglas Gregor // FIXME: Context should be set correctly before we get here. 1142653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor method->setLexicalDeclContext(this); 11431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump addDecl(method); 114453df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner } 11451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 114617945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis void addPropertyImplementation(ObjCPropertyImplDecl *property); 11471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 114817945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis ObjCPropertyImplDecl *FindPropertyImplDecl(IdentifierInfo *propertyId) const; 114917945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis ObjCPropertyImplDecl *FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const; 1150653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor 1151653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor // Iterator access to properties. 1152653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor typedef specific_decl_iterator<ObjCPropertyImplDecl> propimpl_iterator; 11531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump propimpl_iterator propimpl_begin() const { 115417945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return propimpl_iterator(decls_begin()); 1155559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian } 11561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump propimpl_iterator propimpl_end() const { 115717945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return propimpl_iterator(decls_end()); 1158559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian } 1159653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor 116080cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 1161bfb498d0996ef049efe9476f2802976fd145cd60Argyrios Kyrtzidis static bool classof(const ObjCImplDecl *D) { return true; } 116280cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { 11639a55591af3e5506b95a9718e15380129fbfc5ebcSean Hunt return K >= firstObjCImpl && K <= lastObjCImpl; 116480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall } 11653aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner}; 11661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 11671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// ObjCCategoryImplDecl - An object of this class encapsulates a category 11681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// @implementation declaration. If a category class has declaration of a 11691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// property, its implementation must be specified in the category's 11703aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @implementation declaration. Example: 11713aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @interface I @end 11723aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @interface I(CATEGORY) 11733aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @property int p1, d1; 11743aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @end 11753aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @implementation I(CATEGORY) 11763aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @dynamic p1,d1; 11773aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @end 11783aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// 11793aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// ObjCCategoryImplDecl 11803aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattnerclass ObjCCategoryImplDecl : public ObjCImplDecl { 11813aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner // Category name 11823aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner IdentifierInfo *Id; 11833aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner 11843aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner ObjCCategoryImplDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, 11853aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner ObjCInterfaceDecl *classInterface) 11863aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner : ObjCImplDecl(ObjCCategoryImpl, DC, L, classInterface), Id(Id) {} 11873aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattnerpublic: 11883aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner static ObjCCategoryImplDecl *Create(ASTContext &C, DeclContext *DC, 11893aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner SourceLocation L, IdentifierInfo *Id, 11903aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner ObjCInterfaceDecl *classInterface); 11911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 11920d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff /// getIdentifier - Get the identifier that names the category 11933aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner /// interface associated with this implementation. 11940d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff /// FIXME: This is a bad API, we are overriding the NamedDecl::getIdentifier() 11950d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff /// to mean something different. For example: 11960d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff /// ((NamedDecl *)SomeCategoryImplDecl)->getIdentifier() 11970d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff /// returns the class interface name, whereas 11980d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff /// ((ObjCCategoryImplDecl *)SomeCategoryImplDecl)->getIdentifier() 11990d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff /// returns the category name. 12001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump IdentifierInfo *getIdentifier() const { 12011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return Id; 12023aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner } 120310b0e1fa3aabd8877dbbc0df1f2414e04afd5fddDouglas Gregor void setIdentifier(IdentifierInfo *II) { Id = II; } 12041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12050d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff ObjCCategoryDecl *getCategoryDecl() const; 120610b0e1fa3aabd8877dbbc0df1f2414e04afd5fddDouglas Gregor 1207b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar /// getName - Get the name of identifier for the class interface associated 1208b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar /// with this implementation as a StringRef. 1209b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar // 1210b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar // FIXME: This is a bad API, we are overriding the NamedDecl::getName, to mean 1211b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar // something different. 1212686775deca8b8685eb90801495880e3abdd844c2Chris Lattner StringRef getName() const { 1213b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar return Id ? Id->getNameStart() : ""; 1214b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar } 1215b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar 12163aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner /// getNameAsCString - Get the name of identifier for the class 12173aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner /// interface associated with this implementation as a C string 12183aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner /// (const char*). 12197fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar // 1220b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar // FIXME: Deprecated, move clients to getName(). 12213aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner const char *getNameAsCString() const { 12227fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar return Id ? Id->getNameStart() : ""; 12233aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner } 12241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12253aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner /// @brief Get the name of the class associated with this interface. 12267fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar // 1227b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar // FIXME: Deprecated, move clients to getName(). 12283aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner std::string getNameAsString() const { 1229b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar return getName(); 12303aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner } 12311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 123280cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 1233a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCCategoryImplDecl *D) { return true; } 123480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCCategoryImpl;} 12358f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian}; 12368f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian 12378cc488fefb2fb04bc8d5398da29f0182f97934cfChris Lattnerraw_ostream &operator<<(raw_ostream &OS, 1238900fc6388e803868a34b9483510c345e9b49d7ebBenjamin Kramer const ObjCCategoryImplDecl *CID); 1239900fc6388e803868a34b9483510c345e9b49d7ebBenjamin Kramer 1240a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCImplementationDecl - Represents a class definition - this is where 12410c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// method definitions are specified. For example: 12420c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 124398abf4bd3526a00a0e5cf71a9462c181f97b1c81Fariborz Jahanian/// @code 12440c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @implementation MyClass 12450c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (void)myMethod { /* do something */ } 12460c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end 124798abf4bd3526a00a0e5cf71a9462c181f97b1c81Fariborz Jahanian/// @endcode 12480c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 12491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// Typically, instance variables are specified in the class interface, 1250ec0d7a6f4b0699cc9960e6d9fee0f957c64d1cf9Douglas Gregor/// *not* in the implementation. Nevertheless (for legacy reasons), we 125153df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner/// allow instance variables to be specified in the implementation. When 125253df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner/// specified, they need to be *identical* to the interface. 12530c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 12541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumpclass ObjCImplementationDecl : public ObjCImplDecl { 1255980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff /// Implementation Class's super class. 1256a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *SuperClass; 1257e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// Support for ivar initialization. 1258e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// IvarInitializers - The arguments used to initialize the ivars 1259cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt CXXCtorInitializer **IvarInitializers; 1260e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian unsigned NumIvarInitializers; 1261f85e193739c953358c865005855253af4f68a497John McCall 1262f85e193739c953358c865005855253af4f68a497John McCall /// true if class has a .cxx_[construct,destruct] method. 1263f85e193739c953358c865005855253af4f68a497John McCall bool HasCXXStructors : 1; 1264e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian 1265000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian /// true of class extension has at least one bitfield ivar. 1266000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian bool HasSynthBitfield : 1; 1267000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian 12681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ObjCImplementationDecl(DeclContext *DC, SourceLocation L, 1269a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *classInterface, 1270a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *superDecl) 12711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump : ObjCImplDecl(ObjCImplementation, DC, L, classInterface), 1272000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian SuperClass(superDecl), IvarInitializers(0), NumIvarInitializers(0), 1273f85e193739c953358c865005855253af4f68a497John McCall HasCXXStructors(false), HasSynthBitfield(false) {} 12741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumppublic: 12751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static ObjCImplementationDecl *Create(ASTContext &C, DeclContext *DC, 12761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation L, 127775c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattner ObjCInterfaceDecl *classInterface, 127875c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattner ObjCInterfaceDecl *superDecl); 1279e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian 1280e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// init_iterator - Iterates through the ivar initializer list. 1281cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt typedef CXXCtorInitializer **init_iterator; 1282e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian 1283e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// init_const_iterator - Iterates through the ivar initializer list. 1284cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt typedef CXXCtorInitializer * const * init_const_iterator; 1285e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian 1286e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// init_begin() - Retrieve an iterator to the first initializer. 1287e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian init_iterator init_begin() { return IvarInitializers; } 1288e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// begin() - Retrieve an iterator to the first initializer. 1289e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian init_const_iterator init_begin() const { return IvarInitializers; } 1290e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian 1291e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// init_end() - Retrieve an iterator past the last initializer. 1292e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian init_iterator init_end() { 1293e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian return IvarInitializers + NumIvarInitializers; 1294e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian } 1295e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// end() - Retrieve an iterator past the last initializer. 1296e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian init_const_iterator init_end() const { 1297e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian return IvarInitializers + NumIvarInitializers; 1298e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian } 1299e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// getNumArgs - Number of ivars which must be initialized. 1300e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian unsigned getNumIvarInitializers() const { 1301e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian return NumIvarInitializers; 1302e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian } 1303e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian 1304e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian void setNumIvarInitializers(unsigned numNumIvarInitializers) { 1305e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian NumIvarInitializers = numNumIvarInitializers; 1306e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian } 1307e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian 1308e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian void setIvarInitializers(ASTContext &C, 1309cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt CXXCtorInitializer ** initializers, 1310e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian unsigned numInitializers); 1311f85e193739c953358c865005855253af4f68a497John McCall 1312f85e193739c953358c865005855253af4f68a497John McCall bool hasCXXStructors() const { return HasCXXStructors; } 1313f85e193739c953358c865005855253af4f68a497John McCall void setHasCXXStructors(bool val) { HasCXXStructors = val; } 1314000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian 1315000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian bool hasSynthBitfield() const { return HasSynthBitfield; } 1316000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian void setHasSynthBitfield (bool val) { HasSynthBitfield = val; } 1317e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian 13184afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// getIdentifier - Get the identifier that names the class 13194afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// interface associated with this implementation. 13201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump IdentifierInfo *getIdentifier() const { 13211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return getClassInterface()->getIdentifier(); 13224afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor } 13234afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor 1324d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar /// getName - Get the name of identifier for the class interface associated 1325d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar /// with this implementation as a StringRef. 1326d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar // 1327d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar // FIXME: This is a bad API, we are overriding the NamedDecl::getName, to mean 1328d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar // something different. 1329686775deca8b8685eb90801495880e3abdd844c2Chris Lattner StringRef getName() const { 1330d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar assert(getIdentifier() && "Name is not a simple identifier"); 1331d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar return getIdentifier()->getName(); 1332d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar } 1333d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar 13344afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// getNameAsCString - Get the name of identifier for the class 13354afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// interface associated with this implementation as a C string 13364afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// (const char*). 13377fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar // 13387fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar // FIXME: Move to StringRef API. 13394afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor const char *getNameAsCString() const { 1340d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar return getName().data(); 13414afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor } 13424afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor 13434afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// @brief Get the name of the class associated with this interface. 13447fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar // 13457fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar // FIXME: Move to StringRef API. 13464afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor std::string getNameAsString() const { 1347d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar return getName(); 13484afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor } 13494afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor 1350e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner const ObjCInterfaceDecl *getSuperClass() const { return SuperClass; } 1351e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner ObjCInterfaceDecl *getSuperClass() { return SuperClass; } 13521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1353f3a7af901231535191d14cb524d58f22907ac4d2Chris Lattner void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; } 13541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13558f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator; 13561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ivar_iterator ivar_begin() const { 13571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return ivar_iterator(decls_begin()); 13588f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor } 13591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ivar_iterator ivar_end() const { 136017945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return ivar_iterator(decls_end()); 13618f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor } 13621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump unsigned ivar_size() const { 136317945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return std::distance(ivar_begin(), ivar_end()); 13648f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor } 13651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump bool ivar_empty() const { 136617945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return ivar_begin() == ivar_end(); 13678f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor } 13681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 136980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 1370a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCImplementationDecl *D) { return true; } 137180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCImplementation; } 13729d50c0635fb213b2a1857e3f8488580f0dab2f98Argyrios Kyrtzidis 1373d527cc06d78fe5afa5f20105b51697637eb02c56Sebastian Redl friend class ASTDeclReader; 13743397c5570369f19b2d6c52e898f708d75ceede1fSebastian Redl friend class ASTDeclWriter; 1375980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 1376243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian 13778cc488fefb2fb04bc8d5398da29f0182f97934cfChris Lattnerraw_ostream &operator<<(raw_ostream &OS, 1378900fc6388e803868a34b9483510c345e9b49d7ebBenjamin Kramer const ObjCImplementationDecl *ID); 1379900fc6388e803868a34b9483510c345e9b49d7ebBenjamin Kramer 13801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is 1381243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian/// declared as @compatibility_alias alias class. 13824afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCCompatibleAliasDecl : public NamedDecl { 1383243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian /// Class that this is an alias of. 1384a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *AliasedClass; 13851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1386d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor ObjCCompatibleAliasDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, 1387e8043c39176e7f253fbd92982b077eca6bf2fd59Steve Naroff ObjCInterfaceDecl* aliasedClass) 13884afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor : NamedDecl(ObjCCompatibleAlias, DC, L, Id), AliasedClass(aliasedClass) {} 1389f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattnerpublic: 1390d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCCompatibleAliasDecl *Create(ASTContext &C, DeclContext *DC, 13910ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner SourceLocation L, IdentifierInfo *Id, 1392f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner ObjCInterfaceDecl* aliasedClass); 1393f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner 1394f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner const ObjCInterfaceDecl *getClassInterface() const { return AliasedClass; } 1395f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner ObjCInterfaceDecl *getClassInterface() { return AliasedClass; } 139630833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff void setClassInterface(ObjCInterfaceDecl *D) { AliasedClass = D; } 13971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 139880cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 1399a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCCompatibleAliasDecl *D) { return true; } 140080cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCCompatibleAlias; } 14011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1402243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian}; 14031de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian 14041de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian/// ObjCPropertyDecl - Represents one property declaration in an interface. 14051de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian/// For example: 14061de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian/// @property (assign, readwrite) int MyProperty; 14071de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian/// 14084afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCPropertyDecl : public NamedDecl { 140982a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanianpublic: 1410a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner enum PropertyAttributeKind { 14111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump OBJC_PR_noattr = 0x00, 14121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump OBJC_PR_readonly = 0x01, 1413a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner OBJC_PR_getter = 0x02, 14141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump OBJC_PR_assign = 0x04, 14151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump OBJC_PR_readwrite = 0x08, 1416a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner OBJC_PR_retain = 0x10, 14171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump OBJC_PR_copy = 0x20, 1418a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner OBJC_PR_nonatomic = 0x40, 141945937ae10a0f70f74508165aab4f2b63e18ea747Fariborz Jahanian OBJC_PR_setter = 0x80, 1420f85e193739c953358c865005855253af4f68a497John McCall OBJC_PR_atomic = 0x100, 1421f85e193739c953358c865005855253af4f68a497John McCall OBJC_PR_weak = 0x200, 1422f85e193739c953358c865005855253af4f68a497John McCall OBJC_PR_strong = 0x400, 14239f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis OBJC_PR_unsafe_unretained = 0x800 14249f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis // Adding a property should change NumPropertyAttrsBits 14259f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis }; 14260a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis 14279f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis enum { 14280a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis /// \brief Number of bits fitting all the property attributes. 14299f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis NumPropertyAttrsBits = 12 1430a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner }; 1431af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar 1432af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar enum SetterKind { Assign, Retain, Copy }; 143346b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian enum PropertyControl { None, Required, Optional }; 143482a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanianprivate: 1435d8265b838360578032020757d9a2a84c86457edcFariborz Jahanian SourceLocation AtLoc; // location of @property 143683a230c83a54190366138c1a4f4310ef838b88fcJohn McCall TypeSourceInfo *DeclType; 14379f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis unsigned PropertyAttributes : NumPropertyAttrsBits; 14389f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis unsigned PropertyAttributesAsWritten : NumPropertyAttrsBits; 143946b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian // @required/@optional 144046b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian unsigned PropertyImplementation : 2; 14411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14425251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian Selector GetterName; // getter name of NULL if no getter 14435251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian Selector SetterName; // setter name of NULL if no setter 14441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 144533de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian ObjCMethodDecl *GetterMethodDecl; // Declaration of getter instance method 144633de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian ObjCMethodDecl *SetterMethodDecl; // Declaration of setter instance method 1447af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian ObjCIvarDecl *PropertyIvarDecl; // Synthesize ivar for this property 144833de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian 14491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, 145083a230c83a54190366138c1a4f4310ef838b88fcJohn McCall SourceLocation AtLocation, TypeSourceInfo *T) 1451d0502407c1b41b2ace326f355d7b7a6876246223Fariborz Jahanian : NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation), DeclType(T), 145280aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian PropertyAttributes(OBJC_PR_noattr), 145380aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian PropertyAttributesAsWritten(OBJC_PR_noattr), 145480aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian PropertyImplementation(None), 14551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump GetterName(Selector()), 145633de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian SetterName(Selector()), 1457af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian GetterMethodDecl(0), SetterMethodDecl(0) , PropertyIvarDecl(0) {} 1458f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattnerpublic: 14591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC, 14601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation L, 1461d0502407c1b41b2ace326f355d7b7a6876246223Fariborz Jahanian IdentifierInfo *Id, SourceLocation AtLocation, 146283a230c83a54190366138c1a4f4310ef838b88fcJohn McCall TypeSourceInfo *T, 146346b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian PropertyControl propControl = None); 1464d0502407c1b41b2ace326f355d7b7a6876246223Fariborz Jahanian SourceLocation getAtLoc() const { return AtLoc; } 1465d0502407c1b41b2ace326f355d7b7a6876246223Fariborz Jahanian void setAtLoc(SourceLocation L) { AtLoc = L; } 1466d0502407c1b41b2ace326f355d7b7a6876246223Fariborz Jahanian 146783a230c83a54190366138c1a4f4310ef838b88fcJohn McCall TypeSourceInfo *getTypeSourceInfo() const { return DeclType; } 146883a230c83a54190366138c1a4f4310ef838b88fcJohn McCall QualType getType() const { return DeclType->getType(); } 146983a230c83a54190366138c1a4f4310ef838b88fcJohn McCall void setType(TypeSourceInfo *T) { DeclType = T; } 147070e5a14c6076d63833c62d1d6d628c26309897c1Douglas Gregor 1471a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner PropertyAttributeKind getPropertyAttributes() const { 1472f4af5154571e0c5eadb19df10e65464766ef6683Chris Lattner return PropertyAttributeKind(PropertyAttributes); 1473f4af5154571e0c5eadb19df10e65464766ef6683Chris Lattner } 14741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void setPropertyAttributes(PropertyAttributeKind PRVal) { 1475a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner PropertyAttributes |= PRVal; 147682a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian } 1477394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar 147880aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian PropertyAttributeKind getPropertyAttributesAsWritten() const { 147980aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian return PropertyAttributeKind(PropertyAttributesAsWritten); 148080aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian } 14810a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis 14820a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis bool hasWrittenStorageAttribute() const { 14830a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis return PropertyAttributesAsWritten & (OBJC_PR_assign | OBJC_PR_copy | 14840a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis OBJC_PR_unsafe_unretained | OBJC_PR_retain | OBJC_PR_strong | 14850a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis OBJC_PR_weak); 14860a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis } 148780aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian 148880aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal) { 148980aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian PropertyAttributesAsWritten = PRVal; 149080aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian } 149180aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian 14928cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian void makeitReadWriteAttribute(void) { 14938cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian PropertyAttributes &= ~OBJC_PR_readonly; 14948cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian PropertyAttributes |= OBJC_PR_readwrite; 14951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump } 14968cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian 1497af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar // Helper methods for accessing attributes. 1498af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar 1499af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar /// isReadOnly - Return true iff the property has a setter. 1500394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar bool isReadOnly() const { 1501394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar return (PropertyAttributes & OBJC_PR_readonly); 1502394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar } 1503af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar 1504af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar /// getSetterKind - Return the method used for doing assignment in 1505af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar /// the property setter. This is only valid if the property has been 1506af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar /// defined to have a setter. 1507af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar SetterKind getSetterKind() const { 1508f85e193739c953358c865005855253af4f68a497John McCall if (PropertyAttributes & (OBJC_PR_retain|OBJC_PR_strong)) 1509af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar return Retain; 1510af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar if (PropertyAttributes & OBJC_PR_copy) 1511af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar return Copy; 1512af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar return Assign; 1513af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar } 1514af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar 15155251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian Selector getGetterName() const { return GetterName; } 15165251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian void setGetterName(Selector Sel) { GetterName = Sel; } 15171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15185251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian Selector getSetterName() const { return SetterName; } 15195251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian void setSetterName(Selector Sel) { SetterName = Sel; } 15201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 152133de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian ObjCMethodDecl *getGetterMethodDecl() const { return GetterMethodDecl; } 152233de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian void setGetterMethodDecl(ObjCMethodDecl *gDecl) { GetterMethodDecl = gDecl; } 152333de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian 152433de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian ObjCMethodDecl *getSetterMethodDecl() const { return SetterMethodDecl; } 152533de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian void setSetterMethodDecl(ObjCMethodDecl *gDecl) { SetterMethodDecl = gDecl; } 15261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 152746b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian // Related to @optional/@required declared in @protocol 152846b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian void setPropertyImplementation(PropertyControl pc) { 152946b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian PropertyImplementation = pc; 153046b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian } 153146b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian PropertyControl getPropertyImplementation() const { 153246b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian return PropertyControl(PropertyImplementation); 15331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump } 15341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1535af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian void setPropertyIvarDecl(ObjCIvarDecl *Ivar) { 1536af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian PropertyIvarDecl = Ivar; 1537af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian } 1538af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian ObjCIvarDecl *getPropertyIvarDecl() const { 1539af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian return PropertyIvarDecl; 1540af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian } 15411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1542da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor virtual SourceRange getSourceRange() const { 1543e3c60a7ce9e0f42c7ca2344b33203266aceca1dbDouglas Gregor return SourceRange(AtLoc, getLocation()); 1544e3c60a7ce9e0f42c7ca2344b33203266aceca1dbDouglas Gregor } 1545e3c60a7ce9e0f42c7ca2344b33203266aceca1dbDouglas Gregor 15469f550ff05d496e6b9480e5619a21d9da0c9e27c1Ted Kremenek /// Lookup a property by name in the specified DeclContext. 1547de09d0c9694f01a99870a8825266d44a29ebb325Ted Kremenek static ObjCPropertyDecl *findPropertyDecl(const DeclContext *DC, 15489f550ff05d496e6b9480e5619a21d9da0c9e27c1Ted Kremenek IdentifierInfo *propertyID); 15499f550ff05d496e6b9480e5619a21d9da0c9e27c1Ted Kremenek 155080cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 1551a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCPropertyDecl *D) { return true; } 155280cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCProperty; } 155382a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian}; 1554980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 15551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// ObjCPropertyImplDecl - Represents implementation declaration of a property 155661d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian/// in a class or category implementation block. For example: 155761d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian/// @synthesize prop1 = ivar1; 155861d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian/// 15594afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCPropertyImplDecl : public Decl { 156061d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanianpublic: 15619f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar enum Kind { 15629f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar Synthesize, 15639f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar Dynamic 156461d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian }; 156561d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanianprivate: 1566559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian SourceLocation AtLoc; // location of @synthesize or @dynamic 1567a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor 1568a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor /// \brief For @synthesize, the location of the ivar, if it was written in 1569a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor /// the source code. 1570a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor /// 1571a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor /// \code 1572a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor /// @synthesize int a = b 1573a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor /// \endcode 1574a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor SourceLocation IvarLoc; 1575a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor 157661d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian /// Property declaration being implemented 157761d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian ObjCPropertyDecl *PropertyDecl; 1578be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek 157961d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian /// Null for @dynamic. Required for @synthesize. 158061d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian ObjCIvarDecl *PropertyIvarDecl; 158117cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian 158217cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian /// Null for @dynamic. Non-null if property must be copy-constructed in getter 158317cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian Expr *GetterCXXConstructor; 158417cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian 158517cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian /// Null for @dynamic. Non-null if property has assignment operator to call 158617cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian /// in Setter synthesis. 158717cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian Expr *SetterCXXAssignment; 1588be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek 1589d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor ObjCPropertyImplDecl(DeclContext *DC, SourceLocation atLoc, SourceLocation L, 15901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ObjCPropertyDecl *property, 15911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Kind PK, 1592a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor ObjCIvarDecl *ivarDecl, 1593a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor SourceLocation ivarLoc) 15941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump : Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc), 1595a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor IvarLoc(ivarLoc), PropertyDecl(property), PropertyIvarDecl(ivarDecl), 159617cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian GetterCXXConstructor(0), SetterCXXAssignment(0) { 15979f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar assert (PK == Dynamic || PropertyIvarDecl); 15989f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar } 15991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16009f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbarpublic: 1601d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCPropertyImplDecl *Create(ASTContext &C, DeclContext *DC, 16021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation atLoc, SourceLocation L, 16031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ObjCPropertyDecl *property, 16041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Kind PK, 1605a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor ObjCIvarDecl *ivarDecl, 1606a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor SourceLocation ivarLoc); 160761d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian 1608da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor virtual SourceRange getSourceRange() const; 1609a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor 1610d40910b581b09c937a8c1fdcde9b8ec724398fb9Steve Naroff SourceLocation getLocStart() const { return AtLoc; } 16118818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor void setAtLoc(SourceLocation Loc) { AtLoc = Loc; } 1612d40910b581b09c937a8c1fdcde9b8ec724398fb9Steve Naroff 1613be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek ObjCPropertyDecl *getPropertyDecl() const { 1614be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek return PropertyDecl; 1615be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek } 16168818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor void setPropertyDecl(ObjCPropertyDecl *Prop) { PropertyDecl = Prop; } 16178818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor 16189f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar Kind getPropertyImplementation() const { 16199f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar return PropertyIvarDecl ? Synthesize : Dynamic; 1620be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek } 16211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1622af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar ObjCIvarDecl *getPropertyIvarDecl() const { 1623be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek return PropertyIvarDecl; 1624be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek } 1625a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor SourceLocation getPropertyIvarDeclLoc() const { return IvarLoc; } 1626a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor 1627a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor void setPropertyIvarDecl(ObjCIvarDecl *Ivar, 1628a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor SourceLocation IvarLoc) { 1629a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor PropertyIvarDecl = Ivar; 1630a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor this->IvarLoc = IvarLoc; 1631a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor } 163217cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian 163317cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian Expr *getGetterCXXConstructor() const { 163417cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian return GetterCXXConstructor; 163517cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian } 163617cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian void setGetterCXXConstructor(Expr *getterCXXConstructor) { 163717cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian GetterCXXConstructor = getterCXXConstructor; 163817cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian } 16398818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor 164017cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian Expr *getSetterCXXAssignment() const { 164117cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian return SetterCXXAssignment; 164217cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian } 164317cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian void setSetterCXXAssignment(Expr *setterCXXAssignment) { 164417cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian SetterCXXAssignment = setterCXXAssignment; 164517cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian } 164617cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian 164780cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 16481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const ObjCPropertyImplDecl *D) { return true; } 164980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Decl::Kind K) { return K == ObjCPropertyImpl; } 1650a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor 1651a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor friend class ASTDeclReader; 165261d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian}; 165361d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian 1654980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff} // end namespace clang 1655980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#endif 1656