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" 18491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis#include "clang/AST/SelectorLocationsKind.h" 196ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson#include "llvm/ADT/STLExtras.h" 20aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar#include "llvm/Support/Compiler.h" 21980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 22980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffnamespace clang { 23980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass Expr; 24980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass Stmt; 25980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass FunctionDecl; 2660f8c868ffb346b78451a3eccaecd0461d2ae498Fariborz Jahanianclass RecordDecl; 27a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCIvarDecl; 28a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCMethodDecl; 29a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCProtocolDecl; 30a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCCategoryDecl; 31a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCPropertyDecl; 32f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanianclass ObjCPropertyImplDecl; 33cbb67480094b3bcb5b715acd827cbad55e2a204cSean Huntclass CXXCtorInitializer; 3468835718c4125f2f66740cd04de7088645ec695dChris Lattner 35793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerclass ObjCListBase { 36f56faa01936b9cf909623d7f06e3c2569ca4a78eDmitri Gribenko ObjCListBase(const ObjCListBase &) LLVM_DELETED_FUNCTION; 37f56faa01936b9cf909623d7f06e3c2569ca4a78eDmitri Gribenko void operator=(const ObjCListBase &) LLVM_DELETED_FUNCTION; 38793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerprotected: 39793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner /// List is an array of pointers to objects that are not owned by this object. 40793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner void **List; 413db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner unsigned NumElts; 42793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner 433db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattnerpublic: 44793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner ObjCListBase() : List(0), NumElts(0) {} 45793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner unsigned size() const { return NumElts; } 46793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner bool empty() const { return NumElts == 0; } 471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 48793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerprotected: 4938af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void set(void *const* InList, unsigned Elts, ASTContext &Ctx); 50793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner}; 511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 53793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// ObjCList - This is a simple template class used to hold various lists of 54793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// decls etc, which is heavily used by the ObjC front-end. This only use case 55793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// this supports is setting the list all at once and then reading elements out 56793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// of it. 57793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnertemplate <typename T> 58793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerclass ObjCList : public ObjCListBase { 59793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerpublic: 6038af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void set(T* const* InList, unsigned Elts, ASTContext &Ctx) { 6138af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner ObjCListBase::set(reinterpret_cast<void*const*>(InList), Elts, Ctx); 62793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner } 631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 64793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner typedef T* const * iterator; 65793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner iterator begin() const { return (iterator)List; } 66793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner iterator end() const { return (iterator)List+NumElts; } 671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 68793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner T* operator[](unsigned Idx) const { 69793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner assert(Idx < NumElts && "Invalid access"); 70793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner return (T*)List[Idx]; 713db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner } 723db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner}; 733db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner 7418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor/// \brief A list of Objective-C protocols, along with the source 7518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor/// locations at which they were referenced. 7618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregorclass ObjCProtocolList : public ObjCList<ObjCProtocolDecl> { 7718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor SourceLocation *Locations; 7818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor 7918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor using ObjCList<ObjCProtocolDecl>::set; 8018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor 8118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregorpublic: 8218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor ObjCProtocolList() : ObjCList<ObjCProtocolDecl>(), Locations(0) { } 8318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor 8418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor typedef const SourceLocation *loc_iterator; 8518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor loc_iterator loc_begin() const { return Locations; } 8618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor loc_iterator loc_end() const { return Locations + size(); } 8718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor 88ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie void set(ObjCProtocolDecl* const* InList, unsigned Elts, 8918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const SourceLocation *Locs, ASTContext &Ctx); 9018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor}; 911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 93a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCMethodDecl - Represents an instance or class method declaration. 9458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// ObjC methods can be declared within 4 contexts: class interfaces, 9558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// categories, protocols, and class implementations. While C++ member 961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// functions leverage C syntax, Objective-C method syntax is modeled after 971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// Smalltalk (using colons to specify argument types/expressions). 9858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Here are some brief examples: 9958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// 10058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Setter/getter instance methods: 10158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// - (void)setMenu:(NSMenu *)menu; 1021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// - (NSMenu *)menu; 1031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 10458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Instance method that takes 2 NSView arguments: 10558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// - (void)replaceSubview:(NSView *)oldView with:(NSView *)newView; 10658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// 10758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Getter class method: 10858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// + (NSMenu *)defaultMenu; 10958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// 11058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// A selector represents a unique name for a method. The selector names for 11158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// the above methods are setMenu:, menu, replaceSubview:with:, and defaultMenu. 11258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// 1134afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCMethodDecl : public NamedDecl, public DeclContext { 11458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroffpublic: 11558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff enum ImplementationControl { None, Required, Optional }; 11658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroffprivate: 11785f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall // The conventional meaning of this method; an ObjCMethodFamily. 11885f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall // This is not serialized; instead, it is computed on demand and 11985f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall // cached. 12085f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall mutable unsigned Family : ObjCMethodFamilyBitWidth; 12185f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall 12258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff /// instance (true) or class (false) method. 12385f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall unsigned IsInstance : 1; 12485f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall unsigned IsVariadic : 1; 1251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1261e4691b9d8e1bdcc8ef62b323969d702c51b3c08Jordan Rose /// True if this method is the getter or setter for an explicit property. 1271e4691b9d8e1bdcc8ef62b323969d702c51b3c08Jordan Rose unsigned IsPropertyAccessor : 1; 128ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1293fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian // Method has a definition. 13085f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall unsigned IsDefined : 1; 1311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13272b2625aa67c8213acaf4bf6209b67859d60e2cfArgyrios Kyrtzidis /// \brief Method redeclaration in the same interface. 1333a919e7110407ae7609bb6edc57aac16a5990661Argyrios Kyrtzidis unsigned IsRedeclaration : 1; 1343a919e7110407ae7609bb6edc57aac16a5990661Argyrios Kyrtzidis 13572b2625aa67c8213acaf4bf6209b67859d60e2cfArgyrios Kyrtzidis /// \brief Is redeclared in the same interface. 13672b2625aa67c8213acaf4bf6209b67859d60e2cfArgyrios Kyrtzidis mutable unsigned HasRedeclaration : 1; 13772b2625aa67c8213acaf4bf6209b67859d60e2cfArgyrios Kyrtzidis 138ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek // NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum 13941c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// \@required/\@optional 140ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek unsigned DeclImplementation : 2; 1411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 142ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek // NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum 14358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff /// in, inout, etc. 144ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek unsigned objcDeclQualifier : 6; 1451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 146926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor /// \brief Indicates whether this method has a related result type. 147926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor unsigned RelatedResultType : 1; 148ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 149491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis /// \brief Whether the locations of the selector identifiers are in a 150491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis /// "standard" position, a enum SelectorLocationsKind. 151491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis unsigned SelLocsKind : 2; 1527732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian 153e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis /// \brief Whether this method overrides any other in the class hierarchy. 154e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis /// 155e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis /// A method is said to override any method in the class's 156e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis /// base classes, its protocols, or its categories' protocols, that has 157e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis /// the same selector and is of the same kind (class or instance). 158e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis /// A method in an implementation is not considered as overriding the same 159e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis /// method in the interface or its categories. 160e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis unsigned IsOverriding : 1; 161e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis 16235f3f36cb9451f347b83a6e7f01e3c702df4732dArgyrios Kyrtzidis /// \brief Indicates if the method was a definition but its body was skipped. 16335f3f36cb9451f347b83a6e7f01e3c702df4732dArgyrios Kyrtzidis unsigned HasSkippedBody : 1; 16435f3f36cb9451f347b83a6e7f01e3c702df4732dArgyrios Kyrtzidis 1654bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor // Result type of this method. 16658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff QualType MethodDeclType; 167ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1684bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor // Type source information for the result type. 1694bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor TypeSourceInfo *ResultTInfo; 1704bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor 171491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis /// \brief Array of ParmVarDecls for the formal parameters of this method 172491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis /// and optionally followed by selector locations. 173491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis void *ParamsAndSelLocs; 174491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis unsigned NumParams; 1751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 17658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff /// List of attributes for this method declaration. 177a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis SourceLocation DeclEndLoc; // the location of the ';' or '{'. 1781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 17958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff // The following are only used for method definitions, null otherwise. 1805456b0fe40714a78cd0ba7c1a5b7dc34eda385afDouglas Gregor LazyDeclStmtPtr Body; 181451318c08a6342c10b8986060386fd9274418437Daniel Dunbar 182451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// SelfDecl - Decl for the implicit self parameter. This is lazily 183451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// constructed by createImplicitParams. 1844111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner ImplicitParamDecl *SelfDecl; 185451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// CmdDecl - Decl for the implicit _cmd parameter. This is lazily 186451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// constructed by createImplicitParams. 1874111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner ImplicitParamDecl *CmdDecl; 1881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 189491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis SelectorLocationsKind getSelLocsKind() const { 190491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis return (SelectorLocationsKind)SelLocsKind; 191491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis } 192491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis bool hasStandardSelLocs() const { 193491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis return getSelLocsKind() != SelLoc_NonStandard; 194491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis } 195491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis 196491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis /// \brief Get a pointer to the stored selector identifiers locations array. 197491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis /// No locations will be stored if HasStandardSelLocs is true. 198491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis SourceLocation *getStoredSelLocs() { 199491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis return reinterpret_cast<SourceLocation*>(getParams() + NumParams); 200491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis } 201491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis const SourceLocation *getStoredSelLocs() const { 202491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis return reinterpret_cast<const SourceLocation*>(getParams() + NumParams); 203491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis } 204491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis 205491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis /// \brief Get a pointer to the stored selector identifiers locations array. 206491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis /// No locations will be stored if HasStandardSelLocs is true. 207491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis ParmVarDecl **getParams() { 208491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis return reinterpret_cast<ParmVarDecl **>(ParamsAndSelLocs); 209491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis } 210491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis const ParmVarDecl *const *getParams() const { 211491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis return reinterpret_cast<const ParmVarDecl *const *>(ParamsAndSelLocs); 212491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis } 213491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis 214491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis /// \brief Get the number of stored selector identifiers locations. 215491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis /// No locations will be stored if HasStandardSelLocs is true. 216491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis unsigned getNumStoredSelLocs() const { 217491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis if (hasStandardSelLocs()) 218491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis return 0; 219491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis return getNumSelectorLocs(); 220491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis } 221491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis 222491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis void setParamsAndSelLocs(ASTContext &C, 223491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis ArrayRef<ParmVarDecl*> Params, 224491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis ArrayRef<SourceLocation> SelLocs); 225491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis 226a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc, 22758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff Selector SelInfo, QualType T, 2284bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor TypeSourceInfo *ResultTInfo, 2290701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff DeclContext *contextDecl, 230f6414927e67e27d9324d8d179c5f7ea620443924Daniel Dunbar bool isInstance = true, 23158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff bool isVariadic = false, 2321e4691b9d8e1bdcc8ef62b323969d702c51b3c08Jordan Rose bool isPropertyAccessor = false, 23375cf3e86d33ce810c12084126385371b335c30baArgyrios Kyrtzidis bool isImplicitlyDeclared = false, 2343fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian bool isDefined = false, 2357732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian ImplementationControl impControl = None, 236da92a7f91cf88f49e02050919676f7fb8e3bdff8Argyrios Kyrtzidis bool HasRelatedResultType = false) 2374afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor : NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo), 23885f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall DeclContext(ObjCMethod), Family(InvalidObjCMethodFamily), 23958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff IsInstance(isInstance), IsVariadic(isVariadic), 2401e4691b9d8e1bdcc8ef62b323969d702c51b3c08Jordan Rose IsPropertyAccessor(isPropertyAccessor), 24172b2625aa67c8213acaf4bf6209b67859d60e2cfArgyrios Kyrtzidis IsDefined(isDefined), IsRedeclaration(0), HasRedeclaration(0), 24258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None), 243da92a7f91cf88f49e02050919676f7fb8e3bdff8Argyrios Kyrtzidis RelatedResultType(HasRelatedResultType), 244fb4f3a2591782f8643f06724703d2e5b03af36d2Argyrios Kyrtzidis SelLocsKind(SelLoc_StandardNoSpace), IsOverriding(0), HasSkippedBody(0), 245926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor MethodDeclType(T), ResultTInfo(ResultTInfo), 246491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis ParamsAndSelLocs(0), NumParams(0), 2475456b0fe40714a78cd0ba7c1a5b7dc34eda385afDouglas Gregor DeclEndLoc(endLoc), Body(), SelfDecl(0), CmdDecl(0) { 24875cf3e86d33ce810c12084126385371b335c30baArgyrios Kyrtzidis setImplicit(isImplicitlyDeclared); 24975cf3e86d33ce810c12084126385371b335c30baArgyrios Kyrtzidis } 2508a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek 25157ea6bee79cc60ba20c7886b453f40f380dce1b1Argyrios Kyrtzidis /// \brief A definition will return its interface declaration. 25257ea6bee79cc60ba20c7886b453f40f380dce1b1Argyrios Kyrtzidis /// An interface declaration will return its definition. 25357ea6bee79cc60ba20c7886b453f40f380dce1b1Argyrios Kyrtzidis /// Otherwise it will return itself. 254da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor virtual ObjCMethodDecl *getNextRedeclaration(); 255da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor 2566c4ae5de0c356777446f823b573821fb95560d91Chris Lattnerpublic: 2570ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner static ObjCMethodDecl *Create(ASTContext &C, 2581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation beginLoc, 25911d77169555480ee0a04c6e5bc390d8fde41175dArgyrios Kyrtzidis SourceLocation endLoc, 26011d77169555480ee0a04c6e5bc390d8fde41175dArgyrios Kyrtzidis Selector SelInfo, 261ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie QualType T, 2624bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor TypeSourceInfo *ResultTInfo, 2634bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor DeclContext *contextDecl, 264f6414927e67e27d9324d8d179c5f7ea620443924Daniel Dunbar bool isInstance = true, 2656c4ae5de0c356777446f823b573821fb95560d91Chris Lattner bool isVariadic = false, 2661e4691b9d8e1bdcc8ef62b323969d702c51b3c08Jordan Rose bool isPropertyAccessor = false, 26775cf3e86d33ce810c12084126385371b335c30baArgyrios Kyrtzidis bool isImplicitlyDeclared = false, 2683fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian bool isDefined = false, 2697732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian ImplementationControl impControl = None, 270da92a7f91cf88f49e02050919676f7fb8e3bdff8Argyrios Kyrtzidis bool HasRelatedResultType = false); 271e7f9d301a10b4b3223e91d9be4362b44cba0a212Argyrios Kyrtzidis 2721e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor static ObjCMethodDecl *CreateDeserialized(ASTContext &C, unsigned ID); 2731e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor 274da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor virtual ObjCMethodDecl *getCanonicalDecl(); 27513e635c55eb23f736d38abf9c954801bd6482db4Ted Kremenek const ObjCMethodDecl *getCanonicalDecl() const { 27613e635c55eb23f736d38abf9c954801bd6482db4Ted Kremenek return const_cast<ObjCMethodDecl*>(this)->getCanonicalDecl(); 27713e635c55eb23f736d38abf9c954801bd6482db4Ted Kremenek } 278e7f9d301a10b4b3223e91d9be4362b44cba0a212Argyrios Kyrtzidis 279ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek ObjCDeclQualifier getObjCDeclQualifier() const { 280ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek return ObjCDeclQualifier(objcDeclQualifier); 281ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek } 282a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek void setObjCDeclQualifier(ObjCDeclQualifier QV) { objcDeclQualifier = QV; } 2831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 284926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor /// \brief Determine whether this method has a result type that is related 285926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor /// to the message receiver's type. 286926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor bool hasRelatedResultType() const { return RelatedResultType; } 287ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 288926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor /// \brief Note whether this method has a related result type. 289926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor void SetRelatedResultType(bool RRT = true) { RelatedResultType = RRT; } 2903a919e7110407ae7609bb6edc57aac16a5990661Argyrios Kyrtzidis 2913a919e7110407ae7609bb6edc57aac16a5990661Argyrios Kyrtzidis /// \brief True if this is a method redeclaration in the same interface. 2923a919e7110407ae7609bb6edc57aac16a5990661Argyrios Kyrtzidis bool isRedeclaration() const { return IsRedeclaration; } 2933a919e7110407ae7609bb6edc57aac16a5990661Argyrios Kyrtzidis void setAsRedeclaration(const ObjCMethodDecl *PrevMethod); 294ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 295a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis /// \brief Returns the location where the declarator ends. It will be 296a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis /// the location of ';' for a method declaration and the location of '{' 297a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis /// for a method definition. 298a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis SourceLocation getDeclaratorEndLoc() const { return DeclEndLoc; } 299a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis 30058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff // Location information, modeled after the Stmt API. 301aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar SourceLocation getLocStart() const LLVM_READONLY { return getLocation(); } 302a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis SourceLocation getLocEnd() const LLVM_READONLY; 303aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar virtual SourceRange getSourceRange() const LLVM_READONLY { 304a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis return SourceRange(getLocation(), getLocEnd()); 3059776ba0d844cf9f6888e871e3fd246ae782f76f4Daniel Dunbar } 3061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 307746f5bcbfde5b25269169c63c66492311673b67dArgyrios Kyrtzidis SourceLocation getSelectorStartLoc() const { 308746f5bcbfde5b25269169c63c66492311673b67dArgyrios Kyrtzidis if (isImplicit()) 309746f5bcbfde5b25269169c63c66492311673b67dArgyrios Kyrtzidis return getLocStart(); 310746f5bcbfde5b25269169c63c66492311673b67dArgyrios Kyrtzidis return getSelectorLoc(0); 311746f5bcbfde5b25269169c63c66492311673b67dArgyrios Kyrtzidis } 312491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis SourceLocation getSelectorLoc(unsigned Index) const { 313491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis assert(Index < getNumSelectorLocs() && "Index out of range!"); 314491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis if (hasStandardSelLocs()) 315491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis return getStandardSelectorLoc(Index, getSelector(), 316491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis getSelLocsKind() == SelLoc_StandardWithSpace, 317491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis llvm::makeArrayRef(const_cast<ParmVarDecl**>(getParams()), 318491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis NumParams), 319a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis DeclEndLoc); 320491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis return getStoredSelLocs()[Index]; 321491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis } 322491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis 323491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis void getSelectorLocs(SmallVectorImpl<SourceLocation> &SelLocs) const; 324491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis 325491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis unsigned getNumSelectorLocs() const { 326491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis if (isImplicit()) 327491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis return 0; 328491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis Selector Sel = getSelector(); 329491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis if (Sel.isUnarySelector()) 330491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis return 1; 331491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis return Sel.getNumArgs(); 332491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis } 333491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis 3345619688510185081cbb4621d703daf7ee24cf39aChris Lattner ObjCInterfaceDecl *getClassInterface(); 3355619688510185081cbb4621d703daf7ee24cf39aChris Lattner const ObjCInterfaceDecl *getClassInterface() const { 3365619688510185081cbb4621d703daf7ee24cf39aChris Lattner return const_cast<ObjCMethodDecl*>(this)->getClassInterface(); 337e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner } 3381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3392e1cd4264d363ca869bf37ef160902f211d21b8cDouglas Gregor Selector getSelector() const { return getDeclName().getObjCSelector(); } 3403a082d81006e7a2e01a6e431a22e21c78490ff8fAnders Carlsson 34158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff QualType getResultType() const { return MethodDeclType; } 34253c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setResultType(QualType T) { MethodDeclType = T; } 3431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 344ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Determine the type of an expression that sends a message to this 3455291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor /// function. 3465291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor QualType getSendResultType() const { 3476398235d7890a81b785ea5af3b6e66d86bf184ccDouglas Gregor return getResultType().getNonLValueExprType(getASTContext()); 3485291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor } 349ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3504bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor TypeSourceInfo *getResultTypeSourceInfo() const { return ResultTInfo; } 3514bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor void setResultTypeSourceInfo(TypeSourceInfo *TInfo) { ResultTInfo = TInfo; } 3524bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor 353d57f635d520e8cb5b93d3d770ff58db06c62de54Chris Lattner // Iterator access to formal parameters. 354491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis unsigned param_size() const { return NumParams; } 355491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis typedef const ParmVarDecl *const *param_const_iterator; 356491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis typedef ParmVarDecl *const *param_iterator; 357491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis param_const_iterator param_begin() const { return getParams(); } 358491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis param_const_iterator param_end() const { return getParams() + NumParams; } 359491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis param_iterator param_begin() { return getParams(); } 360491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis param_iterator param_end() { return getParams() + NumParams; } 3617732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian // This method returns and of the parameters which are part of the selector 3627732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian // name mangling requirements. 363ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie param_const_iterator sel_param_end() const { 364ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return param_begin() + getSelector().getNumArgs(); 3657732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian } 36689951a86b594513c2a013532ed45d197413b1087Chris Lattner 3679dd0065e61ea4b48b19eee550704ce964e64e946Argyrios Kyrtzidis /// \brief Sets the method's parameters and selector source locations. 3681824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// If the method is implicit (not coming from source) \p SelLocs is 3699dd0065e61ea4b48b19eee550704ce964e64e946Argyrios Kyrtzidis /// ignored. 370491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis void setMethodParams(ASTContext &C, 371491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis ArrayRef<ParmVarDecl*> Params, 3729dd0065e61ea4b48b19eee550704ce964e64e946Argyrios Kyrtzidis ArrayRef<SourceLocation> SelLocs = 3739dd0065e61ea4b48b19eee550704ce964e64e946Argyrios Kyrtzidis ArrayRef<SourceLocation>()); 3744111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner 3756ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson // Iterator access to parameter types. 3766ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson typedef std::const_mem_fun_t<QualType, ParmVarDecl> deref_fun; 377491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis typedef llvm::mapped_iterator<param_const_iterator, deref_fun> 378491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis arg_type_iterator; 3796ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson 3806ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson arg_type_iterator arg_type_begin() const { 3816ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson return llvm::map_iterator(param_begin(), deref_fun(&ParmVarDecl::getType)); 3826ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson } 3836ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson arg_type_iterator arg_type_end() const { 3846ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson return llvm::map_iterator(param_end(), deref_fun(&ParmVarDecl::getType)); 3856ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson } 3861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 387451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// createImplicitParams - Used to lazily create the self and cmd 388451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// implict parameters. This must be called prior to using getSelfDecl() 389451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// or getCmdDecl(). The call is ignored if the implicit paramters 390451318c08a6342c10b8986060386fd9274418437Daniel Dunbar /// have already been created. 391fef30b55230064d334a669a065a1c9acdb87cdfeFariborz Jahanian void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID); 392451318c08a6342c10b8986060386fd9274418437Daniel Dunbar 3934111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner ImplicitParamDecl * getSelfDecl() const { return SelfDecl; } 39453c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setSelfDecl(ImplicitParamDecl *SD) { SelfDecl = SD; } 3954111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner ImplicitParamDecl * getCmdDecl() const { return CmdDecl; } 39653c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setCmdDecl(ImplicitParamDecl *CD) { CmdDecl = CD; } 3971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 39885f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall /// Determines the family of this method. 39985f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall ObjCMethodFamily getMethodFamily() const; 40085f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall 401f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor bool isInstanceMethod() const { return IsInstance; } 40253c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setInstanceMethod(bool isInst) { IsInstance = isInst; } 40358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff bool isVariadic() const { return IsVariadic; } 40453c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff void setVariadic(bool isVar) { IsVariadic = isVar; } 4051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 406f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor bool isClassMethod() const { return !IsInstance; } 407f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor 4081e4691b9d8e1bdcc8ef62b323969d702c51b3c08Jordan Rose bool isPropertyAccessor() const { return IsPropertyAccessor; } 4091e4691b9d8e1bdcc8ef62b323969d702c51b3c08Jordan Rose void setPropertyAccessor(bool isAccessor) { IsPropertyAccessor = isAccessor; } 410ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 4113fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian bool isDefined() const { return IsDefined; } 4123fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian void setDefined(bool isDefined) { IsDefined = isDefined; } 4131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 414e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis /// \brief Whether this method overrides any other in the class hierarchy. 415e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis /// 416e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis /// A method is said to override any method in the class's 417e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis /// base classes, its protocols, or its categories' protocols, that has 418e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis /// the same selector and is of the same kind (class or instance). 419e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis /// A method in an implementation is not considered as overriding the same 420e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis /// method in the interface or its categories. 421e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis bool isOverriding() const { return IsOverriding; } 422e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis void setOverriding(bool isOverriding) { IsOverriding = isOverriding; } 423740ae67dbf8dac44dbc8d6593a60f4f37a0a2aa5Argyrios Kyrtzidis 424740ae67dbf8dac44dbc8d6593a60f4f37a0a2aa5Argyrios Kyrtzidis /// \brief Return overridden methods for the given \p Method. 425740ae67dbf8dac44dbc8d6593a60f4f37a0a2aa5Argyrios Kyrtzidis /// 426740ae67dbf8dac44dbc8d6593a60f4f37a0a2aa5Argyrios Kyrtzidis /// An ObjC method is considered to override any method in the class's 427bf967be66ea8c51b66c61659c23240f762a56dbeFariborz Jahanian /// base classes (and base's categories), its protocols, or its categories' 428bf967be66ea8c51b66c61659c23240f762a56dbeFariborz Jahanian /// protocols, that has 429740ae67dbf8dac44dbc8d6593a60f4f37a0a2aa5Argyrios Kyrtzidis /// the same selector and is of the same kind (class or instance). 430740ae67dbf8dac44dbc8d6593a60f4f37a0a2aa5Argyrios Kyrtzidis /// A method in an implementation is not considered as overriding the same 431740ae67dbf8dac44dbc8d6593a60f4f37a0a2aa5Argyrios Kyrtzidis /// method in the interface or its categories. 432740ae67dbf8dac44dbc8d6593a60f4f37a0a2aa5Argyrios Kyrtzidis void getOverriddenMethods( 433740ae67dbf8dac44dbc8d6593a60f4f37a0a2aa5Argyrios Kyrtzidis SmallVectorImpl<const ObjCMethodDecl *> &Overridden) const; 43404bec39d61f2b392d798882c9141fecf3ca653c5Jordan Rose 43535f3f36cb9451f347b83a6e7f01e3c702df4732dArgyrios Kyrtzidis /// \brief True if the method was a definition but its body was skipped. 43635f3f36cb9451f347b83a6e7f01e3c702df4732dArgyrios Kyrtzidis bool hasSkippedBody() const { return HasSkippedBody; } 43735f3f36cb9451f347b83a6e7f01e3c702df4732dArgyrios Kyrtzidis void setHasSkippedBody(bool Skipped = true) { HasSkippedBody = Skipped; } 43835f3f36cb9451f347b83a6e7f01e3c702df4732dArgyrios Kyrtzidis 43904bec39d61f2b392d798882c9141fecf3ca653c5Jordan Rose /// \brief Returns the property associated with this method's selector. 44004bec39d61f2b392d798882c9141fecf3ca653c5Jordan Rose /// 44104bec39d61f2b392d798882c9141fecf3ca653c5Jordan Rose /// Note that even if this particular method is not marked as a property 44204bec39d61f2b392d798882c9141fecf3ca653c5Jordan Rose /// accessor, it is still possible for it to match a property declared in a 44304bec39d61f2b392d798882c9141fecf3ca653c5Jordan Rose /// superclass. Pass \c false if you only want to check the current class. 44404bec39d61f2b392d798882c9141fecf3ca653c5Jordan Rose const ObjCPropertyDecl *findPropertyDecl(bool CheckOverrides = true) const; 44504bec39d61f2b392d798882c9141fecf3ca653c5Jordan Rose 44641c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth // Related to protocols declared in \@protocol 4471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void setDeclImplementation(ImplementationControl ic) { 4481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump DeclImplementation = ic; 44958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff } 4501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ImplementationControl getImplementationControl() const { 4511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return ImplementationControl(DeclImplementation); 45258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff } 453792481eec23d8c1aa92173be589e2ae9d02514a5Ted Kremenek 4545456b0fe40714a78cd0ba7c1a5b7dc34eda385afDouglas Gregor /// \brief Determine whether this method has a body. 4557247c88d1e41514a41085f83ebf03dd5220e054aDavid Blaikie virtual bool hasBody() const { return Body.isValid(); } 4565456b0fe40714a78cd0ba7c1a5b7dc34eda385afDouglas Gregor 4575456b0fe40714a78cd0ba7c1a5b7dc34eda385afDouglas Gregor /// \brief Retrieve the body of this method, if it has one. 4585456b0fe40714a78cd0ba7c1a5b7dc34eda385afDouglas Gregor virtual Stmt *getBody() const; 4595456b0fe40714a78cd0ba7c1a5b7dc34eda385afDouglas Gregor 4605456b0fe40714a78cd0ba7c1a5b7dc34eda385afDouglas Gregor void setLazyBody(uint64_t Offset) { Body = Offset; } 4615456b0fe40714a78cd0ba7c1a5b7dc34eda385afDouglas Gregor 4625456b0fe40714a78cd0ba7c1a5b7dc34eda385afDouglas Gregor CompoundStmt *getCompoundBody() { return (CompoundStmt*)getBody(); } 463d3a413d3b8eb39bcee5944bc545d9997c1abe492Sebastian Redl void setBody(Stmt *B) { Body = B; } 46458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff 46566570b230941651245accbc5680b60e904eb993cArgyrios Kyrtzidis /// \brief Returns whether this specific method is a definition. 4667247c88d1e41514a41085f83ebf03dd5220e054aDavid Blaikie bool isThisDeclarationADefinition() const { return hasBody(); } 46766570b230941651245accbc5680b60e904eb993cArgyrios Kyrtzidis 46858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff // Implement isa/cast/dyncast/etc. 46980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 47080cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCMethod; } 47142220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis static DeclContext *castToDeclContext(const ObjCMethodDecl *D) { 47242220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis return static_cast<DeclContext *>(const_cast<ObjCMethodDecl*>(D)); 47342220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis } 47442220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis static ObjCMethodDecl *castFromDeclContext(const DeclContext *DC) { 47542220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis return static_cast<ObjCMethodDecl *>(const_cast<DeclContext*>(DC)); 47642220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis } 477491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis 478491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis friend class ASTDeclReader; 479491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis friend class ASTDeclWriter; 48058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff}; 481e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 482e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff/// ObjCContainerDecl - Represents a container for method declarations. 483aecae629269fae3bf484baf1d109e9a89d14eeadArgyrios Kyrtzidis/// Current sub-classes are ObjCInterfaceDecl, ObjCCategoryDecl, 4841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// ObjCProtocolDecl, and ObjCImplDecl. 485e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff/// 4864afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCContainerDecl : public NamedDecl, public DeclContext { 48799ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie virtual void anchor(); 48899ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie 4891711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis SourceLocation AtStart; 4901711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis 491782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek // These two locations in the range mark the end of the method container. 492782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek // The first points to the '@' token, and the second to the 'end' token. 493782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek SourceRange AtEnd; 494e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroffpublic: 495e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 4961711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis ObjCContainerDecl(Kind DK, DeclContext *DC, 4971711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis IdentifierInfo *Id, SourceLocation nameLoc, 4981711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis SourceLocation atStartLoc) 4991711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis : NamedDecl(DK, DC, nameLoc, Id), DeclContext(DK), AtStart(atStartLoc) {} 500e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 50193983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff // Iterator access to properties. 50293983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff typedef specific_decl_iterator<ObjCPropertyDecl> prop_iterator; 5031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump prop_iterator prop_begin() const { 50417945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return prop_iterator(decls_begin()); 50593983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff } 5061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump prop_iterator prop_end() const { 50717945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return prop_iterator(decls_end()); 50809c4719788a5cea09897525e528fa00420f1677bSteve Naroff } 5091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5100701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff // Iterator access to instance/class methods. 511f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor typedef specific_decl_iterator<ObjCMethodDecl> method_iterator; 5121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump method_iterator meth_begin() const { 51317945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return method_iterator(decls_begin()); 5147ed4faca5162b3ab85be7f7e57aa40e6ec170971Ted Kremenek } 5151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump method_iterator meth_end() const { 51617945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return method_iterator(decls_end()); 5177ed4faca5162b3ab85be7f7e57aa40e6ec170971Ted Kremenek } 5180701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff 5191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump typedef filtered_decl_iterator<ObjCMethodDecl, 5201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump &ObjCMethodDecl::isInstanceMethod> 521669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor instmeth_iterator; 52217945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis instmeth_iterator instmeth_begin() const { 52317945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return instmeth_iterator(decls_begin()); 524e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff } 52517945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis instmeth_iterator instmeth_end() const { 52617945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return instmeth_iterator(decls_end()); 527e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff } 528e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 5291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump typedef filtered_decl_iterator<ObjCMethodDecl, 5301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump &ObjCMethodDecl::isClassMethod> 531669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor classmeth_iterator; 53217945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis classmeth_iterator classmeth_begin() const { 53317945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return classmeth_iterator(decls_begin()); 534e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff } 53517945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis classmeth_iterator classmeth_end() const { 53617945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return classmeth_iterator(decls_end()); 5370701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff } 5380701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff 5390701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff // Get the local instance/class method declared in this interface. 54004593d0f9d84f6adf942bd66f1587e05c6a47c42Argyrios Kyrtzidis ObjCMethodDecl *getMethod(Selector Sel, bool isInstance, 54104593d0f9d84f6adf942bd66f1587e05c6a47c42Argyrios Kyrtzidis bool AllowHidden = false) const; 54204593d0f9d84f6adf942bd66f1587e05c6a47c42Argyrios Kyrtzidis ObjCMethodDecl *getInstanceMethod(Selector Sel, 54304593d0f9d84f6adf942bd66f1587e05c6a47c42Argyrios Kyrtzidis bool AllowHidden = false) const { 54404593d0f9d84f6adf942bd66f1587e05c6a47c42Argyrios Kyrtzidis return getMethod(Sel, true/*isInstance*/, AllowHidden); 54504593d0f9d84f6adf942bd66f1587e05c6a47c42Argyrios Kyrtzidis } 54604593d0f9d84f6adf942bd66f1587e05c6a47c42Argyrios Kyrtzidis ObjCMethodDecl *getClassMethod(Selector Sel, bool AllowHidden = false) const { 54704593d0f9d84f6adf942bd66f1587e05c6a47c42Argyrios Kyrtzidis return getMethod(Sel, false/*isInstance*/, AllowHidden); 548467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis } 5495bdaef55d486f20346fe16f3d41324694d3ff0d5Fariborz Jahanian bool HasUserDeclaredSetterMethod(const ObjCPropertyDecl *P) const; 550467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis ObjCIvarDecl *getIvarDecl(IdentifierInfo *Id) const; 5511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 55217945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const; 55393983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff 554e63aedd0cb064fc106636ad856cc0e645e6374ceAnna Zaks typedef llvm::DenseMap<IdentifierInfo*, ObjCPropertyDecl*> PropertyMap; 555cfaed8d399a34e79fbab9f70eb4ea1bbeb81a02bFariborz Jahanian 5568dbda516d343706bae904f800c6d64e145d58a8cFariborz Jahanian typedef llvm::DenseMap<const ObjCProtocolDecl *, ObjCPropertyDecl*> 5578dbda516d343706bae904f800c6d64e145d58a8cFariborz Jahanian ProtocolPropertyMap; 5588dbda516d343706bae904f800c6d64e145d58a8cFariborz Jahanian 559cfaed8d399a34e79fbab9f70eb4ea1bbeb81a02bFariborz Jahanian typedef llvm::SmallVector<ObjCPropertyDecl*, 8> PropertyDeclOrder; 560cfaed8d399a34e79fbab9f70eb4ea1bbeb81a02bFariborz Jahanian 561b36ea375e20f71df19c101fa2399b7ea3a607e04Anna Zaks /// This routine collects list of properties to be implemented in the class. 562b36ea375e20f71df19c101fa2399b7ea3a607e04Anna Zaks /// This includes, class's and its conforming protocols' properties. 563e63aedd0cb064fc106636ad856cc0e645e6374ceAnna Zaks /// Note, the superclass's properties are not included in the list. 564cfaed8d399a34e79fbab9f70eb4ea1bbeb81a02bFariborz Jahanian virtual void collectPropertiesToImplement(PropertyMap &PM, 565cfaed8d399a34e79fbab9f70eb4ea1bbeb81a02bFariborz Jahanian PropertyDeclOrder &PO) const {} 566b36ea375e20f71df19c101fa2399b7ea3a607e04Anna Zaks 5671711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis SourceLocation getAtStartLoc() const { return AtStart; } 5681711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis void setAtStartLoc(SourceLocation Loc) { AtStart = Loc; } 5691711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis 570e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff // Marks the end of the container. 571782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek SourceRange getAtEndRange() const { 572782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek return AtEnd; 573782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek } 574782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek void setAtEndRange(SourceRange atEnd) { 575782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek AtEnd = atEnd; 576782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek } 577ddfd4c9eda34765b08fae4cb31ad5a365face107Argyrios Kyrtzidis 578aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar virtual SourceRange getSourceRange() const LLVM_READONLY { 5791711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis return SourceRange(AtStart, getAtEndRange().getEnd()); 580ddfd4c9eda34765b08fae4cb31ad5a365face107Argyrios Kyrtzidis } 5811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 58209c4719788a5cea09897525e528fa00420f1677bSteve Naroff // Implement isa/cast/dyncast/etc. 58380cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 58480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { 5859a55591af3e5506b95a9718e15380129fbfc5ebcSean Hunt return K >= firstObjCContainer && 5869a55591af3e5506b95a9718e15380129fbfc5ebcSean Hunt K <= lastObjCContainer; 58780cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall } 58809c4719788a5cea09897525e528fa00420f1677bSteve Naroff 58909c4719788a5cea09897525e528fa00420f1677bSteve Naroff static DeclContext *castToDeclContext(const ObjCContainerDecl *D) { 59009c4719788a5cea09897525e528fa00420f1677bSteve Naroff return static_cast<DeclContext *>(const_cast<ObjCContainerDecl*>(D)); 59109c4719788a5cea09897525e528fa00420f1677bSteve Naroff } 59209c4719788a5cea09897525e528fa00420f1677bSteve Naroff static ObjCContainerDecl *castFromDeclContext(const DeclContext *DC) { 59309c4719788a5cea09897525e528fa00420f1677bSteve Naroff return static_cast<ObjCContainerDecl *>(const_cast<DeclContext*>(DC)); 59409c4719788a5cea09897525e528fa00420f1677bSteve Naroff } 595e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff}; 596e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff 5970982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \brief Represents an ObjC class declaration. 5980c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 5990982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// For example: 6000982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// 6010982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \code 6020c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// // MostPrimitive declares no super class (not particularly useful). 60341c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@interface MostPrimitive 6040c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// // no instance variables or methods. 60541c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@end 6060c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 6071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// // NSResponder inherits from NSObject & implements NSCoding (a protocol). 6080982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \@interface NSResponder : NSObject \<NSCoding> 609a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// { // instance variables are represented by ObjCIvarDecl. 6100c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id nextResponder; // nextResponder instance variable. 6110c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// } 6120c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSResponder *)nextResponder; // return a pointer to NSResponder. 6130c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (void)mouseMoved:(NSEvent *)theEvent; // return void, takes a pointer 61441c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@end // to an NSEvent. 6150982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \endcode 6160c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 61741c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// Unlike C/C++, forward class declarations are accomplished with \@class. 61841c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// Unlike C/C++, \@class allows for a list of classes to be forward declared. 6190c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Unlike C++, ObjC is a single-rooted class model. In Cocoa, classes 6200c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// typically inherit from NSObject (an exception is NSProxy). 6210c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 62253df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregorclass ObjCInterfaceDecl : public ObjCContainerDecl 62353df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor , public Redeclarable<ObjCInterfaceDecl> { 62499ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie virtual void anchor(); 62599ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie 6263110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff /// TypeForDecl - This indicates the Type object that represents this 6273110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff /// TypeDecl. It is a cache maintained by ASTContext::getObjCInterfaceType 628f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall mutable const Type *TypeForDecl; 6293110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff friend class ASTContext; 6302e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 6312e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor struct DefinitionData { 63226fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor /// \brief The definition of this class, for quick access from any 63326fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor /// declaration. 63426fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor ObjCInterfaceDecl *Definition; 63526fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor 6362e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// Class's super class. 6372e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor ObjCInterfaceDecl *SuperClass; 6381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 63941c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// Protocols referenced in the \@interface declaration 6402e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor ObjCProtocolList ReferencedProtocols; 6411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 64241c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// Protocols reference in both the \@interface and class extensions. 6432e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor ObjCList<ObjCProtocolDecl> AllReferencedProtocols; 644ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 6452e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// \brief List of categories and class extensions defined for this class. 6462e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// 6472e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// Categories are stored as a linked list in the AST, since the categories 6482e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// and class extensions come long after the initial interface declaration, 6492e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// and we avoid dynamically-resized arrays in the AST wherever possible. 6502e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor ObjCCategoryDecl *CategoryList; 6511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6522e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// IvarList - List of all ivars defined by this class; including class 6532e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// extensions and implementation. This list is built lazily. 6542e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor ObjCIvarDecl *IvarList; 655ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 6562e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// \brief Indicates that the contents of this Objective-C class will be 6572e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// completed by the external AST source when required. 6582e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor mutable bool ExternallyCompleted : 1; 6592e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 6604919de6a53a007487c6d6b173921b5e7152a2004Adrian Prantl /// \brief Indicates that the ivar cache does not yet include ivars 6614919de6a53a007487c6d6b173921b5e7152a2004Adrian Prantl /// declared in the implementation. 6624919de6a53a007487c6d6b173921b5e7152a2004Adrian Prantl mutable bool IvarListMissingImplementation : 1; 6634919de6a53a007487c6d6b173921b5e7152a2004Adrian Prantl 66405c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor /// \brief The location of the superclass, if any. 66505c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor SourceLocation SuperClassLoc; 666161794732195881c33305f701f6e58721998541fDouglas Gregor 66705c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor /// \brief The location of the last location in this declaration, before 66805c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor /// the properties/methods. For example, this will be the '>', '}', or 66905c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor /// identifier, 67005c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor SourceLocation EndLoc; 67105c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor 67226fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor DefinitionData() : Definition(), SuperClass(), CategoryList(), IvarList(), 6734919de6a53a007487c6d6b173921b5e7152a2004Adrian Prantl ExternallyCompleted(), 6744919de6a53a007487c6d6b173921b5e7152a2004Adrian Prantl IvarListMissingImplementation(true) { } 6752e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor }; 6762e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 6772e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor ObjCInterfaceDecl(DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, 67837f953f021c67e3b97f1ef38e1ef3cb08bd9d146Douglas Gregor SourceLocation CLoc, ObjCInterfaceDecl *PrevDecl, 67937f953f021c67e3b97f1ef38e1ef3cb08bd9d146Douglas Gregor bool isInternal); 6802e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 6812e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor void LoadExternalDefinition() const; 6822e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 6832e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// \brief Contains a pointer to the data associated with this class, 6842e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// which will be NULL if this class has not yet been defined. 6856bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor /// 6866bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor /// The bit indicates when we don't need to check for out-of-date 6876bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor /// declarations. It will be set unless modules are enabled. 6886bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor llvm::PointerIntPair<DefinitionData *, 1, bool> Data; 6892e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 6902e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor DefinitionData &data() const { 6916bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor assert(Data.getPointer() && "Declaration has no definition!"); 6926bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor return *Data.getPointer(); 6932e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor } 6941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6952e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// \brief Allocate the definition data for this class. 6962e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor void allocateDefinitionData(); 6972e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 69853df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor typedef Redeclarable<ObjCInterfaceDecl> redeclarable_base; 69953df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor virtual ObjCInterfaceDecl *getNextRedeclaration() { 7006bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor return RedeclLink.getNext(); 70153df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor } 702ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor virtual ObjCInterfaceDecl *getPreviousDeclImpl() { 703ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor return getPreviousDecl(); 704ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor } 705ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor virtual ObjCInterfaceDecl *getMostRecentDeclImpl() { 706ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor return getMostRecentDecl(); 707ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor } 70853df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor 7090e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattnerpublic: 710a6ea10e22b600d92e084f6b11b9b9a92d0eb2412Douglas Gregor static ObjCInterfaceDecl *Create(const ASTContext &C, DeclContext *DC, 7110ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner SourceLocation atLoc, 7121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump IdentifierInfo *Id, 7130af550115df1f57f17a4f125ff0e8b34820c65d1Douglas Gregor ObjCInterfaceDecl *PrevDecl, 714deacbdca554298ccdf636f19c6094a8825ec6b34Douglas Gregor SourceLocation ClassLoc = SourceLocation(), 7150e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattner bool isInternal = false); 716d1cf3ff6c7e34fce764293cd2900fce99a60ed69Argyrios Kyrtzidis 7171e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor static ObjCInterfaceDecl *CreateDeserialized(ASTContext &C, unsigned ID); 7180af550115df1f57f17a4f125ff0e8b34820c65d1Douglas Gregor 719aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar virtual SourceRange getSourceRange() const LLVM_READONLY { 7207723fec9b45b7258c0eddf4cbfd0d335348f5edcDouglas Gregor if (isThisDeclarationADefinition()) 7217723fec9b45b7258c0eddf4cbfd0d335348f5edcDouglas Gregor return ObjCContainerDecl::getSourceRange(); 7227723fec9b45b7258c0eddf4cbfd0d335348f5edcDouglas Gregor 7237723fec9b45b7258c0eddf4cbfd0d335348f5edcDouglas Gregor return SourceRange(getAtStartLoc(), getLocation()); 724d1cf3ff6c7e34fce764293cd2900fce99a60ed69Argyrios Kyrtzidis } 725ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 72626ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor /// \brief Indicate that this Objective-C class is complete, but that 72726ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor /// the external AST source will be responsible for filling in its contents 72826ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor /// when a complete class is required. 72926ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor void setExternallyCompleted(); 730ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 73118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const ObjCProtocolList &getReferencedProtocols() const { 732a5f4441de7890953460d95f4e88b9fa432b48dc2Argyrios Kyrtzidis assert(hasDefinition() && "Caller did not check for forward reference!"); 7332e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (data().ExternallyCompleted) 73426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 735ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 7362e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return data().ReferencedProtocols; 7377ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian } 7388a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis 7398a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis ObjCImplementationDecl *getImplementation() const; 7408a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis void setImplementation(ObjCImplementationDecl *ImplD); 7418a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis 742559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian ObjCCategoryDecl *FindCategoryDeclaration(IdentifierInfo *CategoryId) const; 7431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7441cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis // Get the local instance/class method declared in a category. 7451cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis ObjCMethodDecl *getCategoryInstanceMethod(Selector Sel) const; 7461cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis ObjCMethodDecl *getCategoryClassMethod(Selector Sel) const; 7471cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis ObjCMethodDecl *getCategoryMethod(Selector Sel, bool isInstance) const { 7481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return isInstance ? getInstanceMethod(Sel) 7491cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis : getClassMethod(Sel); 7501cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis } 7513db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner 75218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor typedef ObjCProtocolList::iterator protocol_iterator; 753ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 75453b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek protocol_iterator protocol_begin() const { 7552e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor // FIXME: Should make sure no callers ever do this. 7562e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (!hasDefinition()) 7572e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return protocol_iterator(); 7582e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 7592e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (data().ExternallyCompleted) 76026ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 76126ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 7622e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return data().ReferencedProtocols.begin(); 76353b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek } 76453b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek protocol_iterator protocol_end() const { 7652e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor // FIXME: Should make sure no callers ever do this. 7662e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (!hasDefinition()) 7672e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return protocol_iterator(); 7682e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 7692e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (data().ExternallyCompleted) 77026ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 77126ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 7722e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return data().ReferencedProtocols.end(); 77353b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek } 77453b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 77518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor typedef ObjCProtocolList::loc_iterator protocol_loc_iterator; 77653b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 777ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie protocol_loc_iterator protocol_loc_begin() const { 7782e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor // FIXME: Should make sure no callers ever do this. 7792e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (!hasDefinition()) 7802e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return protocol_loc_iterator(); 7812e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 7822e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (data().ExternallyCompleted) 78326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 78426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 7852e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return data().ReferencedProtocols.loc_begin(); 78618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor } 78753b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 788ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie protocol_loc_iterator protocol_loc_end() const { 7892e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor // FIXME: Should make sure no callers ever do this. 7902e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (!hasDefinition()) 7912e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return protocol_loc_iterator(); 7922e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 7932e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (data().ExternallyCompleted) 79426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 79526ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 7962e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return data().ReferencedProtocols.loc_end(); 79718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor } 798ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 79953b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek typedef ObjCList<ObjCProtocolDecl>::iterator all_protocol_iterator; 800ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 80153b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek all_protocol_iterator all_referenced_protocol_begin() const { 8022e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor // FIXME: Should make sure no callers ever do this. 8032e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (!hasDefinition()) 8042e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return all_protocol_iterator(); 8052e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 8062e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (data().ExternallyCompleted) 80726ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 80826ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 8092e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return data().AllReferencedProtocols.empty() 8102e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor ? protocol_begin() 8112e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor : data().AllReferencedProtocols.begin(); 81253b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek } 81353b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek all_protocol_iterator all_referenced_protocol_end() const { 8142e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor // FIXME: Should make sure no callers ever do this. 8152e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (!hasDefinition()) 8162e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return all_protocol_iterator(); 8172e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 8182e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (data().ExternallyCompleted) 81926ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 82026ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 8212e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return data().AllReferencedProtocols.empty() 8222e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor ? protocol_end() 8232e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor : data().AllReferencedProtocols.end(); 82453b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek } 825291be393aa33759e6e34b6429c5ffa206ba50115Douglas Gregor 82611062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator; 82753b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 8282e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor ivar_iterator ivar_begin() const { 8292e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (const ObjCInterfaceDecl *Def = getDefinition()) 8302e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return ivar_iterator(Def->decls_begin()); 8312e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 8322e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor // FIXME: Should make sure no callers ever do this. 8332e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return ivar_iterator(); 8342e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor } 8352e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor ivar_iterator ivar_end() const { 8362e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (const ObjCInterfaceDecl *Def = getDefinition()) 8372e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return ivar_iterator(Def->decls_end()); 8382e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 8392e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor // FIXME: Should make sure no callers ever do this. 8402e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return ivar_iterator(); 8412e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor } 84253b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 84311062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian unsigned ivar_size() const { 84411062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian return std::distance(ivar_begin(), ivar_end()); 84511062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian } 846ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 84711062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian bool ivar_empty() const { return ivar_begin() == ivar_end(); } 848ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 849db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose ObjCIvarDecl *all_declared_ivar_begin(); 850db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose const ObjCIvarDecl *all_declared_ivar_begin() const { 851db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose // Even though this modifies IvarList, it's conceptually const: 852db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose // the ivar chain is essentially a cached property of ObjCInterfaceDecl. 853db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose return const_cast<ObjCInterfaceDecl *>(this)->all_declared_ivar_begin(); 854db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose } 8552e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor void setIvarList(ObjCIvarDecl *ivar) { data().IvarList = ivar; } 856ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 85738af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner /// setProtocolList - Set the list of protocols that this interface 858b752f289026ad8e5f44851b20e009a27ed61eefcChris Lattner /// implements. 85938af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void setProtocolList(ObjCProtocolDecl *const* List, unsigned Num, 86018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const SourceLocation *Locs, ASTContext &C) { 8612e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor data().ReferencedProtocols.set(List, Num, Locs, C); 8623db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner } 8631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 864339798eae1eb61c50ca68766ed028c0a16d0a284Fariborz Jahanian /// mergeClassExtensionProtocolList - Merge class extension's protocol list 865339798eae1eb61c50ca68766ed028c0a16d0a284Fariborz Jahanian /// into the protocol list for this class. 866ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie void mergeClassExtensionProtocolList(ObjCProtocolDecl *const* List, 86718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor unsigned Num, 86818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor ASTContext &C); 869339798eae1eb61c50ca68766ed028c0a16d0a284Fariborz Jahanian 87053df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor /// \brief Determine whether this particular declaration of this class is 87153df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor /// actually also a definition. 87226fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor bool isThisDeclarationADefinition() const { 8736bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor return getDefinition() == this; 87426fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor } 87553df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor 8762e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// \brief Determine whether this class has been defined. 8776bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor bool hasDefinition() const { 8786bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor // If the name of this class is out-of-date, bring it up-to-date, which 8796bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor // might bring in a definition. 8806bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor // Note: a null value indicates that we don't have a definition and that 8816bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor // modules are enabled. 8826bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor if (!Data.getOpaqueValue()) { 8836bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor if (IdentifierInfo *II = getIdentifier()) { 8846bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor if (II->isOutOfDate()) { 8856bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor updateOutOfDate(*II); 8866bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor } 8876bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor } 8886bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor } 8896bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor 8906bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor return Data.getPointer(); 8916bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor } 89253df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor 8932e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// \brief Retrieve the definition of this class, or NULL if this class 89441c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// has been forward-declared (with \@class) but not yet defined (with 89541c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// \@interface). 8962e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor ObjCInterfaceDecl *getDefinition() { 8976bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor return hasDefinition()? Data.getPointer()->Definition : 0; 8982e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor } 899ad834d534e9a5db3d3baa09593775f83ceaff1f2Argyrios Kyrtzidis 9002e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// \brief Retrieve the definition of this class, or NULL if this class 90141c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// has been forward-declared (with \@class) but not yet defined (with 90241c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// \@interface). 9032e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor const ObjCInterfaceDecl *getDefinition() const { 9046bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor return hasDefinition()? Data.getPointer()->Definition : 0; 9052e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor } 9061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9072e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor /// \brief Starts the definition of this Objective-C class, taking it from 90841c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// a forward declaration (\@class) to a definition (\@interface). 9092e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor void startDefinition(); 9102e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 911ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie ObjCInterfaceDecl *getSuperClass() const { 9122e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor // FIXME: Should make sure no callers ever do this. 9132e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (!hasDefinition()) 9142e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return 0; 9152e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 9162e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (data().ExternallyCompleted) 91726ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 91826ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 9192e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return data().SuperClass; 92026ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor } 921ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 9222e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor void setSuperClass(ObjCInterfaceDecl * superCls) { 923712ef874534ee1bef41d1aa4664ae36148ec8b12Fariborz Jahanian data().SuperClass = 924712ef874534ee1bef41d1aa4664ae36148ec8b12Fariborz Jahanian (superCls && superCls->hasDefinition()) ? superCls->getDefinition() 925712ef874534ee1bef41d1aa4664ae36148ec8b12Fariborz Jahanian : superCls; 9262e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor } 9271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 928d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Iterator that walks over the list of categories, filtering out 929d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// those that do not meet specific criteria. 930d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// 931d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// This class template is used for the various permutations of category 932d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// and extension iterators. 933d329724745b49f894b768d47275b7c2713106e89Douglas Gregor template<bool (*Filter)(ObjCCategoryDecl *)> 934d329724745b49f894b768d47275b7c2713106e89Douglas Gregor class filtered_category_iterator { 935d329724745b49f894b768d47275b7c2713106e89Douglas Gregor ObjCCategoryDecl *Current; 936d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 937d329724745b49f894b768d47275b7c2713106e89Douglas Gregor void findAcceptableCategory(); 938d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 939d329724745b49f894b768d47275b7c2713106e89Douglas Gregor public: 940d329724745b49f894b768d47275b7c2713106e89Douglas Gregor typedef ObjCCategoryDecl * value_type; 941d329724745b49f894b768d47275b7c2713106e89Douglas Gregor typedef value_type reference; 942d329724745b49f894b768d47275b7c2713106e89Douglas Gregor typedef value_type pointer; 943d329724745b49f894b768d47275b7c2713106e89Douglas Gregor typedef std::ptrdiff_t difference_type; 944d329724745b49f894b768d47275b7c2713106e89Douglas Gregor typedef std::input_iterator_tag iterator_category; 945d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 946d329724745b49f894b768d47275b7c2713106e89Douglas Gregor filtered_category_iterator() : Current(0) { } 947d329724745b49f894b768d47275b7c2713106e89Douglas Gregor explicit filtered_category_iterator(ObjCCategoryDecl *Current) 948d329724745b49f894b768d47275b7c2713106e89Douglas Gregor : Current(Current) 949d329724745b49f894b768d47275b7c2713106e89Douglas Gregor { 950d329724745b49f894b768d47275b7c2713106e89Douglas Gregor findAcceptableCategory(); 951d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 952d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 953d329724745b49f894b768d47275b7c2713106e89Douglas Gregor reference operator*() const { return Current; } 954d329724745b49f894b768d47275b7c2713106e89Douglas Gregor pointer operator->() const { return Current; } 955d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 956d329724745b49f894b768d47275b7c2713106e89Douglas Gregor filtered_category_iterator &operator++(); 957d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 958d329724745b49f894b768d47275b7c2713106e89Douglas Gregor filtered_category_iterator operator++(int) { 959d329724745b49f894b768d47275b7c2713106e89Douglas Gregor filtered_category_iterator Tmp = *this; 960d329724745b49f894b768d47275b7c2713106e89Douglas Gregor ++(*this); 961d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return Tmp; 962d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 963d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 964d329724745b49f894b768d47275b7c2713106e89Douglas Gregor friend bool operator==(filtered_category_iterator X, 965d329724745b49f894b768d47275b7c2713106e89Douglas Gregor filtered_category_iterator Y) { 9661c2397539d1b105eacee2a69ece4775d0af45618Matt Beaumont-Gay return X.Current == Y.Current; 967d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 968d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 969d329724745b49f894b768d47275b7c2713106e89Douglas Gregor friend bool operator!=(filtered_category_iterator X, 970d329724745b49f894b768d47275b7c2713106e89Douglas Gregor filtered_category_iterator Y) { 971d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return X.Current != Y.Current; 972d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 973d329724745b49f894b768d47275b7c2713106e89Douglas Gregor }; 974d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 975d329724745b49f894b768d47275b7c2713106e89Douglas Gregorprivate: 976d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Test whether the given category is visible. 977d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// 978d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// Used in the \c visible_categories_iterator. 979d329724745b49f894b768d47275b7c2713106e89Douglas Gregor static bool isVisibleCategory(ObjCCategoryDecl *Cat); 980d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 981d329724745b49f894b768d47275b7c2713106e89Douglas Gregorpublic: 982d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Iterator that walks over the list of categories and extensions 983d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// that are visible, i.e., not hidden in a non-imported submodule. 984d329724745b49f894b768d47275b7c2713106e89Douglas Gregor typedef filtered_category_iterator<isVisibleCategory> 985d329724745b49f894b768d47275b7c2713106e89Douglas Gregor visible_categories_iterator; 986d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 987d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Retrieve an iterator to the beginning of the visible-categories 988d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// list. 989d329724745b49f894b768d47275b7c2713106e89Douglas Gregor visible_categories_iterator visible_categories_begin() const { 990d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return visible_categories_iterator(getCategoryListRaw()); 991d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 992d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 993d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Retrieve an iterator to the end of the visible-categories list. 994d329724745b49f894b768d47275b7c2713106e89Douglas Gregor visible_categories_iterator visible_categories_end() const { 995d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return visible_categories_iterator(); 996d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 997d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 998d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Determine whether the visible-categories list is empty. 999d329724745b49f894b768d47275b7c2713106e89Douglas Gregor bool visible_categories_empty() const { 1000d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return visible_categories_begin() == visible_categories_end(); 1001d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 1002d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 1003d329724745b49f894b768d47275b7c2713106e89Douglas Gregorprivate: 1004d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Test whether the given category... is a category. 1005d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// 1006d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// Used in the \c known_categories_iterator. 1007d329724745b49f894b768d47275b7c2713106e89Douglas Gregor static bool isKnownCategory(ObjCCategoryDecl *) { return true; } 1008d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 1009d329724745b49f894b768d47275b7c2713106e89Douglas Gregorpublic: 1010d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Iterator that walks over all of the known categories and 1011d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// extensions, including those that are hidden. 1012d329724745b49f894b768d47275b7c2713106e89Douglas Gregor typedef filtered_category_iterator<isKnownCategory> known_categories_iterator; 1013d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 1014d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Retrieve an iterator to the beginning of the known-categories 1015d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// list. 1016d329724745b49f894b768d47275b7c2713106e89Douglas Gregor known_categories_iterator known_categories_begin() const { 1017d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return known_categories_iterator(getCategoryListRaw()); 1018d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 1019d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 1020d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Retrieve an iterator to the end of the known-categories list. 1021d329724745b49f894b768d47275b7c2713106e89Douglas Gregor known_categories_iterator known_categories_end() const { 1022d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return known_categories_iterator(); 1023d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 1024d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 1025d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Determine whether the known-categories list is empty. 1026d329724745b49f894b768d47275b7c2713106e89Douglas Gregor bool known_categories_empty() const { 1027d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return known_categories_begin() == known_categories_end(); 1028d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 1029d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 1030d329724745b49f894b768d47275b7c2713106e89Douglas Gregorprivate: 1031d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Test whether the given category is a visible extension. 1032d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// 1033d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// Used in the \c visible_extensions_iterator. 1034d329724745b49f894b768d47275b7c2713106e89Douglas Gregor static bool isVisibleExtension(ObjCCategoryDecl *Cat); 1035d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 1036d329724745b49f894b768d47275b7c2713106e89Douglas Gregorpublic: 1037d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Iterator that walks over all of the visible extensions, skipping 1038d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// any that are known but hidden. 1039d329724745b49f894b768d47275b7c2713106e89Douglas Gregor typedef filtered_category_iterator<isVisibleExtension> 1040d329724745b49f894b768d47275b7c2713106e89Douglas Gregor visible_extensions_iterator; 1041d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 1042d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Retrieve an iterator to the beginning of the visible-extensions 1043d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// list. 1044d329724745b49f894b768d47275b7c2713106e89Douglas Gregor visible_extensions_iterator visible_extensions_begin() const { 1045d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return visible_extensions_iterator(getCategoryListRaw()); 1046d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 1047d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 1048d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Retrieve an iterator to the end of the visible-extensions list. 1049d329724745b49f894b768d47275b7c2713106e89Douglas Gregor visible_extensions_iterator visible_extensions_end() const { 1050d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return visible_extensions_iterator(); 1051d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 1052d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 1053d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Determine whether the visible-extensions list is empty. 1054d329724745b49f894b768d47275b7c2713106e89Douglas Gregor bool visible_extensions_empty() const { 1055d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return visible_extensions_begin() == visible_extensions_end(); 1056d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 1057d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 1058d329724745b49f894b768d47275b7c2713106e89Douglas Gregorprivate: 1059d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Test whether the given category is an extension. 1060d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// 1061d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// Used in the \c known_extensions_iterator. 1062d329724745b49f894b768d47275b7c2713106e89Douglas Gregor static bool isKnownExtension(ObjCCategoryDecl *Cat); 1063d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 1064d329724745b49f894b768d47275b7c2713106e89Douglas Gregorpublic: 1065d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Iterator that walks over all of the known extensions. 1066d329724745b49f894b768d47275b7c2713106e89Douglas Gregor typedef filtered_category_iterator<isKnownExtension> 1067d329724745b49f894b768d47275b7c2713106e89Douglas Gregor known_extensions_iterator; 1068d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 1069d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Retrieve an iterator to the beginning of the known-extensions 1070d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// list. 1071d329724745b49f894b768d47275b7c2713106e89Douglas Gregor known_extensions_iterator known_extensions_begin() const { 1072d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return known_extensions_iterator(getCategoryListRaw()); 1073d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 1074d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 1075d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Retrieve an iterator to the end of the known-extensions list. 1076d329724745b49f894b768d47275b7c2713106e89Douglas Gregor known_extensions_iterator known_extensions_end() const { 1077d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return known_extensions_iterator(); 1078d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 1079d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 1080d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Determine whether the known-extensions list is empty. 1081d329724745b49f894b768d47275b7c2713106e89Douglas Gregor bool known_extensions_empty() const { 1082d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return known_extensions_begin() == known_extensions_end(); 1083d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 1084d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 1085d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Retrieve the raw pointer to the start of the category/extension 1086d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// list. 1087d329724745b49f894b768d47275b7c2713106e89Douglas Gregor ObjCCategoryDecl* getCategoryListRaw() const { 10882e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor // FIXME: Should make sure no callers ever do this. 10892e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (!hasDefinition()) 10902e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return 0; 10912e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 10922e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor if (data().ExternallyCompleted) 109326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor LoadExternalDefinition(); 109426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor 10952e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor return data().CategoryList; 109626ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor } 1097ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1098d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Set the raw pointer to the start of the category/extension 1099d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// list. 1100d329724745b49f894b768d47275b7c2713106e89Douglas Gregor void setCategoryListRaw(ObjCCategoryDecl *category) { 11012e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor data().CategoryList = category; 1102980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff } 1103ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 110437cafb077ad5b170acae77e566638603011ef4c0Ted Kremenek ObjCPropertyDecl 110537cafb077ad5b170acae77e566638603011ef4c0Ted Kremenek *FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId) const; 110637cafb077ad5b170acae77e566638603011ef4c0Ted Kremenek 1107cfaed8d399a34e79fbab9f70eb4ea1bbeb81a02bFariborz Jahanian virtual void collectPropertiesToImplement(PropertyMap &PM, 1108cfaed8d399a34e79fbab9f70eb4ea1bbeb81a02bFariborz Jahanian PropertyDeclOrder &PO) const; 1109b36ea375e20f71df19c101fa2399b7ea3a607e04Anna Zaks 111053efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner /// isSuperClassOf - Return true if this class is the specified class or is a 111153efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner /// super class of the specified interface class. 111253efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner bool isSuperClassOf(const ObjCInterfaceDecl *I) const { 111353efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner // If RHS is derived from LHS it is OK; else it is not OK. 111453efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner while (I != NULL) { 111560ef308e51c71b760d7f598c1b763ceb7b768148Douglas Gregor if (declaresSameEntity(this, I)) 111653efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner return true; 11172e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 111853efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner I = I->getSuperClass(); 111953efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner } 112053efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner return false; 112153efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner } 11221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 11237263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian /// isArcWeakrefUnavailable - Checks for a class or one of its super classes 11247263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian /// to be incompatible with __weak references. Returns true if it is. 11252fa67efeaf66a9332c30a026dc1c21bef6c33a6cBenjamin Kramer bool isArcWeakrefUnavailable() const; 11267263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian 112771207fc0470e1eee40a2951cd5cc3ff47725b755Ted Kremenek /// isObjCRequiresPropertyDefs - Checks that a class or one of its super 112841c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// classes must not be auto-synthesized. Returns class decl. if it must not 112941c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// be; 0, otherwise. 11302fa67efeaf66a9332c30a026dc1c21bef6c33a6cBenjamin Kramer const ObjCInterfaceDecl *isObjCRequiresPropertyDefs() const; 1131e23dcf3524fe01208cc79e707412f0a5dd8eed7bFariborz Jahanian 113217945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName, 113368a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner ObjCInterfaceDecl *&ClassDeclared); 113417945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName) { 113568a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner ObjCInterfaceDecl *ClassDeclared; 113617945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return lookupInstanceVariable(IVarName, ClassDeclared); 113768a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner } 113868a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner 113907b1bbe648a21b8cdbc073fb6a409422c49921bbFariborz Jahanian ObjCProtocolDecl *lookupNestedProtocol(IdentifierInfo *Name); 114007b1bbe648a21b8cdbc073fb6a409422c49921bbFariborz Jahanian 114194a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff // Lookup a method. First, we search locally. If a method isn't 114294a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff // found, we search referenced protocols and class categories. 1143bb3d14e55d267bf5228699c7bf0c8ccdb71c8f46Fariborz Jahanian ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance, 1144c775b1a0702621e297d00452a897381c8bf10f3fFariborz Jahanian bool shallowCategoryLookup= false, 1145f3f0f357f8d6b4511b6d605cc8a39ae3787fef6dFariborz Jahanian const ObjCCategoryDecl *C= 0) const; 1146bb3d14e55d267bf5228699c7bf0c8ccdb71c8f46Fariborz Jahanian ObjCMethodDecl *lookupInstanceMethod(Selector Sel, 1147bf393be8a0b8b573ceb23ed19ac953832a2a69e4Fariborz Jahanian bool shallowCategoryLookup = false) const { 1148bf393be8a0b8b573ceb23ed19ac953832a2a69e4Fariborz Jahanian return lookupMethod(Sel, true/*isInstance*/, shallowCategoryLookup); 1149bb3d14e55d267bf5228699c7bf0c8ccdb71c8f46Fariborz Jahanian } 1150bb3d14e55d267bf5228699c7bf0c8ccdb71c8f46Fariborz Jahanian ObjCMethodDecl *lookupClassMethod(Selector Sel, 1151bf393be8a0b8b573ceb23ed19ac953832a2a69e4Fariborz Jahanian bool shallowCategoryLookup = false) const { 1152bf393be8a0b8b573ceb23ed19ac953832a2a69e4Fariborz Jahanian return lookupMethod(Sel, false/*isInstance*/, shallowCategoryLookup); 1153aa5420c1e36ab8e0e4bb87239d8b73a3a8ce75dbArgyrios Kyrtzidis } 1154cd1876207f5564beba74e4b2524b664bdba0ba9fFariborz Jahanian ObjCInterfaceDecl *lookupInheritedClass(const IdentifierInfo *ICName); 1155ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1156e61354b274ec5aa6acf3d15271896ce7596bb123Anna Zaks /// \brief Lookup a method in the classes implementation hierarchy. 1157ca93ee707d9570b74d24c7d55defe18dac38bcc0Anna Zaks ObjCMethodDecl *lookupPrivateMethod(const Selector &Sel, 1158ca93ee707d9570b74d24c7d55defe18dac38bcc0Anna Zaks bool Instance=true) const; 115960fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff 1160e61354b274ec5aa6acf3d15271896ce7596bb123Anna Zaks ObjCMethodDecl *lookupPrivateClassMethod(const Selector &Sel) { 1161e61354b274ec5aa6acf3d15271896ce7596bb123Anna Zaks return lookupPrivateMethod(Sel, false); 1162e61354b274ec5aa6acf3d15271896ce7596bb123Anna Zaks } 1163e61354b274ec5aa6acf3d15271896ce7596bb123Anna Zaks 1164f3f0f357f8d6b4511b6d605cc8a39ae3787fef6dFariborz Jahanian /// \brief Lookup a setter or getter in the class hierarchy, 1165f3f0f357f8d6b4511b6d605cc8a39ae3787fef6dFariborz Jahanian /// including in all categories except for category passed 1166f3f0f357f8d6b4511b6d605cc8a39ae3787fef6dFariborz Jahanian /// as argument. 1167f3f0f357f8d6b4511b6d605cc8a39ae3787fef6dFariborz Jahanian ObjCMethodDecl *lookupPropertyAccessor(const Selector Sel, 1168f3f0f357f8d6b4511b6d605cc8a39ae3787fef6dFariborz Jahanian const ObjCCategoryDecl *Cat) const { 1169f3f0f357f8d6b4511b6d605cc8a39ae3787fef6dFariborz Jahanian return lookupMethod(Sel, true/*isInstance*/, 1170f3f0f357f8d6b4511b6d605cc8a39ae3787fef6dFariborz Jahanian false/*shallowCategoryLookup*/, Cat); 1171c775b1a0702621e297d00452a897381c8bf10f3fFariborz Jahanian } 1172f3f0f357f8d6b4511b6d605cc8a39ae3787fef6dFariborz Jahanian 117305c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor SourceLocation getEndOfDefinitionLoc() const { 117405c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor if (!hasDefinition()) 117505c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor return getLocation(); 117605c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor 117705c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor return data().EndLoc; 117805c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor } 117905c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor 118005c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor void setEndOfDefinitionLoc(SourceLocation LE) { data().EndLoc = LE; } 11811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 11822e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor void setSuperClassLoc(SourceLocation Loc) { data().SuperClassLoc = Loc; } 11832e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor SourceLocation getSuperClassLoc() const { return data().SuperClassLoc; } 11841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 118528e71cf851b73a67604735a9a95aef800b144e2eSteve Naroff /// isImplicitInterfaceDecl - check that this is an implicitly declared 118641c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// ObjCInterfaceDecl node. This is for legacy objective-c \@implementation 118741c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// declaration without an \@interface declaration. 118897bbab2df74cbfe221fb20454738d607a41f3ca4Fariborz Jahanian bool isImplicitInterfaceDecl() const { 11896bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor return hasDefinition() ? data().Definition->isImplicit() : isImplicit(); 119097bbab2df74cbfe221fb20454738d607a41f3ca4Fariborz Jahanian } 11911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 11920fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian /// ClassImplementsProtocol - Checks that 'lProto' protocol 11930fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian /// has been implemented in IDecl class, its super class or categories (if 11940fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian /// lookupCategory is true). 11950fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, 11960fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian bool lookupCategory, 11970fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian bool RHSIsQualifiedID = false); 11981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1199a54fbf2499c7cc999e22abb9be484ce976ed9689Douglas Gregor typedef redeclarable_base::redecl_iterator redecl_iterator; 1200ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor using redeclarable_base::redecls_begin; 1201ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor using redeclarable_base::redecls_end; 1202ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor using redeclarable_base::getPreviousDecl; 1203ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor using redeclarable_base::getMostRecentDecl; 1204f785a7d611404cf4747287a2bbc59b4d0e6a5a8cDouglas Gregor 120553df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor /// Retrieves the canonical declaration of this Objective-C class. 120653df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor ObjCInterfaceDecl *getCanonicalDecl() { 120753df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor return getFirstDeclaration(); 120853df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor } 120953df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor const ObjCInterfaceDecl *getCanonicalDecl() const { 121053df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor return getFirstDeclaration(); 121153df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor } 121253df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor 121333feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff // Low-level accessor 1214f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const Type *getTypeForDecl() const { return TypeForDecl; } 1215f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall void setTypeForDecl(const Type *TD) const { TypeForDecl = TD; } 121633feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff 121780cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 121880cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCInterface; } 121953b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek 1220fc529f7fcafe7da0b8a32621e13685891e8ce52aDouglas Gregor friend class ASTReader; 122153b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek friend class ASTDeclReader; 122253b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek friend class ASTDeclWriter; 1223980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 1224980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 1225a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCIvarDecl - Represents an ObjC instance variable. In general, ObjC 12260c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// instance variables are identical to C. The only exception is Objective-C 12270c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// supports C++ style access control. For example: 12280c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 122941c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@interface IvarExample : NSObject 12300c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// { 1231f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek/// id defaultToProtected; 123241c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@public: 12330c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id canBePublic; // same as C++. 123441c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@protected: 12350c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id canBeProtected; // same as C++. 123641c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@package: 12370c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id canBePackage; // framework visibility (not available in C++). 12380c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// } 12390c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 1240a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCIvarDecl : public FieldDecl { 124199ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie virtual void anchor(); 124299ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie 12430e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattnerpublic: 1244980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff enum AccessControl { 1245980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff None, Private, Protected, Public, Package 1246980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff }; 12471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1248b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenekprivate: 1249ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara ObjCIvarDecl(ObjCContainerDecl *DC, SourceLocation StartLoc, 1250ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara SourceLocation IdLoc, IdentifierInfo *Id, 1251ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW, 1252ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian bool synthesized) 1253ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara : FieldDecl(ObjCIvar, DC, StartLoc, IdLoc, Id, T, TInfo, BW, 1254ca5233044ef679840d1ad1c46a36b16e2ee8a6e1Richard Smith /*Mutable=*/false, /*HasInit=*/ICIS_NoInit), 1255ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara NextIvar(0), DeclAccess(ac), Synthesized(synthesized) {} 12561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1257b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenekpublic: 1258a06549226f45d5b72169a3d054415616dd1014a2Daniel Dunbar static ObjCIvarDecl *Create(ASTContext &C, ObjCContainerDecl *DC, 1259ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara SourceLocation StartLoc, SourceLocation IdLoc, 1260ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara IdentifierInfo *Id, QualType T, 1261a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall TypeSourceInfo *TInfo, 1262ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian AccessControl ac, Expr *BW = NULL, 1263ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian bool synthesized=false); 12641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12651e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor static ObjCIvarDecl *CreateDeserialized(ASTContext &C, unsigned ID); 12661e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor 126727a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar /// \brief Return the class interface that this ivar is logically contained 126827a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar /// in; this is either the interface where the ivar was declared, or the 126927a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar /// interface the ivar is conceptually a part of in the case of synthesized 127027a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar /// ivars. 127127a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar const ObjCInterfaceDecl *getContainingInterface() const; 1272ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 12732c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian ObjCIvarDecl *getNextIvar() { return NextIvar; } 1274db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose const ObjCIvarDecl *getNextIvar() const { return NextIvar; } 12752c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian void setNextIvar(ObjCIvarDecl *ivar) { NextIvar = ivar; } 127627a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar 1277980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff void setAccessControl(AccessControl ac) { DeclAccess = ac; } 1278f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek 1279ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek AccessControl getAccessControl() const { return AccessControl(DeclAccess); } 1280f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek 1281f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek AccessControl getCanonicalAccessControl() const { 1282f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek return DeclAccess == None ? Protected : AccessControl(DeclAccess); 1283f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek } 12841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1285ac0021ba802e193e0f9f8207768c7862c7603bc0Fariborz Jahanian void setSynthesize(bool synth) { Synthesized = synth; } 1286ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian bool getSynthesize() const { return Synthesized; } 1287ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1288980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff // Implement isa/cast/dyncast/etc. 128980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 129080cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCIvar; } 1291980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffprivate: 1292ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// NextIvar - Next Ivar in the list of ivars declared in class; class's 12932c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian /// extensions and class's implementation 12942c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian ObjCIvarDecl *NextIvar; 1295ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1296ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek // NOTE: VC++ treats enums as signed, avoid using the AccessControl enum 1297ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek unsigned DeclAccess : 3; 1298ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian unsigned Synthesized : 1; 1299980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 1300980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 13011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13020982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \brief Represents a field declaration created by an \@defs(...). 130301e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenekclass ObjCAtDefsFieldDecl : public FieldDecl { 130499ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie virtual void anchor(); 1305ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara ObjCAtDefsFieldDecl(DeclContext *DC, SourceLocation StartLoc, 1306ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara SourceLocation IdLoc, IdentifierInfo *Id, 130701e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek QualType T, Expr *BW) 1308ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara : FieldDecl(ObjCAtDefsField, DC, StartLoc, IdLoc, Id, T, 1309a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall /*TInfo=*/0, // FIXME: Do ObjCAtDefs have declarators ? 1310ca5233044ef679840d1ad1c46a36b16e2ee8a6e1Richard Smith BW, /*Mutable=*/false, /*HasInit=*/ICIS_NoInit) {} 13111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 131201e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenekpublic: 131344b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor static ObjCAtDefsFieldDecl *Create(ASTContext &C, DeclContext *DC, 1314ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara SourceLocation StartLoc, 1315ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara SourceLocation IdLoc, IdentifierInfo *Id, 1316ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara QualType T, Expr *BW); 13171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13181e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor static ObjCAtDefsFieldDecl *CreateDeserialized(ASTContext &C, unsigned ID); 13191e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor 132001e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek // Implement isa/cast/dyncast/etc. 132180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 132280cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCAtDefsField; } 132301e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek}; 1324980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 13250982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \brief Represents an Objective-C protocol declaration. 13260982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// 13270982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// Objective-C protocols declare a pure abstract type (i.e., no instance 13280982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// variables are permitted). Protocols originally drew inspiration from 13290982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// C++ pure virtual functions (a C++ feature with nice semantics and lousy 13300982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// syntax:-). Here is an example: 13310c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 13320982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \code 133341c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@protocol NSDraggingInfo <refproto1, refproto2> 13340c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSWindow *)draggingDestinationWindow; 13350c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSImage *)draggedImage; 133641c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@end 13370982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \endcode 13380c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 1339eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// This says that NSDraggingInfo requires two methods and requires everything 1340eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// that the two "referenced protocols" 'refproto1' and 'refproto2' require as 1341eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// well. 1342eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// 13430982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \code 13440982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \@interface ImplementsNSDraggingInfo : NSObject \<NSDraggingInfo> 134541c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@end 13460982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \endcode 13470c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 1348a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjC protocols inspired Java interfaces. Unlike Java, ObjC classes and 13490c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// protocols are in distinct namespaces. For example, Cocoa defines both 13501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// an NSObject protocol and class (which isn't allowed in Java). As a result, 13510c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// protocols are referenced using angle brackets as follows: 13520c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 13530982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// id \<NSDraggingInfo> anyObjectThatImplementsNSDraggingInfo; 13540c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 13551d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregorclass ObjCProtocolDecl : public ObjCContainerDecl, 13561d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor public Redeclarable<ObjCProtocolDecl> { 135799ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie virtual void anchor(); 135899ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie 13595e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor struct DefinitionData { 13601d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor // \brief The declaration that defines this protocol. 13611d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor ObjCProtocolDecl *Definition; 13621d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor 1363ec1a58b201b3276966aaade8ac3ac4705aba96c2Douglas Gregor /// \brief Referenced protocols 13645e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor ObjCProtocolList ReferencedProtocols; 13655e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor }; 13666bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor 13676bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor /// \brief Contains a pointer to the data associated with this class, 13686bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor /// which will be NULL if this class has not yet been defined. 13696bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor /// 13706bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor /// The bit indicates when we don't need to check for out-of-date 13716bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor /// declarations. It will be set unless modules are enabled. 13726bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor llvm::PointerIntPair<DefinitionData *, 1, bool> Data; 13731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13745e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor DefinitionData &data() const { 13756bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor assert(Data.getPointer() && "Objective-C protocol has no definition!"); 13766bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor return *Data.getPointer(); 13775e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor } 13785e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor 13791711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis ObjCProtocolDecl(DeclContext *DC, IdentifierInfo *Id, 1380b05d7b20171bbd2feb14b059f39332cbe1bf1014Argyrios Kyrtzidis SourceLocation nameLoc, SourceLocation atStartLoc, 1381c9d3c7edb513e9b8a6ab65b04133653e71d7a72bDouglas Gregor ObjCProtocolDecl *PrevDecl); 13821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13835e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor void allocateDefinitionData(); 13841d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor 13851d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor typedef Redeclarable<ObjCProtocolDecl> redeclarable_base; 13861d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor virtual ObjCProtocolDecl *getNextRedeclaration() { 13871d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor return RedeclLink.getNext(); 13881d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor } 1389ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor virtual ObjCProtocolDecl *getPreviousDeclImpl() { 1390ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor return getPreviousDecl(); 1391ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor } 1392ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor virtual ObjCProtocolDecl *getMostRecentDeclImpl() { 1393ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor return getMostRecentDecl(); 1394ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor } 13956bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor 1396cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattnerpublic: 13971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static ObjCProtocolDecl *Create(ASTContext &C, DeclContext *DC, 13981711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis IdentifierInfo *Id, 13991711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis SourceLocation nameLoc, 1400b05d7b20171bbd2feb14b059f39332cbe1bf1014Argyrios Kyrtzidis SourceLocation atStartLoc, 1401c9d3c7edb513e9b8a6ab65b04133653e71d7a72bDouglas Gregor ObjCProtocolDecl *PrevDecl); 1402cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattner 14031e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor static ObjCProtocolDecl *CreateDeserialized(ASTContext &C, unsigned ID); 14041e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor 140518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const ObjCProtocolList &getReferencedProtocols() const { 14065e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor assert(hasDefinition() && "No definition available!"); 14075e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor return data().ReferencedProtocols; 1408980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff } 140918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor typedef ObjCProtocolList::iterator protocol_iterator; 14105e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor protocol_iterator protocol_begin() const { 14115e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor if (!hasDefinition()) 14125e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor return protocol_iterator(); 14135e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor 14145e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor return data().ReferencedProtocols.begin(); 14155e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor } 14165e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor protocol_iterator protocol_end() const { 14175e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor if (!hasDefinition()) 14185e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor return protocol_iterator(); 14195e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor 14205e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor return data().ReferencedProtocols.end(); 14215e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor } 142218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor typedef ObjCProtocolList::loc_iterator protocol_loc_iterator; 1423ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie protocol_loc_iterator protocol_loc_begin() const { 14245e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor if (!hasDefinition()) 14255e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor return protocol_loc_iterator(); 14265e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor 14275e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor return data().ReferencedProtocols.loc_begin(); 142818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor } 1429ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie protocol_loc_iterator protocol_loc_end() const { 14305e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor if (!hasDefinition()) 14315e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor return protocol_loc_iterator(); 14325e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor 14335e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor return data().ReferencedProtocols.loc_end(); 14345e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor } 14355e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor unsigned protocol_size() const { 14365e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor if (!hasDefinition()) 14375e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor return 0; 14385e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor 14395e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor return data().ReferencedProtocols.size(); 144018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor } 14411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 144238af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner /// setProtocolList - Set the list of protocols that this interface 1443780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner /// implements. 144438af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num, 144518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const SourceLocation *Locs, ASTContext &C) { 14466bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor assert(hasDefinition() && "Protocol is not defined"); 14475e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor data().ReferencedProtocols.set(List, Num, Locs, C); 1448aebf0cba02c014ac8b19d615c654248e0e93779fFariborz Jahanian } 14491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 145091b0b0cf6b537cbcbca0038c7032f87161a41d31Steve Naroff ObjCProtocolDecl *lookupProtocolNamed(IdentifierInfo *PName); 14511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 145294a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff // Lookup a method. First, we search locally. If a method isn't 145394a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff // found, we search referenced protocols and class categories. 1454094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance) const; 1455094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis ObjCMethodDecl *lookupInstanceMethod(Selector Sel) const { 1456094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis return lookupMethod(Sel, true/*isInstance*/); 1457094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis } 1458094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis ObjCMethodDecl *lookupClassMethod(Selector Sel) const { 1459094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis return lookupMethod(Sel, false/*isInstance*/); 1460094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis } 1461b05d7b20171bbd2feb14b059f39332cbe1bf1014Argyrios Kyrtzidis 14625e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor /// \brief Determine whether this protocol has a definition. 14636bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor bool hasDefinition() const { 14646bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor // If the name of this protocol is out-of-date, bring it up-to-date, which 14656bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor // might bring in a definition. 14666bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor // Note: a null value indicates that we don't have a definition and that 14676bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor // modules are enabled. 14686bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor if (!Data.getOpaqueValue()) { 14696bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor if (IdentifierInfo *II = getIdentifier()) { 14706bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor if (II->isOutOfDate()) { 14716bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor updateOutOfDate(*II); 14726bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor } 14736bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor } 14746bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor } 14756bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor 14766bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor return Data.getPointer(); 14776bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor } 14785e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor 14795e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor /// \brief Retrieve the definition of this protocol, if any. 14805e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor ObjCProtocolDecl *getDefinition() { 14816bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor return hasDefinition()? Data.getPointer()->Definition : 0; 14825e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor } 14835e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor 14845e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor /// \brief Retrieve the definition of this protocol, if any. 14855e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor const ObjCProtocolDecl *getDefinition() const { 14866bd992946bda92193fadce7e4890d4465d2702f4Douglas Gregor return hasDefinition()? Data.getPointer()->Definition : 0; 14875e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor } 14885e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor 14895e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor /// \brief Determine whether this particular declaration is also the 14905e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor /// definition. 14915e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor bool isThisDeclarationADefinition() const { 14925e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor return getDefinition() == this; 14935e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor } 14945e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor 14955e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor /// \brief Starts the definition of this Objective-C protocol. 14965e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor void startDefinition(); 14975e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor 1498aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar virtual SourceRange getSourceRange() const LLVM_READONLY { 1499ec1a58b201b3276966aaade8ac3ac4705aba96c2Douglas Gregor if (isThisDeclarationADefinition()) 1500ec1a58b201b3276966aaade8ac3ac4705aba96c2Douglas Gregor return ObjCContainerDecl::getSourceRange(); 1501ec1a58b201b3276966aaade8ac3ac4705aba96c2Douglas Gregor 1502ec1a58b201b3276966aaade8ac3ac4705aba96c2Douglas Gregor return SourceRange(getAtStartLoc(), getLocation()); 1503ec1a58b201b3276966aaade8ac3ac4705aba96c2Douglas Gregor } 1504f785a7d611404cf4747287a2bbc59b4d0e6a5a8cDouglas Gregor 1505a54fbf2499c7cc999e22abb9be484ce976ed9689Douglas Gregor typedef redeclarable_base::redecl_iterator redecl_iterator; 1506ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor using redeclarable_base::redecls_begin; 1507ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor using redeclarable_base::redecls_end; 1508ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor using redeclarable_base::getPreviousDecl; 1509ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor using redeclarable_base::getMostRecentDecl; 1510f785a7d611404cf4747287a2bbc59b4d0e6a5a8cDouglas Gregor 15113fc73ee0c613715ebce78e30b4d050ea715a007dDouglas Gregor /// Retrieves the canonical declaration of this Objective-C protocol. 15123fc73ee0c613715ebce78e30b4d050ea715a007dDouglas Gregor ObjCProtocolDecl *getCanonicalDecl() { 15131d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor return getFirstDeclaration(); 15143fc73ee0c613715ebce78e30b4d050ea715a007dDouglas Gregor } 15153fc73ee0c613715ebce78e30b4d050ea715a007dDouglas Gregor const ObjCProtocolDecl *getCanonicalDecl() const { 15161d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor return getFirstDeclaration(); 15173fc73ee0c613715ebce78e30b4d050ea715a007dDouglas Gregor } 15183fc73ee0c613715ebce78e30b4d050ea715a007dDouglas Gregor 1519cfaed8d399a34e79fbab9f70eb4ea1bbeb81a02bFariborz Jahanian virtual void collectPropertiesToImplement(PropertyMap &PM, 1520cfaed8d399a34e79fbab9f70eb4ea1bbeb81a02bFariborz Jahanian PropertyDeclOrder &PO) const; 15218dbda516d343706bae904f800c6d64e145d58a8cFariborz Jahanian 15228dbda516d343706bae904f800c6d64e145d58a8cFariborz Jahanianvoid collectInheritedProtocolProperties(const ObjCPropertyDecl *Property, 15238dbda516d343706bae904f800c6d64e145d58a8cFariborz Jahanian ProtocolPropertyMap &PM) const; 1524b36ea375e20f71df19c101fa2399b7ea3a607e04Anna Zaks 152580cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 152680cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCProtocol; } 1527b05d7b20171bbd2feb14b059f39332cbe1bf1014Argyrios Kyrtzidis 15285e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor friend class ASTReader; 1529b05d7b20171bbd2feb14b059f39332cbe1bf1014Argyrios Kyrtzidis friend class ASTDeclReader; 1530b05d7b20171bbd2feb14b059f39332cbe1bf1014Argyrios Kyrtzidis friend class ASTDeclWriter; 1531980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 15321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1533a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCCategoryDecl - Represents a category declaration. A category allows 15340c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// you to add methods to an existing class (without subclassing or modifying 15351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// the original class interface or implementation:-). Categories don't allow 15360c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// you to add instance data. The following example adds "myMethod" to all 15370c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// NSView's within a process: 15380c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 153941c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@interface NSView (MyViewMethods) 15400c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - myMethod; 154141c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@end 15420c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 154333ced0b8550f3e7169f326944731ee02e9338659Douglas Gregor/// Categories also allow you to split the implementation of a class across 15440c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// several files (a feature more naturally supported in C++). 15450c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 15460c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Categories were originally inspired by dynamic languages such as Common 15471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// Lisp and Smalltalk. More traditional class-based languages (C++, Java) 15480c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// don't support this level of dynamism, which is both powerful and dangerous. 15490c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 1550e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroffclass ObjCCategoryDecl : public ObjCContainerDecl { 155199ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie virtual void anchor(); 155299ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie 1553980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff /// Interface belonging to this category 1554a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *ClassInterface; 15551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 155668c82cf61228102aba1194efef222fa1478af2a8Chris Lattner /// referenced protocols in this category. 155718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor ObjCProtocolList ReferencedProtocols; 15581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1559a8ff9f455d94d9609766cfd5186b6e21dc2102f1Chris Lattner /// Next category belonging to this class. 1560a8ff9f455d94d9609766cfd5186b6e21dc2102f1Chris Lattner /// FIXME: this should not be a singly-linked list. Move storage elsewhere. 1561a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCCategoryDecl *NextClassCategory; 15621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15633db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor /// \brief The location of the category name in this declaration. 15643db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor SourceLocation CategoryNameLoc; 15651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1566af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian /// class extension may have private ivars. 1567af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation IvarLBraceLoc; 1568af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation IvarRBraceLoc; 1569af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian 1570ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie ObjCCategoryDecl(DeclContext *DC, SourceLocation AtLoc, 15713db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, 1572af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, 1573af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation IvarLBraceLoc=SourceLocation(), 1574af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation IvarRBraceLoc=SourceLocation()) 15751711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis : ObjCContainerDecl(ObjCCategory, DC, Id, ClassNameLoc, AtLoc), 1576ffb0c3adc27d257c8453886957b8d220d1ad14d8Eric Christopher ClassInterface(IDecl), NextClassCategory(0), 1577af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian CategoryNameLoc(CategoryNameLoc), 1578af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian IvarLBraceLoc(IvarLBraceLoc), IvarRBraceLoc(IvarRBraceLoc) { 1579a906135721c350435319347d2672bbb3bf494f91Chris Lattner } 1580d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 158161f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattnerpublic: 15821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1583d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCCategoryDecl *Create(ASTContext &C, DeclContext *DC, 1584ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie SourceLocation AtLoc, 15853db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor SourceLocation ClassNameLoc, 15863db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor SourceLocation CategoryNameLoc, 1587955fadbdfecfa24a590febe66a86519096787f2dArgyrios Kyrtzidis IdentifierInfo *Id, 1588af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian ObjCInterfaceDecl *IDecl, 1589af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation IvarLBraceLoc=SourceLocation(), 1590af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation IvarRBraceLoc=SourceLocation()); 15911e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor static ObjCCategoryDecl *CreateDeserialized(ASTContext &C, unsigned ID); 15921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1593e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner ObjCInterfaceDecl *getClassInterface() { return ClassInterface; } 1594e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } 15958a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis 15968a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis ObjCCategoryImplDecl *getImplementation() const; 15978a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis void setImplementation(ObjCCategoryImplDecl *ImplD); 15988a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis 159938af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner /// setProtocolList - Set the list of protocols that this interface 1600f7b2c98c16dfb2261ea57d40a1d5bc4738e73175Chris Lattner /// implements. 160138af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num, 160218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const SourceLocation *Locs, ASTContext &C) { 160318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor ReferencedProtocols.set(List, Num, Locs, C); 1604780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner } 16051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 160618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor const ObjCProtocolList &getReferencedProtocols() const { 1607780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner return ReferencedProtocols; 16088f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian } 16091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 161018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor typedef ObjCProtocolList::iterator protocol_iterator; 1611780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();} 1612780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner protocol_iterator protocol_end() const { return ReferencedProtocols.end(); } 161330833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff unsigned protocol_size() const { return ReferencedProtocols.size(); } 161418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor typedef ObjCProtocolList::loc_iterator protocol_loc_iterator; 1615ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie protocol_loc_iterator protocol_loc_begin() const { 1616ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return ReferencedProtocols.loc_begin(); 161718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor } 1618ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie protocol_loc_iterator protocol_loc_end() const { 1619ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return ReferencedProtocols.loc_end(); 162018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor } 16211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1622a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCCategoryDecl *getNextClassCategory() const { return NextClassCategory; } 16233db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor 1624d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// \brief Retrieve the pointer to the next stored category (or extension), 1625d329724745b49f894b768d47275b7c2713106e89Douglas Gregor /// which may be hidden. 1626d329724745b49f894b768d47275b7c2713106e89Douglas Gregor ObjCCategoryDecl *getNextClassCategoryRaw() const { 1627d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return NextClassCategory; 1628d329724745b49f894b768d47275b7c2713106e89Douglas Gregor } 1629d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 163025760611365be23556b32332f8a66ae21ea93ecfFariborz Jahanian bool IsClassExtension() const { return getIdentifier() == 0; } 1631ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 16320e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator; 16330e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian ivar_iterator ivar_begin() const { 16340e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian return ivar_iterator(decls_begin()); 16350e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian } 16360e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian ivar_iterator ivar_end() const { 16370e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian return ivar_iterator(decls_end()); 16380e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian } 16390e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian unsigned ivar_size() const { 16400e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian return std::distance(ivar_begin(), ivar_end()); 16410e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian } 16420e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian bool ivar_empty() const { 16430e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian return ivar_begin() == ivar_end(); 16440e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian } 16453db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor 16463db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; } 16473db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor void setCategoryNameLoc(SourceLocation Loc) { CategoryNameLoc = Loc; } 1648af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian 1649af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian void setIvarLBraceLoc(SourceLocation Loc) { IvarLBraceLoc = Loc; } 1650af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation getIvarLBraceLoc() const { return IvarLBraceLoc; } 1651af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian void setIvarRBraceLoc(SourceLocation Loc) { IvarRBraceLoc = Loc; } 1652af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation getIvarRBraceLoc() const { return IvarRBraceLoc; } 16533db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor 165480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 165580cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCCategory; } 1656955fadbdfecfa24a590febe66a86519096787f2dArgyrios Kyrtzidis 1657955fadbdfecfa24a590febe66a86519096787f2dArgyrios Kyrtzidis friend class ASTDeclReader; 1658955fadbdfecfa24a590febe66a86519096787f2dArgyrios Kyrtzidis friend class ASTDeclWriter; 1659980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 16600c6b6243d3efd958c17943130e2a773653511edcSteve Naroff 1661aecae629269fae3bf484baf1d109e9a89d14eeadArgyrios Kyrtzidisclass ObjCImplDecl : public ObjCContainerDecl { 166299ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie virtual void anchor(); 166399ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie 16640d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff /// Class interface for this class/category implementation 1665a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *ClassInterface; 16661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16673aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattnerprotected: 16681711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis ObjCImplDecl(Kind DK, DeclContext *DC, 16691711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis ObjCInterfaceDecl *classInterface, 16701711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis SourceLocation nameLoc, SourceLocation atStartLoc) 16711711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis : ObjCContainerDecl(DK, DC, 16721711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis classInterface? classInterface->getIdentifier() : 0, 16731711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis nameLoc, atStartLoc), 1674aecae629269fae3bf484baf1d109e9a89d14eeadArgyrios Kyrtzidis ClassInterface(classInterface) {} 16751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 167675c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattnerpublic: 1677e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } 1678e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner ObjCInterfaceDecl *getClassInterface() { return ClassInterface; } 16798a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis void setClassInterface(ObjCInterfaceDecl *IFace); 16802c2d43c557beca1b4ba4bd743f33978aecb46a97Douglas Gregor 16811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void addInstanceMethod(ObjCMethodDecl *method) { 16822c2d43c557beca1b4ba4bd743f33978aecb46a97Douglas Gregor // FIXME: Context should be set correctly before we get here. 1683653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor method->setLexicalDeclContext(this); 16841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump addDecl(method); 1685e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff } 16861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void addClassMethod(ObjCMethodDecl *method) { 16872c2d43c557beca1b4ba4bd743f33978aecb46a97Douglas Gregor // FIXME: Context should be set correctly before we get here. 1688653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor method->setLexicalDeclContext(this); 16891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump addDecl(method); 169053df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner } 16911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 169217945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis void addPropertyImplementation(ObjCPropertyImplDecl *property); 16931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 169417945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis ObjCPropertyImplDecl *FindPropertyImplDecl(IdentifierInfo *propertyId) const; 169517945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis ObjCPropertyImplDecl *FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const; 1696653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor 1697653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor // Iterator access to properties. 1698653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor typedef specific_decl_iterator<ObjCPropertyImplDecl> propimpl_iterator; 16991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump propimpl_iterator propimpl_begin() const { 170017945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return propimpl_iterator(decls_begin()); 1701559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian } 17021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump propimpl_iterator propimpl_end() const { 170317945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return propimpl_iterator(decls_end()); 1704559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian } 1705653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor 170680cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 170780cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { 17089a55591af3e5506b95a9718e15380129fbfc5ebcSean Hunt return K >= firstObjCImpl && K <= lastObjCImpl; 170980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall } 17103aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner}; 17111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 17121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// ObjCCategoryImplDecl - An object of this class encapsulates a category 171341c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@implementation declaration. If a category class has declaration of a 17141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// property, its implementation must be specified in the category's 171541c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@implementation declaration. Example: 171641c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@interface I \@end 171741c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@interface I(CATEGORY) 171841c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@property int p1, d1; 171941c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@end 172041c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@implementation I(CATEGORY) 172141c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@dynamic p1,d1; 172241c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@end 17233aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// 17243aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// ObjCCategoryImplDecl 17253aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattnerclass ObjCCategoryImplDecl : public ObjCImplDecl { 172699ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie virtual void anchor(); 172799ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie 17283aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner // Category name 17293aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner IdentifierInfo *Id; 17303aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner 1731c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis // Category name location 1732c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis SourceLocation CategoryNameLoc; 1733c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis 17341711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis ObjCCategoryImplDecl(DeclContext *DC, IdentifierInfo *Id, 17351711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis ObjCInterfaceDecl *classInterface, 1736c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis SourceLocation nameLoc, SourceLocation atStartLoc, 1737c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis SourceLocation CategoryNameLoc) 17381711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis : ObjCImplDecl(ObjCCategoryImpl, DC, classInterface, nameLoc, atStartLoc), 1739c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis Id(Id), CategoryNameLoc(CategoryNameLoc) {} 17403aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattnerpublic: 17413aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner static ObjCCategoryImplDecl *Create(ASTContext &C, DeclContext *DC, 17421711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis IdentifierInfo *Id, 17431711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis ObjCInterfaceDecl *classInterface, 17441711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis SourceLocation nameLoc, 1745c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis SourceLocation atStartLoc, 1746c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis SourceLocation CategoryNameLoc); 17471e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor static ObjCCategoryImplDecl *CreateDeserialized(ASTContext &C, unsigned ID); 17481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 17490d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff /// getIdentifier - Get the identifier that names the category 17503aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner /// interface associated with this implementation. 17510d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff /// FIXME: This is a bad API, we are overriding the NamedDecl::getIdentifier() 17520d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff /// to mean something different. For example: 1753ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// ((NamedDecl *)SomeCategoryImplDecl)->getIdentifier() 1754ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// returns the class interface name, whereas 1755ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// ((ObjCCategoryImplDecl *)SomeCategoryImplDecl)->getIdentifier() 17560d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff /// returns the category name. 17571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump IdentifierInfo *getIdentifier() const { 17581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return Id; 17593aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner } 176010b0e1fa3aabd8877dbbc0df1f2414e04afd5fddDouglas Gregor void setIdentifier(IdentifierInfo *II) { Id = II; } 17611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 17620d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff ObjCCategoryDecl *getCategoryDecl() const; 176310b0e1fa3aabd8877dbbc0df1f2414e04afd5fddDouglas Gregor 1764c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; } 1765c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis 1766b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar /// getName - Get the name of identifier for the class interface associated 1767b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar /// with this implementation as a StringRef. 1768b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar // 1769b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar // FIXME: This is a bad API, we are overriding the NamedDecl::getName, to mean 1770b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar // something different. 1771686775deca8b8685eb90801495880e3abdd844c2Chris Lattner StringRef getName() const { 1772b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar return Id ? Id->getNameStart() : ""; 1773b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar } 1774b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar 17753aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner /// @brief Get the name of the class associated with this interface. 17767fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar // 1777b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar // FIXME: Deprecated, move clients to getName(). 17783aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner std::string getNameAsString() const { 1779b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar return getName(); 17803aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner } 17811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 178280cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 178380cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCCategoryImpl;} 1784c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis 1785c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis friend class ASTDeclReader; 1786c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis friend class ASTDeclWriter; 17878f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian}; 17888f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian 1789f978059b82db8c0d849c5f992036210b5ca53200Benjamin Kramerraw_ostream &operator<<(raw_ostream &OS, const ObjCCategoryImplDecl &CID); 1790900fc6388e803868a34b9483510c345e9b49d7ebBenjamin Kramer 1791a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCImplementationDecl - Represents a class definition - this is where 17920c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// method definitions are specified. For example: 17930c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 179498abf4bd3526a00a0e5cf71a9462c181f97b1c81Fariborz Jahanian/// @code 179541c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@implementation MyClass 17960c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (void)myMethod { /* do something */ } 179741c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@end 179898abf4bd3526a00a0e5cf71a9462c181f97b1c81Fariborz Jahanian/// @endcode 17990c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 18001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// Typically, instance variables are specified in the class interface, 1801ec0d7a6f4b0699cc9960e6d9fee0f957c64d1cf9Douglas Gregor/// *not* in the implementation. Nevertheless (for legacy reasons), we 180253df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner/// allow instance variables to be specified in the implementation. When 180353df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner/// specified, they need to be *identical* to the interface. 18040c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// 18051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumpclass ObjCImplementationDecl : public ObjCImplDecl { 180699ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie virtual void anchor(); 1807980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff /// Implementation Class's super class. 1808a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *SuperClass; 1809634c5634817b9ad384a706fe87ab302985566bbaArgyrios Kyrtzidis SourceLocation SuperLoc; 1810634c5634817b9ad384a706fe87ab302985566bbaArgyrios Kyrtzidis 181141c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// \@implementation may have private ivars. 1812af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation IvarLBraceLoc; 1813af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation IvarRBraceLoc; 1814af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian 1815e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// Support for ivar initialization. 1816e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// IvarInitializers - The arguments used to initialize the ivars 1817cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt CXXCtorInitializer **IvarInitializers; 1818e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian unsigned NumIvarInitializers; 1819f85e193739c953358c865005855253af4f68a497John McCall 1820b03527a9a395168762ad8e25e59a7a272dd74561John McCall /// Do the ivars of this class require initialization other than 1821b03527a9a395168762ad8e25e59a7a272dd74561John McCall /// zero-initialization? 1822b03527a9a395168762ad8e25e59a7a272dd74561John McCall bool HasNonZeroConstructors : 1; 1823b03527a9a395168762ad8e25e59a7a272dd74561John McCall 1824b03527a9a395168762ad8e25e59a7a272dd74561John McCall /// Do the ivars of this class require non-trivial destruction? 1825b03527a9a395168762ad8e25e59a7a272dd74561John McCall bool HasDestructors : 1; 1826ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 18271711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis ObjCImplementationDecl(DeclContext *DC, 1828a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *classInterface, 18291711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis ObjCInterfaceDecl *superDecl, 1830af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation nameLoc, SourceLocation atStartLoc, 1831634c5634817b9ad384a706fe87ab302985566bbaArgyrios Kyrtzidis SourceLocation superLoc = SourceLocation(), 1832af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation IvarLBraceLoc=SourceLocation(), 1833af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation IvarRBraceLoc=SourceLocation()) 18341711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis : ObjCImplDecl(ObjCImplementation, DC, classInterface, nameLoc, atStartLoc), 1835634c5634817b9ad384a706fe87ab302985566bbaArgyrios Kyrtzidis SuperClass(superDecl), SuperLoc(superLoc), IvarLBraceLoc(IvarLBraceLoc), 1836af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian IvarRBraceLoc(IvarRBraceLoc), 1837af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian IvarInitializers(0), NumIvarInitializers(0), 1838b03527a9a395168762ad8e25e59a7a272dd74561John McCall HasNonZeroConstructors(false), HasDestructors(false) {} 18391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumppublic: 18401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static ObjCImplementationDecl *Create(ASTContext &C, DeclContext *DC, 184175c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattner ObjCInterfaceDecl *classInterface, 18421711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis ObjCInterfaceDecl *superDecl, 18431711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis SourceLocation nameLoc, 1844af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation atStartLoc, 1845634c5634817b9ad384a706fe87ab302985566bbaArgyrios Kyrtzidis SourceLocation superLoc = SourceLocation(), 1846af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation IvarLBraceLoc=SourceLocation(), 1847af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation IvarRBraceLoc=SourceLocation()); 1848ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 18491e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor static ObjCImplementationDecl *CreateDeserialized(ASTContext &C, unsigned ID); 18501e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor 1851e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// init_iterator - Iterates through the ivar initializer list. 1852cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt typedef CXXCtorInitializer **init_iterator; 1853ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1854e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// init_const_iterator - Iterates through the ivar initializer list. 1855cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt typedef CXXCtorInitializer * const * init_const_iterator; 1856ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1857e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// init_begin() - Retrieve an iterator to the first initializer. 1858e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian init_iterator init_begin() { return IvarInitializers; } 1859e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// begin() - Retrieve an iterator to the first initializer. 1860e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian init_const_iterator init_begin() const { return IvarInitializers; } 1861ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1862e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// init_end() - Retrieve an iterator past the last initializer. 1863e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian init_iterator init_end() { 1864e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian return IvarInitializers + NumIvarInitializers; 1865e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian } 1866e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// end() - Retrieve an iterator past the last initializer. 1867e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian init_const_iterator init_end() const { 1868e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian return IvarInitializers + NumIvarInitializers; 1869e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian } 1870e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian /// getNumArgs - Number of ivars which must be initialized. 1871e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian unsigned getNumIvarInitializers() const { 1872e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian return NumIvarInitializers; 1873e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian } 1874ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1875e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian void setNumIvarInitializers(unsigned numNumIvarInitializers) { 1876e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian NumIvarInitializers = numNumIvarInitializers; 1877e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian } 1878ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1879e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian void setIvarInitializers(ASTContext &C, 1880cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt CXXCtorInitializer ** initializers, 1881e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian unsigned numInitializers); 1882f85e193739c953358c865005855253af4f68a497John McCall 1883b03527a9a395168762ad8e25e59a7a272dd74561John McCall /// Do any of the ivars of this class (not counting its base classes) 1884b03527a9a395168762ad8e25e59a7a272dd74561John McCall /// require construction other than zero-initialization? 1885b03527a9a395168762ad8e25e59a7a272dd74561John McCall bool hasNonZeroConstructors() const { return HasNonZeroConstructors; } 1886b03527a9a395168762ad8e25e59a7a272dd74561John McCall void setHasNonZeroConstructors(bool val) { HasNonZeroConstructors = val; } 1887b03527a9a395168762ad8e25e59a7a272dd74561John McCall 1888b03527a9a395168762ad8e25e59a7a272dd74561John McCall /// Do any of the ivars of this class (not counting its base classes) 1889b03527a9a395168762ad8e25e59a7a272dd74561John McCall /// require non-trivial destruction? 1890b03527a9a395168762ad8e25e59a7a272dd74561John McCall bool hasDestructors() const { return HasDestructors; } 1891b03527a9a395168762ad8e25e59a7a272dd74561John McCall void setHasDestructors(bool val) { HasDestructors = val; } 1892ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 18934afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// getIdentifier - Get the identifier that names the class 18944afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// interface associated with this implementation. 18951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump IdentifierInfo *getIdentifier() const { 18961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return getClassInterface()->getIdentifier(); 18974afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor } 18984afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor 1899d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar /// getName - Get the name of identifier for the class interface associated 1900d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar /// with this implementation as a StringRef. 1901d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar // 1902d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar // FIXME: This is a bad API, we are overriding the NamedDecl::getName, to mean 1903d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar // something different. 1904686775deca8b8685eb90801495880e3abdd844c2Chris Lattner StringRef getName() const { 1905d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar assert(getIdentifier() && "Name is not a simple identifier"); 1906d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar return getIdentifier()->getName(); 1907d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar } 1908d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar 19094afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor /// @brief Get the name of the class associated with this interface. 19107fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar // 19117fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar // FIXME: Move to StringRef API. 19124afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor std::string getNameAsString() const { 1913d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar return getName(); 19144afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor } 19154afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor 1916e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner const ObjCInterfaceDecl *getSuperClass() const { return SuperClass; } 1917e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner ObjCInterfaceDecl *getSuperClass() { return SuperClass; } 19182f729009067e6aff6198719ec9f8220d88cfea09Argyrios Kyrtzidis SourceLocation getSuperClassLoc() const { return SuperLoc; } 19191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1920f3a7af901231535191d14cb524d58f22907ac4d2Chris Lattner void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; } 19211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1922af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian void setIvarLBraceLoc(SourceLocation Loc) { IvarLBraceLoc = Loc; } 1923af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation getIvarLBraceLoc() const { return IvarLBraceLoc; } 1924af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian void setIvarRBraceLoc(SourceLocation Loc) { IvarRBraceLoc = Loc; } 1925af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian SourceLocation getIvarRBraceLoc() const { return IvarRBraceLoc; } 1926af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian 19278f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator; 19281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ivar_iterator ivar_begin() const { 19291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return ivar_iterator(decls_begin()); 19308f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor } 19311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ivar_iterator ivar_end() const { 193217945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return ivar_iterator(decls_end()); 19338f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor } 19341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump unsigned ivar_size() const { 193517945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return std::distance(ivar_begin(), ivar_end()); 19368f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor } 19371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump bool ivar_empty() const { 193817945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis return ivar_begin() == ivar_end(); 19398f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor } 19401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 194180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 194280cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCImplementation; } 19439d50c0635fb213b2a1857e3f8488580f0dab2f98Argyrios Kyrtzidis 1944d527cc06d78fe5afa5f20105b51697637eb02c56Sebastian Redl friend class ASTDeclReader; 19453397c5570369f19b2d6c52e898f708d75ceede1fSebastian Redl friend class ASTDeclWriter; 1946980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}; 1947243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian 1948f978059b82db8c0d849c5f992036210b5ca53200Benjamin Kramerraw_ostream &operator<<(raw_ostream &OS, const ObjCImplementationDecl &ID); 1949900fc6388e803868a34b9483510c345e9b49d7ebBenjamin Kramer 19501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is 195141c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// declared as \@compatibility_alias alias class. 19524afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCCompatibleAliasDecl : public NamedDecl { 195399ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie virtual void anchor(); 1954243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian /// Class that this is an alias of. 1955a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *AliasedClass; 19561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1957d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor ObjCCompatibleAliasDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, 1958e8043c39176e7f253fbd92982b077eca6bf2fd59Steve Naroff ObjCInterfaceDecl* aliasedClass) 19594afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor : NamedDecl(ObjCCompatibleAlias, DC, L, Id), AliasedClass(aliasedClass) {} 1960f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattnerpublic: 1961d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCCompatibleAliasDecl *Create(ASTContext &C, DeclContext *DC, 19620ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner SourceLocation L, IdentifierInfo *Id, 1963f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner ObjCInterfaceDecl* aliasedClass); 1964f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner 19651e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor static ObjCCompatibleAliasDecl *CreateDeserialized(ASTContext &C, 19661e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor unsigned ID); 19671e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor 1968f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner const ObjCInterfaceDecl *getClassInterface() const { return AliasedClass; } 1969f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner ObjCInterfaceDecl *getClassInterface() { return AliasedClass; } 197030833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff void setClassInterface(ObjCInterfaceDecl *D) { AliasedClass = D; } 19711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 197280cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 197380cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCCompatibleAlias; } 19741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1975243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian}; 19761de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian 19770982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \brief Represents one property declaration in an Objective-C interface. 19780982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// 19791de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian/// For example: 19800982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \code{.mm} 198141c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@property (assign, readwrite) int MyProperty; 19820982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \endcode 19834afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCPropertyDecl : public NamedDecl { 198499ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie virtual void anchor(); 198582a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanianpublic: 1986a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner enum PropertyAttributeKind { 19871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump OBJC_PR_noattr = 0x00, 19881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump OBJC_PR_readonly = 0x01, 1989a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner OBJC_PR_getter = 0x02, 19901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump OBJC_PR_assign = 0x04, 19911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump OBJC_PR_readwrite = 0x08, 1992a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner OBJC_PR_retain = 0x10, 19931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump OBJC_PR_copy = 0x20, 1994a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner OBJC_PR_nonatomic = 0x40, 199545937ae10a0f70f74508165aab4f2b63e18ea747Fariborz Jahanian OBJC_PR_setter = 0x80, 1996f85e193739c953358c865005855253af4f68a497John McCall OBJC_PR_atomic = 0x100, 1997f85e193739c953358c865005855253af4f68a497John McCall OBJC_PR_weak = 0x200, 1998f85e193739c953358c865005855253af4f68a497John McCall OBJC_PR_strong = 0x400, 19999f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis OBJC_PR_unsafe_unretained = 0x800 20009f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis // Adding a property should change NumPropertyAttrsBits 20019f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis }; 20020a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis 20039f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis enum { 20040a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis /// \brief Number of bits fitting all the property attributes. 20059f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis NumPropertyAttrsBits = 12 2006a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner }; 2007af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar 20083a02b44e3948f7762dbfba94b7961281ca29d022Fariborz Jahanian enum SetterKind { Assign, Retain, Copy, Weak }; 200946b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian enum PropertyControl { None, Required, Optional }; 201082a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanianprivate: 201141c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth SourceLocation AtLoc; // location of \@property 201277bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian SourceLocation LParenLoc; // location of '(' starting attribute list or null. 201383a230c83a54190366138c1a4f4310ef838b88fcJohn McCall TypeSourceInfo *DeclType; 20149f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis unsigned PropertyAttributes : NumPropertyAttrsBits; 20159f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis unsigned PropertyAttributesAsWritten : NumPropertyAttrsBits; 201641c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth // \@required/\@optional 201746b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian unsigned PropertyImplementation : 2; 20181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 20195251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian Selector GetterName; // getter name of NULL if no getter 20205251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian Selector SetterName; // setter name of NULL if no setter 20211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 202233de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian ObjCMethodDecl *GetterMethodDecl; // Declaration of getter instance method 202333de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian ObjCMethodDecl *SetterMethodDecl; // Declaration of setter instance method 2024af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian ObjCIvarDecl *PropertyIvarDecl; // Synthesize ivar for this property 202533de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian 20261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, 202777bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian SourceLocation AtLocation, SourceLocation LParenLocation, 202877bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian TypeSourceInfo *T) 202977bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian : NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation), 203077bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian LParenLoc(LParenLocation), DeclType(T), 2031ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie PropertyAttributes(OBJC_PR_noattr), 203280aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian PropertyAttributesAsWritten(OBJC_PR_noattr), 203380aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian PropertyImplementation(None), 20341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump GetterName(Selector()), 203533de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian SetterName(Selector()), 2036af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian GetterMethodDecl(0), SetterMethodDecl(0) , PropertyIvarDecl(0) {} 2037f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattnerpublic: 20381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC, 20391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation L, 2040d0502407c1b41b2ace326f355d7b7a6876246223Fariborz Jahanian IdentifierInfo *Id, SourceLocation AtLocation, 204177bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian SourceLocation LParenLocation, 204283a230c83a54190366138c1a4f4310ef838b88fcJohn McCall TypeSourceInfo *T, 204346b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian PropertyControl propControl = None); 20441e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor 20451e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor static ObjCPropertyDecl *CreateDeserialized(ASTContext &C, unsigned ID); 20461e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor 2047d0502407c1b41b2ace326f355d7b7a6876246223Fariborz Jahanian SourceLocation getAtLoc() const { return AtLoc; } 2048d0502407c1b41b2ace326f355d7b7a6876246223Fariborz Jahanian void setAtLoc(SourceLocation L) { AtLoc = L; } 204977bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian 205077bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian SourceLocation getLParenLoc() const { return LParenLoc; } 205177bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian void setLParenLoc(SourceLocation L) { LParenLoc = L; } 2052ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 205383a230c83a54190366138c1a4f4310ef838b88fcJohn McCall TypeSourceInfo *getTypeSourceInfo() const { return DeclType; } 205483a230c83a54190366138c1a4f4310ef838b88fcJohn McCall QualType getType() const { return DeclType->getType(); } 205583a230c83a54190366138c1a4f4310ef838b88fcJohn McCall void setType(TypeSourceInfo *T) { DeclType = T; } 205670e5a14c6076d63833c62d1d6d628c26309897c1Douglas Gregor 2057a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner PropertyAttributeKind getPropertyAttributes() const { 2058f4af5154571e0c5eadb19df10e65464766ef6683Chris Lattner return PropertyAttributeKind(PropertyAttributes); 2059f4af5154571e0c5eadb19df10e65464766ef6683Chris Lattner } 20601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void setPropertyAttributes(PropertyAttributeKind PRVal) { 2061a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner PropertyAttributes |= PRVal; 206282a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian } 2063394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar 206480aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian PropertyAttributeKind getPropertyAttributesAsWritten() const { 206580aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian return PropertyAttributeKind(PropertyAttributesAsWritten); 206680aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian } 20670a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis 20680a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis bool hasWrittenStorageAttribute() const { 20690a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis return PropertyAttributesAsWritten & (OBJC_PR_assign | OBJC_PR_copy | 20700a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis OBJC_PR_unsafe_unretained | OBJC_PR_retain | OBJC_PR_strong | 20710a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis OBJC_PR_weak); 20720a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis } 2073ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 207480aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal) { 207580aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian PropertyAttributesAsWritten = PRVal; 207680aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian } 2077ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2078c4a77906c259cba58c147d8468c406a430ecdcbbDmitri Gribenko void makeitReadWriteAttribute() { 20798cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian PropertyAttributes &= ~OBJC_PR_readonly; 20808cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian PropertyAttributes |= OBJC_PR_readwrite; 20811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump } 20828cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian 2083af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar // Helper methods for accessing attributes. 2084af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar 2085f3477c13eeaf11b32a41f181398fb5deffd0dd73Sylvestre Ledru /// isReadOnly - Return true iff the property has a setter. 2086394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar bool isReadOnly() const { 2087394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar return (PropertyAttributes & OBJC_PR_readonly); 2088394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar } 2089af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar 2090265941bc308d65cc270d5c4de5806f37ce405606John McCall /// isAtomic - Return true if the property is atomic. 2091265941bc308d65cc270d5c4de5806f37ce405606John McCall bool isAtomic() const { 2092265941bc308d65cc270d5c4de5806f37ce405606John McCall return (PropertyAttributes & OBJC_PR_atomic); 2093265941bc308d65cc270d5c4de5806f37ce405606John McCall } 2094265941bc308d65cc270d5c4de5806f37ce405606John McCall 2095265941bc308d65cc270d5c4de5806f37ce405606John McCall /// isRetaining - Return true if the property retains its value. 2096265941bc308d65cc270d5c4de5806f37ce405606John McCall bool isRetaining() const { 2097265941bc308d65cc270d5c4de5806f37ce405606John McCall return (PropertyAttributes & 2098265941bc308d65cc270d5c4de5806f37ce405606John McCall (OBJC_PR_retain | OBJC_PR_strong | OBJC_PR_copy)); 2099265941bc308d65cc270d5c4de5806f37ce405606John McCall } 2100265941bc308d65cc270d5c4de5806f37ce405606John McCall 2101af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar /// getSetterKind - Return the method used for doing assignment in 2102af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar /// the property setter. This is only valid if the property has been 2103af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar /// defined to have a setter. 2104af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar SetterKind getSetterKind() const { 21056dc6f008994472cf4da321855e8c51c39720f3edJohn McCall if (PropertyAttributes & OBJC_PR_strong) 21066dc6f008994472cf4da321855e8c51c39720f3edJohn McCall return getType()->isBlockPointerType() ? Copy : Retain; 21076dc6f008994472cf4da321855e8c51c39720f3edJohn McCall if (PropertyAttributes & OBJC_PR_retain) 2108af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar return Retain; 2109af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar if (PropertyAttributes & OBJC_PR_copy) 2110af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar return Copy; 21113a02b44e3948f7762dbfba94b7961281ca29d022Fariborz Jahanian if (PropertyAttributes & OBJC_PR_weak) 21123a02b44e3948f7762dbfba94b7961281ca29d022Fariborz Jahanian return Weak; 2113af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar return Assign; 2114af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar } 2115af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar 21165251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian Selector getGetterName() const { return GetterName; } 21175251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian void setGetterName(Selector Sel) { GetterName = Sel; } 21181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21195251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian Selector getSetterName() const { return SetterName; } 21205251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian void setSetterName(Selector Sel) { SetterName = Sel; } 21211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 212233de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian ObjCMethodDecl *getGetterMethodDecl() const { return GetterMethodDecl; } 212333de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian void setGetterMethodDecl(ObjCMethodDecl *gDecl) { GetterMethodDecl = gDecl; } 212433de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian 212533de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian ObjCMethodDecl *getSetterMethodDecl() const { return SetterMethodDecl; } 212633de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian void setSetterMethodDecl(ObjCMethodDecl *gDecl) { SetterMethodDecl = gDecl; } 21271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 212841c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth // Related to \@optional/\@required declared in \@protocol 212946b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian void setPropertyImplementation(PropertyControl pc) { 213046b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian PropertyImplementation = pc; 213146b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian } 213246b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian PropertyControl getPropertyImplementation() const { 213346b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian return PropertyControl(PropertyImplementation); 21341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump } 21351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2136af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian void setPropertyIvarDecl(ObjCIvarDecl *Ivar) { 2137af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian PropertyIvarDecl = Ivar; 2138af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian } 2139af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian ObjCIvarDecl *getPropertyIvarDecl() const { 2140af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian return PropertyIvarDecl; 2141af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian } 21421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2143aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar virtual SourceRange getSourceRange() const LLVM_READONLY { 2144e3c60a7ce9e0f42c7ca2344b33203266aceca1dbDouglas Gregor return SourceRange(AtLoc, getLocation()); 2145e3c60a7ce9e0f42c7ca2344b33203266aceca1dbDouglas Gregor } 2146ad0ce53c8219456938405b84c5d13341a47e3d94Anna Zaks 2147ad0ce53c8219456938405b84c5d13341a47e3d94Anna Zaks /// Get the default name of the synthesized ivar. 2148ad0ce53c8219456938405b84c5d13341a47e3d94Anna Zaks IdentifierInfo *getDefaultSynthIvarName(ASTContext &Ctx) const; 2149e3c60a7ce9e0f42c7ca2344b33203266aceca1dbDouglas Gregor 21509f550ff05d496e6b9480e5619a21d9da0c9e27c1Ted Kremenek /// Lookup a property by name in the specified DeclContext. 2151de09d0c9694f01a99870a8825266d44a29ebb325Ted Kremenek static ObjCPropertyDecl *findPropertyDecl(const DeclContext *DC, 21529f550ff05d496e6b9480e5619a21d9da0c9e27c1Ted Kremenek IdentifierInfo *propertyID); 21539f550ff05d496e6b9480e5619a21d9da0c9e27c1Ted Kremenek 215480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 215580cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Kind K) { return K == ObjCProperty; } 215682a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian}; 2157980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 21581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// ObjCPropertyImplDecl - Represents implementation declaration of a property 215961d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian/// in a class or category implementation block. For example: 216041c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@synthesize prop1 = ivar1; 216161d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian/// 21624afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCPropertyImplDecl : public Decl { 216361d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanianpublic: 21649f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar enum Kind { 21659f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar Synthesize, 21669f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar Dynamic 216761d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian }; 216861d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanianprivate: 216941c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth SourceLocation AtLoc; // location of \@synthesize or \@dynamic 2170ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 217141c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// \brief For \@synthesize, the location of the ivar, if it was written in 2172a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor /// the source code. 2173a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor /// 2174a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor /// \code 217541c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// \@synthesize int a = b 2176a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor /// \endcode 2177a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor SourceLocation IvarLoc; 2178ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 217961d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian /// Property declaration being implemented 218061d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian ObjCPropertyDecl *PropertyDecl; 2181be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek 218241c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// Null for \@dynamic. Required for \@synthesize. 218361d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian ObjCIvarDecl *PropertyIvarDecl; 2184ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 218541c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// Null for \@dynamic. Non-null if property must be copy-constructed in 218641c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// getter. 218717cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian Expr *GetterCXXConstructor; 2188ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 218941c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth /// Null for \@dynamic. Non-null if property has assignment operator to call 219017cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian /// in Setter synthesis. 219117cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian Expr *SetterCXXAssignment; 2192be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek 2193d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor ObjCPropertyImplDecl(DeclContext *DC, SourceLocation atLoc, SourceLocation L, 21941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ObjCPropertyDecl *property, 21951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Kind PK, 2196a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor ObjCIvarDecl *ivarDecl, 2197a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor SourceLocation ivarLoc) 21981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump : Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc), 2199ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie IvarLoc(ivarLoc), PropertyDecl(property), PropertyIvarDecl(ivarDecl), 220017cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian GetterCXXConstructor(0), SetterCXXAssignment(0) { 22019f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar assert (PK == Dynamic || PropertyIvarDecl); 22029f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar } 22031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 22049f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbarpublic: 2205d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor static ObjCPropertyImplDecl *Create(ASTContext &C, DeclContext *DC, 22061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation atLoc, SourceLocation L, 22071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ObjCPropertyDecl *property, 22081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Kind PK, 2209a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor ObjCIvarDecl *ivarDecl, 2210a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor SourceLocation ivarLoc); 221161d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian 22121e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor static ObjCPropertyImplDecl *CreateDeserialized(ASTContext &C, unsigned ID); 22131e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor 2214aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar virtual SourceRange getSourceRange() const LLVM_READONLY; 2215ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2216aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar SourceLocation getLocStart() const LLVM_READONLY { return AtLoc; } 22178818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor void setAtLoc(SourceLocation Loc) { AtLoc = Loc; } 2218d40910b581b09c937a8c1fdcde9b8ec724398fb9Steve Naroff 2219be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek ObjCPropertyDecl *getPropertyDecl() const { 2220be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek return PropertyDecl; 2221be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek } 22228818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor void setPropertyDecl(ObjCPropertyDecl *Prop) { PropertyDecl = Prop; } 22238818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor 22249f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar Kind getPropertyImplementation() const { 22259f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar return PropertyIvarDecl ? Synthesize : Dynamic; 2226be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek } 22271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2228af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar ObjCIvarDecl *getPropertyIvarDecl() const { 2229be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek return PropertyIvarDecl; 2230be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek } 2231a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor SourceLocation getPropertyIvarDeclLoc() const { return IvarLoc; } 2232ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2233a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor void setPropertyIvarDecl(ObjCIvarDecl *Ivar, 2234ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie SourceLocation IvarLoc) { 2235ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie PropertyIvarDecl = Ivar; 2236a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor this->IvarLoc = IvarLoc; 2237a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor } 2238ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2239135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis /// \brief For \@synthesize, returns true if an ivar name was explicitly 2240135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis /// specified. 2241135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis /// 2242135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis /// \code 2243135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis /// \@synthesize int a = b; // true 2244135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis /// \@synthesize int a; // false 2245135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis /// \endcode 2246135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis bool isIvarNameSpecified() const { 2247135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis return IvarLoc.isValid() && IvarLoc != getLocation(); 2248135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis } 2249135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis 225017cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian Expr *getGetterCXXConstructor() const { 225117cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian return GetterCXXConstructor; 225217cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian } 225317cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian void setGetterCXXConstructor(Expr *getterCXXConstructor) { 225417cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian GetterCXXConstructor = getterCXXConstructor; 225517cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian } 22568818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor 225717cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian Expr *getSetterCXXAssignment() const { 225817cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian return SetterCXXAssignment; 225917cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian } 226017cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian void setSetterCXXAssignment(Expr *setterCXXAssignment) { 226117cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian SetterCXXAssignment = setterCXXAssignment; 226217cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian } 2263ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 226480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classof(const Decl *D) { return classofKind(D->getKind()); } 226580cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall static bool classofKind(Decl::Kind K) { return K == ObjCPropertyImpl; } 2266ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2267a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor friend class ASTDeclReader; 226861d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian}; 226961d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian 2270d329724745b49f894b768d47275b7c2713106e89Douglas Gregortemplate<bool (*Filter)(ObjCCategoryDecl *)> 2271d329724745b49f894b768d47275b7c2713106e89Douglas Gregorvoid 2272d329724745b49f894b768d47275b7c2713106e89Douglas GregorObjCInterfaceDecl::filtered_category_iterator<Filter>:: 2273d329724745b49f894b768d47275b7c2713106e89Douglas GregorfindAcceptableCategory() { 2274d329724745b49f894b768d47275b7c2713106e89Douglas Gregor while (Current && !Filter(Current)) 2275d329724745b49f894b768d47275b7c2713106e89Douglas Gregor Current = Current->getNextClassCategoryRaw(); 2276d329724745b49f894b768d47275b7c2713106e89Douglas Gregor} 2277d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 2278d329724745b49f894b768d47275b7c2713106e89Douglas Gregortemplate<bool (*Filter)(ObjCCategoryDecl *)> 2279d329724745b49f894b768d47275b7c2713106e89Douglas Gregorinline ObjCInterfaceDecl::filtered_category_iterator<Filter> & 2280d329724745b49f894b768d47275b7c2713106e89Douglas GregorObjCInterfaceDecl::filtered_category_iterator<Filter>::operator++() { 2281d329724745b49f894b768d47275b7c2713106e89Douglas Gregor Current = Current->getNextClassCategoryRaw(); 2282d329724745b49f894b768d47275b7c2713106e89Douglas Gregor findAcceptableCategory(); 2283d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return *this; 2284d329724745b49f894b768d47275b7c2713106e89Douglas Gregor} 2285d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 2286d329724745b49f894b768d47275b7c2713106e89Douglas Gregorinline bool ObjCInterfaceDecl::isVisibleCategory(ObjCCategoryDecl *Cat) { 2287d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return !Cat->isHidden(); 2288d329724745b49f894b768d47275b7c2713106e89Douglas Gregor} 2289d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 2290d329724745b49f894b768d47275b7c2713106e89Douglas Gregorinline bool ObjCInterfaceDecl::isVisibleExtension(ObjCCategoryDecl *Cat) { 2291d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return Cat->IsClassExtension() && !Cat->isHidden(); 2292d329724745b49f894b768d47275b7c2713106e89Douglas Gregor} 2293d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 2294d329724745b49f894b768d47275b7c2713106e89Douglas Gregorinline bool ObjCInterfaceDecl::isKnownExtension(ObjCCategoryDecl *Cat) { 2295d329724745b49f894b768d47275b7c2713106e89Douglas Gregor return Cat->IsClassExtension(); 2296d329724745b49f894b768d47275b7c2713106e89Douglas Gregor} 2297d329724745b49f894b768d47275b7c2713106e89Douglas Gregor 2298980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff} // end namespace clang 2299980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#endif 2300