DeclObjC.h revision 7a614d8380297fcd2bc23986241905d97222948c
1980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//===--- DeclObjC.h - Classes for representing declarations -----*- C++ -*-===//
2980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//
3980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//                     The LLVM Compiler Infrastructure
4980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//
50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source
60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details.
7980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//
8980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//===----------------------------------------------------------------------===//
9980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//
10980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//  This file defines the DeclObjC interface and subclasses.
11980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//
12980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//===----------------------------------------------------------------------===//
13980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
14980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#ifndef LLVM_CLANG_AST_DECLOBJC_H
15980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#define LLVM_CLANG_AST_DECLOBJC_H
16980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
17980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#include "clang/AST/Decl.h"
186ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson#include "llvm/ADT/STLExtras.h"
19980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
20980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffnamespace clang {
21980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass Expr;
22980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass Stmt;
23980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass FunctionDecl;
2460f8c868ffb346b78451a3eccaecd0461d2ae498Fariborz Jahanianclass RecordDecl;
25a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCIvarDecl;
26a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCMethodDecl;
27a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCProtocolDecl;
28a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCCategoryDecl;
29a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCPropertyDecl;
30f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanianclass ObjCPropertyImplDecl;
31cbb67480094b3bcb5b715acd827cbad55e2a204cSean Huntclass CXXCtorInitializer;
3268835718c4125f2f66740cd04de7088645ec695dChris Lattner
33793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerclass ObjCListBase {
34793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  void operator=(const ObjCListBase &);     // DO NOT IMPLEMENT
35793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  ObjCListBase(const ObjCListBase&);        // DO NOT IMPLEMENT
36793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerprotected:
37793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  /// List is an array of pointers to objects that are not owned by this object.
38793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  void **List;
393db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  unsigned NumElts;
40793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner
413db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattnerpublic:
42793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  ObjCListBase() : List(0), NumElts(0) {}
43793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  unsigned size() const { return NumElts; }
44793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  bool empty() const { return NumElts == 0; }
451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
46793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerprotected:
4738af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner  void set(void *const* InList, unsigned Elts, ASTContext &Ctx);
48793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner};
491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
51793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// ObjCList - This is a simple template class used to hold various lists of
52793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// decls etc, which is heavily used by the ObjC front-end.  This only use case
53793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// this supports is setting the list all at once and then reading elements out
54793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// of it.
55793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnertemplate <typename T>
56793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerclass ObjCList : public ObjCListBase {
57793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerpublic:
5838af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner  void set(T* const* InList, unsigned Elts, ASTContext &Ctx) {
5938af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner    ObjCListBase::set(reinterpret_cast<void*const*>(InList), Elts, Ctx);
60793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  }
611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
62793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  typedef T* const * iterator;
63793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  iterator begin() const { return (iterator)List; }
64793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  iterator end() const { return (iterator)List+NumElts; }
651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
66793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  T* operator[](unsigned Idx) const {
67793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner    assert(Idx < NumElts && "Invalid access");
68793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner    return (T*)List[Idx];
693db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  }
703db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner};
713db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner
7218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor/// \brief A list of Objective-C protocols, along with the source
7318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor/// locations at which they were referenced.
7418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregorclass ObjCProtocolList : public ObjCList<ObjCProtocolDecl> {
7518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  SourceLocation *Locations;
7618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor
7718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  using ObjCList<ObjCProtocolDecl>::set;
7818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor
7918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregorpublic:
8018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  ObjCProtocolList() : ObjCList<ObjCProtocolDecl>(), Locations(0) { }
8118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor
8218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  typedef const SourceLocation *loc_iterator;
8318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  loc_iterator loc_begin() const { return Locations; }
8418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  loc_iterator loc_end() const { return Locations + size(); }
8518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor
8618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  void set(ObjCProtocolDecl* const* InList, unsigned Elts,
8718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor           const SourceLocation *Locs, ASTContext &Ctx);
8818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor};
891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
9058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
91a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCMethodDecl - Represents an instance or class method declaration.
9258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// ObjC methods can be declared within 4 contexts: class interfaces,
9358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// categories, protocols, and class implementations. While C++ member
941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// functions leverage C syntax, Objective-C method syntax is modeled after
951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// Smalltalk (using colons to specify argument types/expressions).
9658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Here are some brief examples:
9758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff///
9858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Setter/getter instance methods:
9958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// - (void)setMenu:(NSMenu *)menu;
1001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// - (NSMenu *)menu;
1011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
10258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Instance method that takes 2 NSView arguments:
10358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// - (void)replaceSubview:(NSView *)oldView with:(NSView *)newView;
10458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff///
10558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Getter class method:
10658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// + (NSMenu *)defaultMenu;
10758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff///
10858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// A selector represents a unique name for a method. The selector names for
10958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// the above methods are setMenu:, menu, replaceSubview:with:, and defaultMenu.
11058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff///
1114afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCMethodDecl : public NamedDecl, public DeclContext {
11258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroffpublic:
11358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  enum ImplementationControl { None, Required, Optional };
11458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroffprivate:
11585f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  // The conventional meaning of this method; an ObjCMethodFamily.
11685f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  // This is not serialized; instead, it is computed on demand and
11785f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  // cached.
11885f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  mutable unsigned Family : ObjCMethodFamilyBitWidth;
11985f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall
12058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  /// instance (true) or class (false) method.
12185f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  unsigned IsInstance : 1;
12285f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  unsigned IsVariadic : 1;
1231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1244607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian  // Synthesized declaration method for a property setter/getter
12585f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  unsigned IsSynthesized : 1;
1263fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian
1273fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian  // Method has a definition.
12885f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  unsigned IsDefined : 1;
1291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
130ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  // NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum
13158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  /// @required/@optional
132ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  unsigned DeclImplementation : 2;
1331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
134ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  // NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum
13558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  /// in, inout, etc.
136ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  unsigned objcDeclQualifier : 6;
1371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
138926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor  /// \brief Indicates whether this method has a related result type.
139926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor  unsigned RelatedResultType : 1;
140926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor
1417732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian  // Number of args separated by ':' in a method declaration.
1427732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian  unsigned NumSelectorArgs;
1437732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian
1444bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor  // Result type of this method.
14558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  QualType MethodDeclType;
1464bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor
1474bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor  // Type source information for the result type.
1484bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor  TypeSourceInfo *ResultTInfo;
1494bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor
1502073216a1075767b5d25c23d1462b7034686d94dChris Lattner  /// ParamInfo - List of pointers to VarDecls for the formal parameters of this
1512073216a1075767b5d25c23d1462b7034686d94dChris Lattner  /// Method.
1522073216a1075767b5d25c23d1462b7034686d94dChris Lattner  ObjCList<ParmVarDecl> ParamInfo;
1531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
15458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  /// List of attributes for this method declaration.
155a2e85ada1dfef36201a31f6646bc4ea3bd76a89aArgyrios Kyrtzidis  SourceLocation EndLoc; // the location of the ';' or '}'.
1561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
15758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  // The following are only used for method definitions, null otherwise.
15858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  // FIXME: space savings opportunity, consider a sub-class.
15958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  Stmt *Body;
160451318c08a6342c10b8986060386fd9274418437Daniel Dunbar
161451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// SelfDecl - Decl for the implicit self parameter. This is lazily
162451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// constructed by createImplicitParams.
1634111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner  ImplicitParamDecl *SelfDecl;
164451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// CmdDecl - Decl for the implicit _cmd parameter. This is lazily
165451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// constructed by createImplicitParams.
1664111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner  ImplicitParamDecl *CmdDecl;
1671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
168a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc,
16958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff                 Selector SelInfo, QualType T,
1704bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor                 TypeSourceInfo *ResultTInfo,
1710701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff                 DeclContext *contextDecl,
172f6414927e67e27d9324d8d179c5f7ea620443924Daniel Dunbar                 bool isInstance = true,
17358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff                 bool isVariadic = false,
1744607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian                 bool isSynthesized = false,
1753fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian                 bool isDefined = false,
1767732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian                 ImplementationControl impControl = None,
177926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor                 bool HasRelatedResultType = false,
1787732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian                 unsigned numSelectorArgs = 0)
1794afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  : NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo),
18085f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall    DeclContext(ObjCMethod), Family(InvalidObjCMethodFamily),
18158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff    IsInstance(isInstance), IsVariadic(isVariadic),
1824607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian    IsSynthesized(isSynthesized),
1833fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian    IsDefined(isDefined),
18458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff    DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None),
185926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor    RelatedResultType(HasRelatedResultType), NumSelectorArgs(numSelectorArgs),
186926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor    MethodDeclType(T), ResultTInfo(ResultTInfo),
1874111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner    EndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) {}
1888a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek
18957ea6bee79cc60ba20c7886b453f40f380dce1b1Argyrios Kyrtzidis  /// \brief A definition will return its interface declaration.
19057ea6bee79cc60ba20c7886b453f40f380dce1b1Argyrios Kyrtzidis  /// An interface declaration will return its definition.
19157ea6bee79cc60ba20c7886b453f40f380dce1b1Argyrios Kyrtzidis  /// Otherwise it will return itself.
192da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor  virtual ObjCMethodDecl *getNextRedeclaration();
193da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor
1946c4ae5de0c356777446f823b573821fb95560d91Chris Lattnerpublic:
1950ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner  static ObjCMethodDecl *Create(ASTContext &C,
1961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                SourceLocation beginLoc,
1976c4ae5de0c356777446f823b573821fb95560d91Chris Lattner                                SourceLocation endLoc, Selector SelInfo,
1984bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor                                QualType T,
1994bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor                                TypeSourceInfo *ResultTInfo,
2004bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor                                DeclContext *contextDecl,
201f6414927e67e27d9324d8d179c5f7ea620443924Daniel Dunbar                                bool isInstance = true,
2026c4ae5de0c356777446f823b573821fb95560d91Chris Lattner                                bool isVariadic = false,
2034607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian                                bool isSynthesized = false,
2043fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian                                bool isDefined = false,
2057732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian                                ImplementationControl impControl = None,
206926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor                                bool HasRelatedResultType = false,
2077732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian                                unsigned numSelectorArgs = 0);
208e7f9d301a10b4b3223e91d9be4362b44cba0a212Argyrios Kyrtzidis
209da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor  virtual ObjCMethodDecl *getCanonicalDecl();
21013e635c55eb23f736d38abf9c954801bd6482db4Ted Kremenek  const ObjCMethodDecl *getCanonicalDecl() const {
21113e635c55eb23f736d38abf9c954801bd6482db4Ted Kremenek    return const_cast<ObjCMethodDecl*>(this)->getCanonicalDecl();
21213e635c55eb23f736d38abf9c954801bd6482db4Ted Kremenek  }
213e7f9d301a10b4b3223e91d9be4362b44cba0a212Argyrios Kyrtzidis
214ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  ObjCDeclQualifier getObjCDeclQualifier() const {
215ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek    return ObjCDeclQualifier(objcDeclQualifier);
216ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  }
217a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  void setObjCDeclQualifier(ObjCDeclQualifier QV) { objcDeclQualifier = QV; }
2181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
219926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor  /// \brief Determine whether this method has a result type that is related
220926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor  /// to the message receiver's type.
221926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor  bool hasRelatedResultType() const { return RelatedResultType; }
222926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor
223926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor  /// \brief Note whether this method has a related result type.
224926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor  void SetRelatedResultType(bool RRT = true) { RelatedResultType = RRT; }
225926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor
2267732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian  unsigned getNumSelectorArgs() const { return NumSelectorArgs; }
2277732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian  void setNumSelectorArgs(unsigned numSelectorArgs) {
2287732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian    NumSelectorArgs = numSelectorArgs;
2297732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian  }
2307732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian
23158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  // Location information, modeled after the Stmt API.
23258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  SourceLocation getLocStart() const { return getLocation(); }
23358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  SourceLocation getLocEnd() const { return EndLoc; }
23453c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff  void setEndLoc(SourceLocation Loc) { EndLoc = Loc; }
235da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor  virtual SourceRange getSourceRange() const {
2361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return SourceRange(getLocation(), EndLoc);
2379776ba0d844cf9f6888e871e3fd246ae782f76f4Daniel Dunbar  }
2381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2395619688510185081cbb4621d703daf7ee24cf39aChris Lattner  ObjCInterfaceDecl *getClassInterface();
2405619688510185081cbb4621d703daf7ee24cf39aChris Lattner  const ObjCInterfaceDecl *getClassInterface() const {
2415619688510185081cbb4621d703daf7ee24cf39aChris Lattner    return const_cast<ObjCMethodDecl*>(this)->getClassInterface();
242e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  }
2431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2442e1cd4264d363ca869bf37ef160902f211d21b8cDouglas Gregor  Selector getSelector() const { return getDeclName().getObjCSelector(); }
2453a082d81006e7a2e01a6e431a22e21c78490ff8fAnders Carlsson
24658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  QualType getResultType() const { return MethodDeclType; }
24753c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff  void setResultType(QualType T) { MethodDeclType = T; }
2481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2495291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor  /// \brief Determine the type of an expression that sends a message to this
2505291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor  /// function.
2515291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor  QualType getSendResultType() const {
2526398235d7890a81b785ea5af3b6e66d86bf184ccDouglas Gregor    return getResultType().getNonLValueExprType(getASTContext());
2535291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor  }
2545291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor
2554bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor  TypeSourceInfo *getResultTypeSourceInfo() const { return ResultTInfo; }
2564bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor  void setResultTypeSourceInfo(TypeSourceInfo *TInfo) { ResultTInfo = TInfo; }
2574bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor
258d57f635d520e8cb5b93d3d770ff58db06c62de54Chris Lattner  // Iterator access to formal parameters.
2592073216a1075767b5d25c23d1462b7034686d94dChris Lattner  unsigned param_size() const { return ParamInfo.size(); }
2602073216a1075767b5d25c23d1462b7034686d94dChris Lattner  typedef ObjCList<ParmVarDecl>::iterator param_iterator;
2612073216a1075767b5d25c23d1462b7034686d94dChris Lattner  param_iterator param_begin() const { return ParamInfo.begin(); }
2622073216a1075767b5d25c23d1462b7034686d94dChris Lattner  param_iterator param_end() const { return ParamInfo.end(); }
2637732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian  // This method returns and of the parameters which are part of the selector
2647732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian  // name mangling requirements.
2657732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian  param_iterator sel_param_end() const {
2667732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian    return ParamInfo.begin() + NumSelectorArgs;
2677732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian  }
26889951a86b594513c2a013532ed45d197413b1087Chris Lattner
2694ecb25fa94897b2c03510292acace710e5262ba5Fariborz Jahanian  void setMethodParams(ASTContext &C, ParmVarDecl *const *List, unsigned Num,
2704ecb25fa94897b2c03510292acace710e5262ba5Fariborz Jahanian                       unsigned numSelectorArgs) {
27138af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner    ParamInfo.set(List, Num, C);
2724ecb25fa94897b2c03510292acace710e5262ba5Fariborz Jahanian    NumSelectorArgs = numSelectorArgs;
2732073216a1075767b5d25c23d1462b7034686d94dChris Lattner  }
2744111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner
2756ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson  // Iterator access to parameter types.
2766ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson  typedef std::const_mem_fun_t<QualType, ParmVarDecl> deref_fun;
2776ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson  typedef llvm::mapped_iterator<param_iterator, deref_fun> arg_type_iterator;
2786ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson
2796ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson  arg_type_iterator arg_type_begin() const {
2806ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson    return llvm::map_iterator(param_begin(), deref_fun(&ParmVarDecl::getType));
2816ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson  }
2826ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson  arg_type_iterator arg_type_end() const {
2836ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson    return llvm::map_iterator(param_end(), deref_fun(&ParmVarDecl::getType));
2846ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson  }
2851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
286451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// createImplicitParams - Used to lazily create the self and cmd
287451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// implict parameters. This must be called prior to using getSelfDecl()
288451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// or getCmdDecl(). The call is ignored if the implicit paramters
289451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// have already been created.
290fef30b55230064d334a669a065a1c9acdb87cdfeFariborz Jahanian  void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID);
291451318c08a6342c10b8986060386fd9274418437Daniel Dunbar
2924111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner  ImplicitParamDecl * getSelfDecl() const { return SelfDecl; }
29353c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff  void setSelfDecl(ImplicitParamDecl *SD) { SelfDecl = SD; }
2944111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner  ImplicitParamDecl * getCmdDecl() const { return CmdDecl; }
29553c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff  void setCmdDecl(ImplicitParamDecl *CD) { CmdDecl = CD; }
2961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
29785f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  /// Determines the family of this method.
29885f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  ObjCMethodFamily getMethodFamily() const;
29985f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall
300f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor  bool isInstanceMethod() const { return IsInstance; }
30153c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff  void setInstanceMethod(bool isInst) { IsInstance = isInst; }
30258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  bool isVariadic() const { return IsVariadic; }
30353c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff  void setVariadic(bool isVar) { IsVariadic = isVar; }
3041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
305f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor  bool isClassMethod() const { return !IsInstance; }
306f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor
3074607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian  bool isSynthesized() const { return IsSynthesized; }
30853c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff  void setSynthesized(bool isSynth) { IsSynthesized = isSynth; }
3093fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian
3103fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian  bool isDefined() const { return IsDefined; }
3113fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian  void setDefined(bool isDefined) { IsDefined = isDefined; }
3121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
31358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  // Related to protocols declared in  @protocol
3141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  void setDeclImplementation(ImplementationControl ic) {
3151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    DeclImplementation = ic;
31658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  }
3171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ImplementationControl getImplementationControl() const {
3181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return ImplementationControl(DeclImplementation);
31958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  }
320792481eec23d8c1aa92173be589e2ae9d02514a5Ted Kremenek
321da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor  virtual Stmt *getBody() const {
3221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return (Stmt*) Body;
3237297134f128423fce2e88f92421ed135bded7d4eDouglas Gregor  }
3246fb0aee4f9dc261bbec72e1283ad8dc0557a6d96Argyrios Kyrtzidis  CompoundStmt *getCompoundBody() { return (CompoundStmt*)Body; }
325d3a413d3b8eb39bcee5944bc545d9997c1abe492Sebastian Redl  void setBody(Stmt *B) { Body = B; }
32658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
32766570b230941651245accbc5680b60e904eb993cArgyrios Kyrtzidis  /// \brief Returns whether this specific method is a definition.
32866570b230941651245accbc5680b60e904eb993cArgyrios Kyrtzidis  bool isThisDeclarationADefinition() const { return Body; }
32966570b230941651245accbc5680b60e904eb993cArgyrios Kyrtzidis
33058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  // Implement isa/cast/dyncast/etc.
33180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
332a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCMethodDecl *D) { return true; }
33380cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCMethod; }
33442220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis  static DeclContext *castToDeclContext(const ObjCMethodDecl *D) {
33542220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis    return static_cast<DeclContext *>(const_cast<ObjCMethodDecl*>(D));
33642220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis  }
33742220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis  static ObjCMethodDecl *castFromDeclContext(const DeclContext *DC) {
33842220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis    return static_cast<ObjCMethodDecl *>(const_cast<DeclContext*>(DC));
33942220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis  }
34058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff};
341e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
342e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff/// ObjCContainerDecl - Represents a container for method declarations.
343aecae629269fae3bf484baf1d109e9a89d14eeadArgyrios Kyrtzidis/// Current sub-classes are ObjCInterfaceDecl, ObjCCategoryDecl,
3441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// ObjCProtocolDecl, and ObjCImplDecl.
345e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff///
3464afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCContainerDecl : public NamedDecl, public DeclContext {
347782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek  // These two locations in the range mark the end of the method container.
348782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek  // The first points to the '@' token, and the second to the 'end' token.
349782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek  SourceRange AtEnd;
350e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroffpublic:
351e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
3521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ObjCContainerDecl(Kind DK, DeclContext *DC, SourceLocation L,
353d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor                    IdentifierInfo *Id)
3544afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor    : NamedDecl(DK, DC, L, Id), DeclContext(DK) {}
355e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
35693983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff  // Iterator access to properties.
35793983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff  typedef specific_decl_iterator<ObjCPropertyDecl> prop_iterator;
3581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  prop_iterator prop_begin() const {
35917945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return prop_iterator(decls_begin());
36093983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff  }
3611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  prop_iterator prop_end() const {
36217945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return prop_iterator(decls_end());
36309c4719788a5cea09897525e528fa00420f1677bSteve Naroff  }
3641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3650701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  // Iterator access to instance/class methods.
366f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor  typedef specific_decl_iterator<ObjCMethodDecl> method_iterator;
3671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  method_iterator meth_begin() const {
36817945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return method_iterator(decls_begin());
3697ed4faca5162b3ab85be7f7e57aa40e6ec170971Ted Kremenek  }
3701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  method_iterator meth_end() const {
37117945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return method_iterator(decls_end());
3727ed4faca5162b3ab85be7f7e57aa40e6ec170971Ted Kremenek  }
3730701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff
3741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  typedef filtered_decl_iterator<ObjCMethodDecl,
3751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                 &ObjCMethodDecl::isInstanceMethod>
376669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor    instmeth_iterator;
37717945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  instmeth_iterator instmeth_begin() const {
37817945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return instmeth_iterator(decls_begin());
379e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff  }
38017945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  instmeth_iterator instmeth_end() const {
38117945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return instmeth_iterator(decls_end());
382e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff  }
383e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
3841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  typedef filtered_decl_iterator<ObjCMethodDecl,
3851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                 &ObjCMethodDecl::isClassMethod>
386669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor    classmeth_iterator;
38717945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  classmeth_iterator classmeth_begin() const {
38817945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return classmeth_iterator(decls_begin());
389e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff  }
39017945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  classmeth_iterator classmeth_end() const {
39117945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return classmeth_iterator(decls_end());
3920701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  }
3930701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff
3940701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  // Get the local instance/class method declared in this interface.
395467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis  ObjCMethodDecl *getMethod(Selector Sel, bool isInstance) const;
396467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis  ObjCMethodDecl *getInstanceMethod(Selector Sel) const {
397467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis    return getMethod(Sel, true/*isInstance*/);
39853df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner  }
399467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis  ObjCMethodDecl *getClassMethod(Selector Sel) const {
400467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis    return getMethod(Sel, false/*isInstance*/);
401467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis  }
402467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis  ObjCIvarDecl *getIvarDecl(IdentifierInfo *Id) const;
4031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
40417945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const;
40593983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff
406e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff  // Marks the end of the container.
407782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek  SourceRange getAtEndRange() const {
408782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek    return AtEnd;
409782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek  }
410782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek  void setAtEndRange(SourceRange atEnd) {
411782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek    AtEnd = atEnd;
412782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek  }
413ddfd4c9eda34765b08fae4cb31ad5a365face107Argyrios Kyrtzidis
414da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor  virtual SourceRange getSourceRange() const {
415782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek    return SourceRange(getLocation(), getAtEndRange().getEnd());
416ddfd4c9eda34765b08fae4cb31ad5a365face107Argyrios Kyrtzidis  }
4171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
41809c4719788a5cea09897525e528fa00420f1677bSteve Naroff  // Implement isa/cast/dyncast/etc.
41980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
42009c4719788a5cea09897525e528fa00420f1677bSteve Naroff  static bool classof(const ObjCContainerDecl *D) { return true; }
42180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) {
4229a55591af3e5506b95a9718e15380129fbfc5ebcSean Hunt    return K >= firstObjCContainer &&
4239a55591af3e5506b95a9718e15380129fbfc5ebcSean Hunt           K <= lastObjCContainer;
42480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  }
42509c4719788a5cea09897525e528fa00420f1677bSteve Naroff
42609c4719788a5cea09897525e528fa00420f1677bSteve Naroff  static DeclContext *castToDeclContext(const ObjCContainerDecl *D) {
42709c4719788a5cea09897525e528fa00420f1677bSteve Naroff    return static_cast<DeclContext *>(const_cast<ObjCContainerDecl*>(D));
42809c4719788a5cea09897525e528fa00420f1677bSteve Naroff  }
42909c4719788a5cea09897525e528fa00420f1677bSteve Naroff  static ObjCContainerDecl *castFromDeclContext(const DeclContext *DC) {
43009c4719788a5cea09897525e528fa00420f1677bSteve Naroff    return static_cast<ObjCContainerDecl *>(const_cast<DeclContext*>(DC));
43109c4719788a5cea09897525e528fa00420f1677bSteve Naroff  }
432e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff};
433e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
434a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCInterfaceDecl - Represents an ObjC class declaration. For example:
4350c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
4360c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   // MostPrimitive declares no super class (not particularly useful).
4371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///   @interface MostPrimitive
4380c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     // no instance variables or methods.
4390c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @end
4400c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
4411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///   // NSResponder inherits from NSObject & implements NSCoding (a protocol).
4420c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @interface NSResponder : NSObject <NSCoding>
443a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek///   { // instance variables are represented by ObjCIvarDecl.
4440c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id nextResponder; // nextResponder instance variable.
4450c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   }
4460c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   - (NSResponder *)nextResponder; // return a pointer to NSResponder.
4470c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   - (void)mouseMoved:(NSEvent *)theEvent; // return void, takes a pointer
4480c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @end                                    // to an NSEvent.
4490c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
4500c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   Unlike C/C++, forward class declarations are accomplished with @class.
4510c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   Unlike C/C++, @class allows for a list of classes to be forward declared.
4520c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   Unlike C++, ObjC is a single-rooted class model. In Cocoa, classes
4530c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   typically inherit from NSObject (an exception is NSProxy).
4540c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
455deacbdca554298ccdf636f19c6094a8825ec6b34Douglas Gregorclass ObjCInterfaceDecl : public ObjCContainerDecl {
4563110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff  /// TypeForDecl - This indicates the Type object that represents this
4573110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff  /// TypeDecl.  It is a cache maintained by ASTContext::getObjCInterfaceType
458f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall  mutable const Type *TypeForDecl;
4593110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff  friend class ASTContext;
4601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
461980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Class's super class.
462a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl *SuperClass;
4631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
46453b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  /// Protocols referenced in the @interface  declaration
46518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  ObjCProtocolList ReferencedProtocols;
46653b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
46753b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  /// Protocols reference in both the @interface and class extensions.
46853b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  ObjCList<ObjCProtocolDecl> AllReferencedProtocols;
4691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
4708c99d88a6cfa14fc2edab819d5e4325c973b2809Douglas Gregor  /// \brief List of categories and class extensions defined for this class.
4718c99d88a6cfa14fc2edab819d5e4325c973b2809Douglas Gregor  ///
4728c99d88a6cfa14fc2edab819d5e4325c973b2809Douglas Gregor  /// Categories are stored as a linked list in the AST, since the categories
4738c99d88a6cfa14fc2edab819d5e4325c973b2809Douglas Gregor  /// and class extensions come long after the initial interface declaration,
474fc8f0e14ad142ed811e90fbd9a30e419e301c717Chris Lattner  /// and we avoid dynamically-resized arrays in the AST wherever possible.
475a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCCategoryDecl *CategoryList;
4762c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian
4772c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian  /// IvarList - List of all ivars defined by this class; including class
4782c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian  /// extensions and implementation. This list is built lazily.
4792c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian  ObjCIvarDecl *IvarList;
4801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
4813a3ca1b35a7121aea0bf465a192dce748465e10fFariborz Jahanian  bool ForwardDecl:1; // declared with @class.
4823a3ca1b35a7121aea0bf465a192dce748465e10fFariborz Jahanian  bool InternalInterface:1; // true - no @interface for @implementation
48326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
48426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  /// \brief Indicates that the contents of this Objective-C class will be
48526ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  /// completed by the external AST source when required.
48626ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  mutable bool ExternallyCompleted : 1;
48726ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
488d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff  SourceLocation ClassLoc; // location of the class identifier.
489d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff  SourceLocation SuperClassLoc; // location of the super class identifier.
490f908a87299d278164540f90b5b6e6cab7b14fb41Steve Naroff  SourceLocation EndLoc; // marks the '>', '}', or identifier.
4910e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattner
492d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCInterfaceDecl(DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id,
493deacbdca554298ccdf636f19c6094a8825ec6b34Douglas Gregor                    SourceLocation CLoc, bool FD, bool isInternal);
4941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
49526ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  void LoadExternalDefinition() const;
4960e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattnerpublic:
497d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCInterfaceDecl *Create(ASTContext &C, DeclContext *DC,
4980ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner                                   SourceLocation atLoc,
4991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                   IdentifierInfo *Id,
500deacbdca554298ccdf636f19c6094a8825ec6b34Douglas Gregor                                   SourceLocation ClassLoc = SourceLocation(),
5010e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattner                                   bool ForwardDecl = false,
5020e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattner                                   bool isInternal = false);
50326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
50426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  /// \brief Indicate that this Objective-C class is complete, but that
50526ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  /// the external AST source will be responsible for filling in its contents
50626ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  /// when a complete class is required.
50726ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  void setExternallyCompleted();
50826ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
50918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  const ObjCProtocolList &getReferencedProtocols() const {
51026ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor    if (ExternallyCompleted)
51126ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
51226ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
5131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return ReferencedProtocols;
5147ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  }
5158a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis
5168a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis  ObjCImplementationDecl *getImplementation() const;
5178a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis  void setImplementation(ObjCImplementationDecl *ImplD);
5188a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis
519559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  ObjCCategoryDecl *FindCategoryDeclaration(IdentifierInfo *CategoryId) const;
5201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
5211cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis  // Get the local instance/class method declared in a category.
5221cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis  ObjCMethodDecl *getCategoryInstanceMethod(Selector Sel) const;
5231cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis  ObjCMethodDecl *getCategoryClassMethod(Selector Sel) const;
5241cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis  ObjCMethodDecl *getCategoryMethod(Selector Sel, bool isInstance) const {
5251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return isInstance ? getInstanceMethod(Sel)
5261cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis                      : getClassMethod(Sel);
5271cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis  }
5283db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner
52918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  typedef ObjCProtocolList::iterator protocol_iterator;
53053b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
53153b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  protocol_iterator protocol_begin() const {
53226ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor    if (ExternallyCompleted)
53326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
53426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
53553b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek    return ReferencedProtocols.begin();
53653b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  }
53753b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  protocol_iterator protocol_end() const {
53826ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor    if (ExternallyCompleted)
53926ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
54026ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
54153b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek    return ReferencedProtocols.end();
54253b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  }
54353b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
54418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  typedef ObjCProtocolList::loc_iterator protocol_loc_iterator;
54553b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
54618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  protocol_loc_iterator protocol_loc_begin() const {
54726ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor    if (ExternallyCompleted)
54826ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
54926ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
55018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor    return ReferencedProtocols.loc_begin();
55118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  }
55253b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
55318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  protocol_loc_iterator protocol_loc_end() const {
55426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor    if (ExternallyCompleted)
55526ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
55626ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
55718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor    return ReferencedProtocols.loc_end();
55818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  }
55953b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
56053b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  typedef ObjCList<ObjCProtocolDecl>::iterator all_protocol_iterator;
56153b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
56253b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  all_protocol_iterator all_referenced_protocol_begin() const {
56326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor    if (ExternallyCompleted)
56426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
56526ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
56653b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek    return AllReferencedProtocols.empty() ? protocol_begin()
56753b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek      : AllReferencedProtocols.begin();
56853b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  }
56953b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  all_protocol_iterator all_referenced_protocol_end() const {
57026ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor    if (ExternallyCompleted)
57126ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
57226ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
57353b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek    return AllReferencedProtocols.empty() ? protocol_end()
57453b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek      : AllReferencedProtocols.end();
57553b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  }
576291be393aa33759e6e34b6429c5ffa206ba50115Douglas Gregor
57711062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian  typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator;
57853b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
57911062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian  ivar_iterator ivar_begin() const { return  ivar_iterator(decls_begin()); }
58011062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian  ivar_iterator ivar_end() const { return ivar_iterator(decls_end()); }
58153b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
58211062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian  unsigned ivar_size() const {
58311062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian    return std::distance(ivar_begin(), ivar_end());
58411062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian  }
58553b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
58611062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian  bool ivar_empty() const { return ivar_begin() == ivar_end(); }
5872c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian
5882c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian  ObjCIvarDecl  *all_declared_ivar_begin();
5892c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian  void setIvarList(ObjCIvarDecl *ivar) { IvarList = ivar; }
5902c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian
59138af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner  /// setProtocolList - Set the list of protocols that this interface
592b752f289026ad8e5f44851b20e009a27ed61eefcChris Lattner  /// implements.
59338af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner  void setProtocolList(ObjCProtocolDecl *const* List, unsigned Num,
59418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor                       const SourceLocation *Locs, ASTContext &C) {
59518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor    ReferencedProtocols.set(List, Num, Locs, C);
5963db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  }
5971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
598339798eae1eb61c50ca68766ed028c0a16d0a284Fariborz Jahanian  /// mergeClassExtensionProtocolList - Merge class extension's protocol list
599339798eae1eb61c50ca68766ed028c0a16d0a284Fariborz Jahanian  /// into the protocol list for this class.
60018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  void mergeClassExtensionProtocolList(ObjCProtocolDecl *const* List,
60118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor                                       unsigned Num,
60218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor                                       ASTContext &C);
603339798eae1eb61c50ca68766ed028c0a16d0a284Fariborz Jahanian
604768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff  bool isForwardDecl() const { return ForwardDecl; }
605768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff  void setForwardDecl(bool val) { ForwardDecl = val; }
6061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
60726ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  ObjCInterfaceDecl *getSuperClass() const {
60826ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor    if (ExternallyCompleted)
60926ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
61026ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
61126ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor    return SuperClass;
61226ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  }
61326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
614a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; }
6151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
61626ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  ObjCCategoryDecl* getCategoryList() const {
61726ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor    if (ExternallyCompleted)
61826ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
61926ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
62026ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor    return CategoryList;
62126ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  }
62226ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
6231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  void setCategoryList(ObjCCategoryDecl *category) {
62453efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner    CategoryList = category;
625980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
62680aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian
62780aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian  ObjCCategoryDecl* getFirstClassExtension() const;
62837cafb077ad5b170acae77e566638603011ef4c0Ted Kremenek
62937cafb077ad5b170acae77e566638603011ef4c0Ted Kremenek  ObjCPropertyDecl
63037cafb077ad5b170acae77e566638603011ef4c0Ted Kremenek    *FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId) const;
63137cafb077ad5b170acae77e566638603011ef4c0Ted Kremenek
63253efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner  /// isSuperClassOf - Return true if this class is the specified class or is a
63353efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner  /// super class of the specified interface class.
63453efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner  bool isSuperClassOf(const ObjCInterfaceDecl *I) const {
63553efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner    // If RHS is derived from LHS it is OK; else it is not OK.
63653efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner    while (I != NULL) {
63753efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner      if (this == I)
63853efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner        return true;
63953efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner      I = I->getSuperClass();
64053efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner    }
64153efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner    return false;
64253efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner  }
6431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
64417945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName,
64568a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner                                       ObjCInterfaceDecl *&ClassDeclared);
64617945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName) {
64768a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner    ObjCInterfaceDecl *ClassDeclared;
64817945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return lookupInstanceVariable(IVarName, ClassDeclared);
64968a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner  }
65068a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner
65194a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff  // Lookup a method. First, we search locally. If a method isn't
65294a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff  // found, we search referenced protocols and class categories.
653aa5420c1e36ab8e0e4bb87239d8b73a3a8ce75dbArgyrios Kyrtzidis  ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance) const;
654aa5420c1e36ab8e0e4bb87239d8b73a3a8ce75dbArgyrios Kyrtzidis  ObjCMethodDecl *lookupInstanceMethod(Selector Sel) const {
655aa5420c1e36ab8e0e4bb87239d8b73a3a8ce75dbArgyrios Kyrtzidis    return lookupMethod(Sel, true/*isInstance*/);
656aa5420c1e36ab8e0e4bb87239d8b73a3a8ce75dbArgyrios Kyrtzidis  }
657aa5420c1e36ab8e0e4bb87239d8b73a3a8ce75dbArgyrios Kyrtzidis  ObjCMethodDecl *lookupClassMethod(Selector Sel) const {
658aa5420c1e36ab8e0e4bb87239d8b73a3a8ce75dbArgyrios Kyrtzidis    return lookupMethod(Sel, false/*isInstance*/);
659aa5420c1e36ab8e0e4bb87239d8b73a3a8ce75dbArgyrios Kyrtzidis  }
660cd1876207f5564beba74e4b2524b664bdba0ba9fFariborz Jahanian  ObjCInterfaceDecl *lookupInheritedClass(const IdentifierInfo *ICName);
661d789d3d985e28c9404e62157af46dcb7331920e0Steve Naroff
662d789d3d985e28c9404e62157af46dcb7331920e0Steve Naroff  // Lookup a method in the classes implementation hierarchy.
66374b2756bc1f1f5f7c189996fe7e4cd3efef70263Fariborz Jahanian  ObjCMethodDecl *lookupPrivateMethod(const Selector &Sel, bool Instance=true);
66460fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff
665ddfd4c9eda34765b08fae4cb31ad5a365face107Argyrios Kyrtzidis  // Location information, modeled after the Stmt API.
66660fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff  SourceLocation getLocStart() const { return getLocation(); } // '@'interface
667f908a87299d278164540f90b5b6e6cab7b14fb41Steve Naroff  SourceLocation getLocEnd() const { return EndLoc; }
6687177dee8aee4b432911c91f1b788963bec0cac9fDaniel Dunbar  void setLocEnd(SourceLocation LE) { EndLoc = LE; }
6691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
67033feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff  void setClassLoc(SourceLocation Loc) { ClassLoc = Loc; }
671d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff  SourceLocation getClassLoc() const { return ClassLoc; }
672d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff  void setSuperClassLoc(SourceLocation Loc) { SuperClassLoc = Loc; }
673d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff  SourceLocation getSuperClassLoc() const { return SuperClassLoc; }
6741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
67528e71cf851b73a67604735a9a95aef800b144e2eSteve Naroff  /// isImplicitInterfaceDecl - check that this is an implicitly declared
676a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  /// ObjCInterfaceDecl node. This is for legacy objective-c @implementation
6774b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian  /// declaration without an @interface declaration.
67833feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff  bool isImplicitInterfaceDecl() const { return InternalInterface; }
67933feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff  void setImplicitInterfaceDecl(bool val) { InternalInterface = val; }
6801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
6810fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian  /// ClassImplementsProtocol - Checks that 'lProto' protocol
6820fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian  /// has been implemented in IDecl class, its super class or categories (if
6830fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian  /// lookupCategory is true).
6840fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian  bool ClassImplementsProtocol(ObjCProtocolDecl *lProto,
6850fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian                               bool lookupCategory,
6860fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian                               bool RHSIsQualifiedID = false);
6871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
68833feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff  // Low-level accessor
689f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall  const Type *getTypeForDecl() const { return TypeForDecl; }
690f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall  void setTypeForDecl(const Type *TD) const { TypeForDecl = TD; }
69133feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff
69280cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
693a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCInterfaceDecl *D) { return true; }
69480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCInterface; }
69553b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
69653b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  friend class ASTDeclReader;
69753b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  friend class ASTDeclWriter;
698980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
699980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
700a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCIvarDecl - Represents an ObjC instance variable. In general, ObjC
7010c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// instance variables are identical to C. The only exception is Objective-C
7020c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// supports C++ style access control. For example:
7030c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
7040c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @interface IvarExample : NSObject
7050c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   {
706f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek///     id defaultToProtected;
7070c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @public:
7080c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id canBePublic; // same as C++.
7090c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @protected:
7100c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id canBeProtected; // same as C++.
7110c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @package:
7120c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id canBePackage; // framework visibility (not available in C++).
7130c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   }
7140c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
715a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCIvarDecl : public FieldDecl {
7160e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattnerpublic:
717980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  enum AccessControl {
718980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    None, Private, Protected, Public, Package
719980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  };
7201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
721b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenekprivate:
722ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara  ObjCIvarDecl(ObjCContainerDecl *DC, SourceLocation StartLoc,
723ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara               SourceLocation IdLoc, IdentifierInfo *Id,
724ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian               QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW,
725ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian               bool synthesized)
726ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara    : FieldDecl(ObjCIvar, DC, StartLoc, IdLoc, Id, T, TInfo, BW,
7277a614d8380297fcd2bc23986241905d97222948cRichard Smith                /*Mutable=*/false, /*HasInit=*/false),
728ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara      NextIvar(0), DeclAccess(ac), Synthesized(synthesized) {}
7291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
730b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenekpublic:
731a06549226f45d5b72169a3d054415616dd1014a2Daniel Dunbar  static ObjCIvarDecl *Create(ASTContext &C, ObjCContainerDecl *DC,
732ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara                              SourceLocation StartLoc, SourceLocation IdLoc,
733ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara                              IdentifierInfo *Id, QualType T,
734a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall                              TypeSourceInfo *TInfo,
735ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian                              AccessControl ac, Expr *BW = NULL,
736ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian                              bool synthesized=false);
7371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
73827a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar  /// \brief Return the class interface that this ivar is logically contained
73927a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar  /// in; this is either the interface where the ivar was declared, or the
74027a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar  /// interface the ivar is conceptually a part of in the case of synthesized
74127a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar  /// ivars.
74227a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar  const ObjCInterfaceDecl *getContainingInterface() const;
7432c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian
7442c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian  ObjCIvarDecl *getNextIvar() { return NextIvar; }
7452c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian  void setNextIvar(ObjCIvarDecl *ivar) { NextIvar = ivar; }
74627a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar
747980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void setAccessControl(AccessControl ac) { DeclAccess = ac; }
748f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek
749ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  AccessControl getAccessControl() const { return AccessControl(DeclAccess); }
750f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek
751f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek  AccessControl getCanonicalAccessControl() const {
752f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek    return DeclAccess == None ? Protected : AccessControl(DeclAccess);
753f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek  }
7541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
755ac0021ba802e193e0f9f8207768c7862c7603bc0Fariborz Jahanian  void setSynthesize(bool synth) { Synthesized = synth; }
756ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian  bool getSynthesize() const { return Synthesized; }
757ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian
758980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  // Implement isa/cast/dyncast/etc.
75980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
760a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCIvarDecl *D) { return true; }
76180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCIvar; }
762980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffprivate:
7632c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian  /// NextIvar - Next Ivar in the list of ivars declared in class; class's
7642c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian  /// extensions and class's implementation
7652c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian  ObjCIvarDecl *NextIvar;
7662c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian
767ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  // NOTE: VC++ treats enums as signed, avoid using the AccessControl enum
768ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  unsigned DeclAccess : 3;
769ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian  unsigned Synthesized : 1;
770980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
771980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
7721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
77301e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek/// ObjCAtDefsFieldDecl - Represents a field declaration created by an
77401e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek///  @defs(...).
77501e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenekclass ObjCAtDefsFieldDecl : public FieldDecl {
77601e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenekprivate:
777ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara  ObjCAtDefsFieldDecl(DeclContext *DC, SourceLocation StartLoc,
778ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara                      SourceLocation IdLoc, IdentifierInfo *Id,
77901e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek                      QualType T, Expr *BW)
780ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara    : FieldDecl(ObjCAtDefsField, DC, StartLoc, IdLoc, Id, T,
781a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall                /*TInfo=*/0, // FIXME: Do ObjCAtDefs have declarators ?
7827a614d8380297fcd2bc23986241905d97222948cRichard Smith                BW, /*Mutable=*/false, /*HasInit=*/false) {}
7831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
78401e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenekpublic:
78544b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor  static ObjCAtDefsFieldDecl *Create(ASTContext &C, DeclContext *DC,
786ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara                                     SourceLocation StartLoc,
787ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara                                     SourceLocation IdLoc, IdentifierInfo *Id,
788ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara                                     QualType T, Expr *BW);
7891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
79001e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek  // Implement isa/cast/dyncast/etc.
79180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
79201e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek  static bool classof(const ObjCAtDefsFieldDecl *D) { return true; }
79380cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCAtDefsField; }
79401e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek};
795980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
796a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCProtocolDecl - Represents a protocol declaration. ObjC protocols
7971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// declare a pure abstract type (i.e no instance variables are permitted).
798fc8f0e14ad142ed811e90fbd9a30e419e301c717Chris Lattner/// Protocols originally drew inspiration from C++ pure virtual functions (a C++
7990c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// feature with nice semantics and lousy syntax:-). Here is an example:
8000c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
801eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// @protocol NSDraggingInfo <refproto1, refproto2>
8020c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSWindow *)draggingDestinationWindow;
8030c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSImage *)draggedImage;
8040c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end
8050c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
806eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// This says that NSDraggingInfo requires two methods and requires everything
807eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// that the two "referenced protocols" 'refproto1' and 'refproto2' require as
808eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// well.
809eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner///
8100c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @interface ImplementsNSDraggingInfo : NSObject <NSDraggingInfo>
8110c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end
8120c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
813a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjC protocols inspired Java interfaces. Unlike Java, ObjC classes and
8140c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// protocols are in distinct namespaces. For example, Cocoa defines both
8151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// an NSObject protocol and class (which isn't allowed in Java). As a result,
8160c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// protocols are referenced using angle brackets as follows:
8170c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
8180c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id <NSDraggingInfo> anyObjectThatImplementsNSDraggingInfo;
8190c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
820e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroffclass ObjCProtocolDecl : public ObjCContainerDecl {
821780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  /// Referenced protocols
82218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  ObjCProtocolList ReferencedProtocols;
8231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
824980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  bool isForwardProtoDecl; // declared with @protocol.
8251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
826423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff  SourceLocation EndLoc; // marks the '>' or identifier.
8271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
828d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCProtocolDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id)
8291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    : ObjCContainerDecl(ObjCProtocol, DC, L, Id),
830c858105d41602a2dadb2efbc1af80a7b791ebac3Chris Lattner      isForwardProtoDecl(true) {
831cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattner  }
8321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
833cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattnerpublic:
8341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static ObjCProtocolDecl *Create(ASTContext &C, DeclContext *DC,
835d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor                                  SourceLocation L, IdentifierInfo *Id);
836cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattner
83718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  const ObjCProtocolList &getReferencedProtocols() const {
838780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner    return ReferencedProtocols;
839980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
84018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  typedef ObjCProtocolList::iterator protocol_iterator;
841780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
842780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
84318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  typedef ObjCProtocolList::loc_iterator protocol_loc_iterator;
84418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  protocol_loc_iterator protocol_loc_begin() const {
84518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor    return ReferencedProtocols.loc_begin();
84618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  }
84718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  protocol_loc_iterator protocol_loc_end() const {
84818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor    return ReferencedProtocols.loc_end();
84918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  }
85030833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff  unsigned protocol_size() const { return ReferencedProtocols.size(); }
8511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
85238af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner  /// setProtocolList - Set the list of protocols that this interface
853780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  /// implements.
85438af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner  void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num,
85518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor                       const SourceLocation *Locs, ASTContext &C) {
85618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor    ReferencedProtocols.set(List, Num, Locs, C);
857aebf0cba02c014ac8b19d615c654248e0e93779fFariborz Jahanian  }
8581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
85991b0b0cf6b537cbcbca0038c7032f87161a41d31Steve Naroff  ObjCProtocolDecl *lookupProtocolNamed(IdentifierInfo *PName);
8601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
86194a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff  // Lookup a method. First, we search locally. If a method isn't
86294a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff  // found, we search referenced protocols and class categories.
863094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis  ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance) const;
864094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis  ObjCMethodDecl *lookupInstanceMethod(Selector Sel) const {
865094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis    return lookupMethod(Sel, true/*isInstance*/);
866094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis  }
867094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis  ObjCMethodDecl *lookupClassMethod(Selector Sel) const {
868094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis    return lookupMethod(Sel, false/*isInstance*/);
869094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis  }
870d789d3d985e28c9404e62157af46dcb7331920e0Steve Naroff
871768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff  bool isForwardDecl() const { return isForwardProtoDecl; }
872768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff  void setForwardDecl(bool val) { isForwardProtoDecl = val; }
873980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
8741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  // Location information, modeled after the Stmt API.
875423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff  SourceLocation getLocStart() const { return getLocation(); } // '@'protocol
876423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff  SourceLocation getLocEnd() const { return EndLoc; }
8777177dee8aee4b432911c91f1b788963bec0cac9fDaniel Dunbar  void setLocEnd(SourceLocation LE) { EndLoc = LE; }
8781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
87980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
880a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCProtocolDecl *D) { return true; }
88180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCProtocol; }
882980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
8831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
884a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCClassDecl - Specifies a list of forward class declarations. For example:
88506ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff///
88606ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff/// @class NSCursor, NSImage, NSPasteboard, NSWindow;
8870c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
8884afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCClassDecl : public Decl {
889321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenekpublic:
890321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek  class ObjCClassRef {
891321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek    ObjCInterfaceDecl *ID;
892321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek    SourceLocation L;
893321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek  public:
894321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek    ObjCClassRef(ObjCInterfaceDecl *d, SourceLocation l) : ID(d), L(l) {}
895321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek    SourceLocation getLocation() const { return L; }
896321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek    ObjCInterfaceDecl *getInterface() const { return ID; }
897321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek  };
898321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenekprivate:
899321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek  ObjCClassRef *ForwardDecls;
900321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek  unsigned NumDecls;
9011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
9021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ObjCClassDecl(DeclContext *DC, SourceLocation L,
903321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek                ObjCInterfaceDecl *const *Elts, const SourceLocation *Locs,
904321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek                unsigned nElts, ASTContext &C);
90561f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattnerpublic:
906d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCClassDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
9071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                               ObjCInterfaceDecl *const *Elts = 0,
908321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek                               const SourceLocation *Locs = 0,
90930833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff                               unsigned nElts = 0);
9102dbdd622d02d1bfbe1e5bcf421b07b74c7a748f1Ted Kremenek
911da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor  virtual SourceRange getSourceRange() const;
9121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
913321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek  typedef const ObjCClassRef* iterator;
914321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek  iterator begin() const { return ForwardDecls; }
915321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek  iterator end() const { return ForwardDecls + NumDecls; }
916321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek  unsigned size() const { return NumDecls; }
91730833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff
91830833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff  /// setClassList - Set the list of forward classes.
919321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek  void setClassList(ASTContext &C, ObjCInterfaceDecl*const*List,
920321c22f1c4271c3d9a3d4d3fc18847f948ab595bTed Kremenek                    const SourceLocation *Locs, unsigned Num);
9211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
92280cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
923a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCClassDecl *D) { return true; }
92480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCClass; }
92506ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff};
92606ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff
927a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCForwardProtocolDecl - Specifies a list of forward protocol declarations.
92806ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff/// For example:
9291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
9300c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @protocol NSTextInput, NSChangeSpelling, NSDraggingInfo;
9311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
9324afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCForwardProtocolDecl : public Decl {
93318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  ObjCProtocolList ReferencedProtocols;
9341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
935d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L,
93638af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner                          ObjCProtocolDecl *const *Elts, unsigned nElts,
93718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor                          const SourceLocation *Locs, ASTContext &C);
9381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
93961f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattnerpublic:
940d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCForwardProtocolDecl *Create(ASTContext &C, DeclContext *DC,
9411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                         SourceLocation L,
94218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor                                         ObjCProtocolDecl *const *Elts,
94318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor                                         unsigned Num,
94418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor                                         const SourceLocation *Locs);
94518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor
94618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  static ObjCForwardProtocolDecl *Create(ASTContext &C, DeclContext *DC,
94718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor                                         SourceLocation L) {
94818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor    return Create(C, DC, L, 0, 0, 0);
94918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  }
95061f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner
95118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  typedef ObjCProtocolList::iterator protocol_iterator;
95230833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff  protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
95330833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff  protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
95418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  typedef ObjCProtocolList::loc_iterator protocol_loc_iterator;
95518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  protocol_loc_iterator protocol_loc_begin() const {
95618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor    return ReferencedProtocols.loc_begin();
95718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  }
95818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  protocol_loc_iterator protocol_loc_end() const {
95918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor    return ReferencedProtocols.loc_end();
96018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  }
96118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor
96230833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff  unsigned protocol_size() const { return ReferencedProtocols.size(); }
96330833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff
96430833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff  /// setProtocolList - Set the list of forward protocols.
96530833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff  void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num,
96618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor                       const SourceLocation *Locs, ASTContext &C) {
96718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor    ReferencedProtocols.set(List, Num, Locs, C);
96830833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff  }
96980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
970a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCForwardProtocolDecl *D) { return true; }
97180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCForwardProtocol; }
972980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
973980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
974a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCCategoryDecl - Represents a category declaration. A category allows
9750c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// you to add methods to an existing class (without subclassing or modifying
9761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// the original class interface or implementation:-). Categories don't allow
9770c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// you to add instance data. The following example adds "myMethod" to all
9780c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// NSView's within a process:
9790c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
9800c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @interface NSView (MyViewMethods)
9810c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - myMethod;
9820c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end
9830c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
98433ced0b8550f3e7169f326944731ee02e9338659Douglas Gregor/// Categories also allow you to split the implementation of a class across
9850c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// several files (a feature more naturally supported in C++).
9860c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
9870c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Categories were originally inspired by dynamic languages such as Common
9881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// Lisp and Smalltalk.  More traditional class-based languages (C++, Java)
9890c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// don't support this level of dynamism, which is both powerful and dangerous.
9900c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
991e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroffclass ObjCCategoryDecl : public ObjCContainerDecl {
992980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Interface belonging to this category
993a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl *ClassInterface;
9941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
99568c82cf61228102aba1194efef222fa1478af2a8Chris Lattner  /// referenced protocols in this category.
99618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  ObjCProtocolList ReferencedProtocols;
9971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
998a8ff9f455d94d9609766cfd5186b6e21dc2102f1Chris Lattner  /// Next category belonging to this class.
999a8ff9f455d94d9609766cfd5186b6e21dc2102f1Chris Lattner  /// FIXME: this should not be a singly-linked list.  Move storage elsewhere.
1000a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCCategoryDecl *NextClassCategory;
10011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1002000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian  /// true of class extension has at least one bitfield ivar.
1003000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian  bool HasSynthBitfield : 1;
1004000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian
10053db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor  /// \brief The location of the '@' in '@interface'
10063db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor  SourceLocation AtLoc;
10073db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor
10083db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor  /// \brief The location of the category name in this declaration.
10093db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor  SourceLocation CategoryNameLoc;
10101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
10113db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor  ObjCCategoryDecl(DeclContext *DC, SourceLocation AtLoc,
10123db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor                   SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc,
10133db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor                   IdentifierInfo *Id)
10143db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor    : ObjCContainerDecl(ObjCCategory, DC, ClassNameLoc, Id),
1015000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian      ClassInterface(0), NextClassCategory(0), HasSynthBitfield(false),
1016000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian      AtLoc(AtLoc), CategoryNameLoc(CategoryNameLoc) {
1017a906135721c350435319347d2672bbb3bf494f91Chris Lattner  }
101861f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattnerpublic:
10191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1020d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCCategoryDecl *Create(ASTContext &C, DeclContext *DC,
10213db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor                                  SourceLocation AtLoc,
10223db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor                                  SourceLocation ClassNameLoc,
10233db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor                                  SourceLocation CategoryNameLoc,
10243db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor                                  IdentifierInfo *Id);
10251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1026e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  ObjCInterfaceDecl *getClassInterface() { return ClassInterface; }
1027e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
1028a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  void setClassInterface(ObjCInterfaceDecl *IDecl) { ClassInterface = IDecl; }
10298a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis
10308a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis  ObjCCategoryImplDecl *getImplementation() const;
10318a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis  void setImplementation(ObjCCategoryImplDecl *ImplD);
10328a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis
103338af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner  /// setProtocolList - Set the list of protocols that this interface
1034f7b2c98c16dfb2261ea57d40a1d5bc4738e73175Chris Lattner  /// implements.
103538af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner  void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num,
103618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor                       const SourceLocation *Locs, ASTContext &C) {
103718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor    ReferencedProtocols.set(List, Num, Locs, C);
1038780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  }
10391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
104018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  const ObjCProtocolList &getReferencedProtocols() const {
1041780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner    return ReferencedProtocols;
10428f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  }
10431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
104418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  typedef ObjCProtocolList::iterator protocol_iterator;
1045780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
1046780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
104730833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff  unsigned protocol_size() const { return ReferencedProtocols.size(); }
104818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  typedef ObjCProtocolList::loc_iterator protocol_loc_iterator;
104918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  protocol_loc_iterator protocol_loc_begin() const {
105018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor    return ReferencedProtocols.loc_begin();
105118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  }
105218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  protocol_loc_iterator protocol_loc_end() const {
105318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor    return ReferencedProtocols.loc_end();
105418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  }
10551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1056a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCCategoryDecl *getNextClassCategory() const { return NextClassCategory; }
105730833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff  void setNextClassCategory(ObjCCategoryDecl *Cat) {
105830833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff    NextClassCategory = Cat;
105930833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff  }
1060980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void insertNextClassCategory() {
10613d58138992b9bc7b34aaa680f3ddf3971292eb7dSteve Naroff    NextClassCategory = ClassInterface->getCategoryList();
10623d58138992b9bc7b34aaa680f3ddf3971292eb7dSteve Naroff    ClassInterface->setCategoryList(this);
10635e9888c2786bfffa6879a08ff40f5a11545eec23Douglas Gregor    ClassInterface->setChangedSinceDeserialization(true);
1064980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
10653db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor
106625760611365be23556b32332f8a66ae21ea93ecfFariborz Jahanian  bool IsClassExtension() const { return getIdentifier() == 0; }
106780aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian  const ObjCCategoryDecl *getNextClassExtension() const;
106825760611365be23556b32332f8a66ae21ea93ecfFariborz Jahanian
1069000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian  bool hasSynthBitfield() const { return HasSynthBitfield; }
1070000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian  void setHasSynthBitfield (bool val) { HasSynthBitfield = val; }
1071000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian
10720e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator;
10730e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  ivar_iterator ivar_begin() const {
10740e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian    return ivar_iterator(decls_begin());
10750e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  }
10760e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  ivar_iterator ivar_end() const {
10770e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian    return ivar_iterator(decls_end());
10780e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  }
10790e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  unsigned ivar_size() const {
10800e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian    return std::distance(ivar_begin(), ivar_end());
10810e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  }
10820e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  bool ivar_empty() const {
10830e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian    return ivar_begin() == ivar_end();
10840e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  }
10850e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian
10863db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor  SourceLocation getAtLoc() const { return AtLoc; }
10873db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor  void setAtLoc(SourceLocation At) { AtLoc = At; }
10883db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor
10893db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor  SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; }
10903db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor  void setCategoryNameLoc(SourceLocation Loc) { CategoryNameLoc = Loc; }
10913db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor
1092da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor  virtual SourceRange getSourceRange() const {
10933db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor    return SourceRange(AtLoc, getAtEndRange().getEnd());
10943db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor  }
10951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
109680cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1097a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCCategoryDecl *D) { return true; }
109880cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCCategory; }
1099980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
11000c6b6243d3efd958c17943130e2a773653511edcSteve Naroff
1101aecae629269fae3bf484baf1d109e9a89d14eeadArgyrios Kyrtzidisclass ObjCImplDecl : public ObjCContainerDecl {
11020d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff  /// Class interface for this class/category implementation
1103a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl *ClassInterface;
11041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
11053aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattnerprotected:
11063aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  ObjCImplDecl(Kind DK, DeclContext *DC, SourceLocation L,
11073aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner               ObjCInterfaceDecl *classInterface)
11081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    : ObjCContainerDecl(DK, DC, L,
11091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                        classInterface? classInterface->getIdentifier() : 0),
1110aecae629269fae3bf484baf1d109e9a89d14eeadArgyrios Kyrtzidis      ClassInterface(classInterface) {}
11111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
111275c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattnerpublic:
1113e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
1114e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  ObjCInterfaceDecl *getClassInterface() { return ClassInterface; }
11158a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis  void setClassInterface(ObjCInterfaceDecl *IFace);
11162c2d43c557beca1b4ba4bd743f33978aecb46a97Douglas Gregor
11171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  void addInstanceMethod(ObjCMethodDecl *method) {
11182c2d43c557beca1b4ba4bd743f33978aecb46a97Douglas Gregor    // FIXME: Context should be set correctly before we get here.
1119653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor    method->setLexicalDeclContext(this);
11201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    addDecl(method);
1121e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff  }
11221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  void addClassMethod(ObjCMethodDecl *method) {
11232c2d43c557beca1b4ba4bd743f33978aecb46a97Douglas Gregor    // FIXME: Context should be set correctly before we get here.
1124653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor    method->setLexicalDeclContext(this);
11251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    addDecl(method);
112653df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner  }
11271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
112817945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  void addPropertyImplementation(ObjCPropertyImplDecl *property);
11291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
113017945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  ObjCPropertyImplDecl *FindPropertyImplDecl(IdentifierInfo *propertyId) const;
113117945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  ObjCPropertyImplDecl *FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const;
1132653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor
1133653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor  // Iterator access to properties.
1134653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor  typedef specific_decl_iterator<ObjCPropertyImplDecl> propimpl_iterator;
11351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  propimpl_iterator propimpl_begin() const {
113617945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return propimpl_iterator(decls_begin());
1137559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  }
11381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  propimpl_iterator propimpl_end() const {
113917945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return propimpl_iterator(decls_end());
1140559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  }
1141653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor
114280cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1143bfb498d0996ef049efe9476f2802976fd145cd60Argyrios Kyrtzidis  static bool classof(const ObjCImplDecl *D) { return true; }
114480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) {
11459a55591af3e5506b95a9718e15380129fbfc5ebcSean Hunt    return K >= firstObjCImpl && K <= lastObjCImpl;
114680cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  }
11473aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner};
11481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
11491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// ObjCCategoryImplDecl - An object of this class encapsulates a category
11501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// @implementation declaration. If a category class has declaration of a
11511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// property, its implementation must be specified in the category's
11523aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @implementation declaration. Example:
11533aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @interface I @end
11543aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @interface I(CATEGORY)
11553aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner///    @property int p1, d1;
11563aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @end
11573aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @implementation I(CATEGORY)
11583aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner///  @dynamic p1,d1;
11593aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// @end
11603aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner///
11613aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// ObjCCategoryImplDecl
11623aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattnerclass ObjCCategoryImplDecl : public ObjCImplDecl {
11633aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  // Category name
11643aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  IdentifierInfo *Id;
11653aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner
11663aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  ObjCCategoryImplDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
11673aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner                       ObjCInterfaceDecl *classInterface)
11683aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner    : ObjCImplDecl(ObjCCategoryImpl, DC, L, classInterface), Id(Id) {}
11693aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattnerpublic:
11703aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  static ObjCCategoryImplDecl *Create(ASTContext &C, DeclContext *DC,
11713aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner                                      SourceLocation L, IdentifierInfo *Id,
11723aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner                                      ObjCInterfaceDecl *classInterface);
11731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
11740d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff  /// getIdentifier - Get the identifier that names the category
11753aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  /// interface associated with this implementation.
11760d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff  /// FIXME: This is a bad API, we are overriding the NamedDecl::getIdentifier()
11770d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff  /// to mean something different. For example:
11780d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff  /// ((NamedDecl *)SomeCategoryImplDecl)->getIdentifier()
11790d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff  /// returns the class interface name, whereas
11800d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff  /// ((ObjCCategoryImplDecl *)SomeCategoryImplDecl)->getIdentifier()
11810d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff  /// returns the category name.
11821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  IdentifierInfo *getIdentifier() const {
11831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return Id;
11843aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  }
118510b0e1fa3aabd8877dbbc0df1f2414e04afd5fddDouglas Gregor  void setIdentifier(IdentifierInfo *II) { Id = II; }
11861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
11870d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff  ObjCCategoryDecl *getCategoryDecl() const;
118810b0e1fa3aabd8877dbbc0df1f2414e04afd5fddDouglas Gregor
1189b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar  /// getName - Get the name of identifier for the class interface associated
1190b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar  /// with this implementation as a StringRef.
1191b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar  //
1192b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar  // FIXME: This is a bad API, we are overriding the NamedDecl::getName, to mean
1193b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar  // something different.
1194b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar  llvm::StringRef getName() const {
1195b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar    return Id ? Id->getNameStart() : "";
1196b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar  }
1197b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar
11983aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  /// getNameAsCString - Get the name of identifier for the class
11993aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  /// interface associated with this implementation as a C string
12003aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  /// (const char*).
12017fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar  //
1202b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar  // FIXME: Deprecated, move clients to getName().
12033aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  const char *getNameAsCString() const {
12047fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar    return Id ? Id->getNameStart() : "";
12053aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  }
12061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
12073aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  /// @brief Get the name of the class associated with this interface.
12087fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar  //
1209b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar  // FIXME: Deprecated, move clients to getName().
12103aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  std::string getNameAsString() const {
1211b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar    return getName();
12123aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  }
12131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
121480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1215a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCCategoryImplDecl *D) { return true; }
121680cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCCategoryImpl;}
12178f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian};
12188f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
1219900fc6388e803868a34b9483510c345e9b49d7ebBenjamin Kramerllvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
1220900fc6388e803868a34b9483510c345e9b49d7ebBenjamin Kramer                              const ObjCCategoryImplDecl *CID);
1221900fc6388e803868a34b9483510c345e9b49d7ebBenjamin Kramer
1222a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCImplementationDecl - Represents a class definition - this is where
12230c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// method definitions are specified. For example:
12240c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
122598abf4bd3526a00a0e5cf71a9462c181f97b1c81Fariborz Jahanian/// @code
12260c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @implementation MyClass
12270c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (void)myMethod { /* do something */ }
12280c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end
122998abf4bd3526a00a0e5cf71a9462c181f97b1c81Fariborz Jahanian/// @endcode
12300c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
12311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// Typically, instance variables are specified in the class interface,
1232ec0d7a6f4b0699cc9960e6d9fee0f957c64d1cf9Douglas Gregor/// *not* in the implementation. Nevertheless (for legacy reasons), we
123353df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner/// allow instance variables to be specified in the implementation.  When
123453df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner/// specified, they need to be *identical* to the interface.
12350c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
12361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumpclass ObjCImplementationDecl : public ObjCImplDecl {
1237980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Implementation Class's super class.
1238a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl *SuperClass;
1239e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// Support for ivar initialization.
1240e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// IvarInitializers - The arguments used to initialize the ivars
1241cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt  CXXCtorInitializer **IvarInitializers;
1242e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  unsigned NumIvarInitializers;
1243e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian
1244000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian  /// true of class extension has at least one bitfield ivar.
1245000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian  bool HasSynthBitfield : 1;
1246000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian
12471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ObjCImplementationDecl(DeclContext *DC, SourceLocation L,
1248a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek                         ObjCInterfaceDecl *classInterface,
1249a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek                         ObjCInterfaceDecl *superDecl)
12501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    : ObjCImplDecl(ObjCImplementation, DC, L, classInterface),
1251000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian       SuperClass(superDecl), IvarInitializers(0), NumIvarInitializers(0),
1252000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian       HasSynthBitfield(false) {}
12531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumppublic:
12541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static ObjCImplementationDecl *Create(ASTContext &C, DeclContext *DC,
12551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                        SourceLocation L,
125675c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattner                                        ObjCInterfaceDecl *classInterface,
125775c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattner                                        ObjCInterfaceDecl *superDecl);
1258e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian
1259e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// init_iterator - Iterates through the ivar initializer list.
1260cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt  typedef CXXCtorInitializer **init_iterator;
1261e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian
1262e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// init_const_iterator - Iterates through the ivar initializer list.
1263cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt  typedef CXXCtorInitializer * const * init_const_iterator;
1264e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian
1265e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// init_begin() - Retrieve an iterator to the first initializer.
1266e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  init_iterator       init_begin()       { return IvarInitializers; }
1267e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// begin() - Retrieve an iterator to the first initializer.
1268e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  init_const_iterator init_begin() const { return IvarInitializers; }
1269e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian
1270e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// init_end() - Retrieve an iterator past the last initializer.
1271e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  init_iterator       init_end()       {
1272e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian    return IvarInitializers + NumIvarInitializers;
1273e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  }
1274e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// end() - Retrieve an iterator past the last initializer.
1275e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  init_const_iterator init_end() const {
1276e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian    return IvarInitializers + NumIvarInitializers;
1277e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  }
1278e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// getNumArgs - Number of ivars which must be initialized.
1279e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  unsigned getNumIvarInitializers() const {
1280e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian    return NumIvarInitializers;
1281e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  }
1282e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian
1283e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  void setNumIvarInitializers(unsigned numNumIvarInitializers) {
1284e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian    NumIvarInitializers = numNumIvarInitializers;
1285e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  }
1286e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian
1287e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  void setIvarInitializers(ASTContext &C,
1288cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt                           CXXCtorInitializer ** initializers,
1289e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian                           unsigned numInitializers);
1290000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian
1291000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian  bool hasSynthBitfield() const { return HasSynthBitfield; }
1292000835d0b04345c0014c603fe6339b3bc154050eFariborz Jahanian  void setHasSynthBitfield (bool val) { HasSynthBitfield = val; }
1293e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian
12944afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  /// getIdentifier - Get the identifier that names the class
12954afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  /// interface associated with this implementation.
12961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  IdentifierInfo *getIdentifier() const {
12971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return getClassInterface()->getIdentifier();
12984afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  }
12994afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor
1300d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar  /// getName - Get the name of identifier for the class interface associated
1301d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar  /// with this implementation as a StringRef.
1302d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar  //
1303d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar  // FIXME: This is a bad API, we are overriding the NamedDecl::getName, to mean
1304d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar  // something different.
1305d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar  llvm::StringRef getName() const {
1306d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar    assert(getIdentifier() && "Name is not a simple identifier");
1307d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar    return getIdentifier()->getName();
1308d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar  }
1309d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar
13104afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  /// getNameAsCString - Get the name of identifier for the class
13114afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  /// interface associated with this implementation as a C string
13124afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  /// (const char*).
13137fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar  //
13147fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar  // FIXME: Move to StringRef API.
13154afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  const char *getNameAsCString() const {
1316d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar    return getName().data();
13174afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  }
13184afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor
13194afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  /// @brief Get the name of the class associated with this interface.
13207fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar  //
13217fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar  // FIXME: Move to StringRef API.
13224afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  std::string getNameAsString() const {
1323d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar    return getName();
13244afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  }
13254afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor
1326e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  const ObjCInterfaceDecl *getSuperClass() const { return SuperClass; }
1327e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  ObjCInterfaceDecl *getSuperClass() { return SuperClass; }
13281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1329f3a7af901231535191d14cb524d58f22907ac4d2Chris Lattner  void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; }
13301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
13318f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor  typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator;
13321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ivar_iterator ivar_begin() const {
13331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return ivar_iterator(decls_begin());
13348f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor  }
13351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ivar_iterator ivar_end() const {
133617945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return ivar_iterator(decls_end());
13378f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor  }
13381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  unsigned ivar_size() const {
133917945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return std::distance(ivar_begin(), ivar_end());
13408f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor  }
13411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  bool ivar_empty() const {
134217945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return ivar_begin() == ivar_end();
13438f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor  }
13441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
134580cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1346a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCImplementationDecl *D) { return true; }
134780cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCImplementation; }
13489d50c0635fb213b2a1857e3f8488580f0dab2f98Argyrios Kyrtzidis
1349d527cc06d78fe5afa5f20105b51697637eb02c56Sebastian Redl  friend class ASTDeclReader;
13503397c5570369f19b2d6c52e898f708d75ceede1fSebastian Redl  friend class ASTDeclWriter;
1351980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
1352243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian
1353900fc6388e803868a34b9483510c345e9b49d7ebBenjamin Kramerllvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
1354900fc6388e803868a34b9483510c345e9b49d7ebBenjamin Kramer                              const ObjCImplementationDecl *ID);
1355900fc6388e803868a34b9483510c345e9b49d7ebBenjamin Kramer
13561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is
1357243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian/// declared as @compatibility_alias alias class.
13584afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCCompatibleAliasDecl : public NamedDecl {
1359243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian  /// Class that this is an alias of.
1360a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl *AliasedClass;
13611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1362d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCCompatibleAliasDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
1363e8043c39176e7f253fbd92982b077eca6bf2fd59Steve Naroff                          ObjCInterfaceDecl* aliasedClass)
13644afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor    : NamedDecl(ObjCCompatibleAlias, DC, L, Id), AliasedClass(aliasedClass) {}
1365f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattnerpublic:
1366d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCCompatibleAliasDecl *Create(ASTContext &C, DeclContext *DC,
13670ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner                                         SourceLocation L, IdentifierInfo *Id,
1368f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner                                         ObjCInterfaceDecl* aliasedClass);
1369f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner
1370f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner  const ObjCInterfaceDecl *getClassInterface() const { return AliasedClass; }
1371f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner  ObjCInterfaceDecl *getClassInterface() { return AliasedClass; }
137230833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff  void setClassInterface(ObjCInterfaceDecl *D) { AliasedClass = D; }
13731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
137480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1375a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCCompatibleAliasDecl *D) { return true; }
137680cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCCompatibleAlias; }
13771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1378243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian};
13791de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian
13801de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian/// ObjCPropertyDecl - Represents one property declaration in an interface.
13811de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian/// For example:
13821de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian/// @property (assign, readwrite) int MyProperty;
13831de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian///
13844afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCPropertyDecl : public NamedDecl {
138582a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanianpublic:
1386a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner  enum PropertyAttributeKind {
13871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    OBJC_PR_noattr    = 0x00,
13881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    OBJC_PR_readonly  = 0x01,
1389a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    OBJC_PR_getter    = 0x02,
13901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    OBJC_PR_assign    = 0x04,
13911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    OBJC_PR_readwrite = 0x08,
1392a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    OBJC_PR_retain    = 0x10,
13931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    OBJC_PR_copy      = 0x20,
1394a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    OBJC_PR_nonatomic = 0x40,
139545937ae10a0f70f74508165aab4f2b63e18ea747Fariborz Jahanian    OBJC_PR_setter    = 0x80,
139645937ae10a0f70f74508165aab4f2b63e18ea747Fariborz Jahanian    OBJC_PR_atomic    = 0x100
1397a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner  };
1398af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar
1399af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  enum SetterKind { Assign, Retain, Copy };
140046b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  enum PropertyControl { None, Required, Optional };
140182a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanianprivate:
1402d8265b838360578032020757d9a2a84c86457edcFariborz Jahanian  SourceLocation AtLoc;   // location of @property
140383a230c83a54190366138c1a4f4310ef838b88fcJohn McCall  TypeSourceInfo *DeclType;
1404dd4430e596fac34e9ce44228a249f71e73effd4aFariborz Jahanian  unsigned PropertyAttributes : 9;
1405dd4430e596fac34e9ce44228a249f71e73effd4aFariborz Jahanian  unsigned PropertyAttributesAsWritten : 9;
140646b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  // @required/@optional
140746b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  unsigned PropertyImplementation : 2;
14081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
14095251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  Selector GetterName;    // getter name of NULL if no getter
14105251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  Selector SetterName;    // setter name of NULL if no setter
14111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
141233de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  ObjCMethodDecl *GetterMethodDecl; // Declaration of getter instance method
141333de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  ObjCMethodDecl *SetterMethodDecl; // Declaration of setter instance method
1414af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian  ObjCIvarDecl *PropertyIvarDecl;   // Synthesize ivar for this property
141533de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian
14161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
141783a230c83a54190366138c1a4f4310ef838b88fcJohn McCall                   SourceLocation AtLocation, TypeSourceInfo *T)
1418d0502407c1b41b2ace326f355d7b7a6876246223Fariborz Jahanian    : NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation), DeclType(T),
141980aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian      PropertyAttributes(OBJC_PR_noattr),
142080aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian      PropertyAttributesAsWritten(OBJC_PR_noattr),
142180aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian      PropertyImplementation(None),
14221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      GetterName(Selector()),
142333de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian      SetterName(Selector()),
1424af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian      GetterMethodDecl(0), SetterMethodDecl(0) , PropertyIvarDecl(0) {}
1425f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattnerpublic:
14261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC,
14271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                  SourceLocation L,
1428d0502407c1b41b2ace326f355d7b7a6876246223Fariborz Jahanian                                  IdentifierInfo *Id, SourceLocation AtLocation,
142983a230c83a54190366138c1a4f4310ef838b88fcJohn McCall                                  TypeSourceInfo *T,
143046b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian                                  PropertyControl propControl = None);
1431d0502407c1b41b2ace326f355d7b7a6876246223Fariborz Jahanian  SourceLocation getAtLoc() const { return AtLoc; }
1432d0502407c1b41b2ace326f355d7b7a6876246223Fariborz Jahanian  void setAtLoc(SourceLocation L) { AtLoc = L; }
1433d0502407c1b41b2ace326f355d7b7a6876246223Fariborz Jahanian
143483a230c83a54190366138c1a4f4310ef838b88fcJohn McCall  TypeSourceInfo *getTypeSourceInfo() const { return DeclType; }
143583a230c83a54190366138c1a4f4310ef838b88fcJohn McCall  QualType getType() const { return DeclType->getType(); }
143683a230c83a54190366138c1a4f4310ef838b88fcJohn McCall  void setType(TypeSourceInfo *T) { DeclType = T; }
143770e5a14c6076d63833c62d1d6d628c26309897c1Douglas Gregor
1438a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner  PropertyAttributeKind getPropertyAttributes() const {
1439f4af5154571e0c5eadb19df10e65464766ef6683Chris Lattner    return PropertyAttributeKind(PropertyAttributes);
1440f4af5154571e0c5eadb19df10e65464766ef6683Chris Lattner  }
14411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  void setPropertyAttributes(PropertyAttributeKind PRVal) {
1442a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    PropertyAttributes |= PRVal;
144382a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian  }
1444394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar
144580aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian  PropertyAttributeKind getPropertyAttributesAsWritten() const {
144680aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian    return PropertyAttributeKind(PropertyAttributesAsWritten);
144780aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian  }
144880aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian
144980aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian  void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal) {
145080aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian    PropertyAttributesAsWritten = PRVal;
145180aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian  }
145280aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian
14538cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian void makeitReadWriteAttribute(void) {
14548cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian    PropertyAttributes &= ~OBJC_PR_readonly;
14558cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian    PropertyAttributes |= OBJC_PR_readwrite;
14561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump }
14578cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian
1458af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  // Helper methods for accessing attributes.
1459af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar
1460af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  /// isReadOnly - Return true iff the property has a setter.
1461394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar  bool isReadOnly() const {
1462394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar    return (PropertyAttributes & OBJC_PR_readonly);
1463394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar  }
1464af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar
1465af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  /// getSetterKind - Return the method used for doing assignment in
1466af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  /// the property setter. This is only valid if the property has been
1467af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  /// defined to have a setter.
1468af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  SetterKind getSetterKind() const {
1469af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar    if (PropertyAttributes & OBJC_PR_retain)
1470af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar      return Retain;
1471af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar    if (PropertyAttributes & OBJC_PR_copy)
1472af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar      return Copy;
1473af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar    return Assign;
1474af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  }
1475af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar
14765251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  Selector getGetterName() const { return GetterName; }
14775251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  void setGetterName(Selector Sel) { GetterName = Sel; }
14781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
14795251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  Selector getSetterName() const { return SetterName; }
14805251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  void setSetterName(Selector Sel) { SetterName = Sel; }
14811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
148233de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  ObjCMethodDecl *getGetterMethodDecl() const { return GetterMethodDecl; }
148333de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  void setGetterMethodDecl(ObjCMethodDecl *gDecl) { GetterMethodDecl = gDecl; }
148433de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian
148533de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  ObjCMethodDecl *getSetterMethodDecl() const { return SetterMethodDecl; }
148633de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  void setSetterMethodDecl(ObjCMethodDecl *gDecl) { SetterMethodDecl = gDecl; }
14871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
148846b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  // Related to @optional/@required declared in @protocol
148946b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  void setPropertyImplementation(PropertyControl pc) {
149046b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian    PropertyImplementation = pc;
149146b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  }
149246b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  PropertyControl getPropertyImplementation() const {
149346b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian    return PropertyControl(PropertyImplementation);
14941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  }
14951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1496af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian  void setPropertyIvarDecl(ObjCIvarDecl *Ivar) {
1497af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian    PropertyIvarDecl = Ivar;
1498af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian  }
1499af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian  ObjCIvarDecl *getPropertyIvarDecl() const {
1500af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian    return PropertyIvarDecl;
1501af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian  }
15021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1503da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor  virtual SourceRange getSourceRange() const {
1504e3c60a7ce9e0f42c7ca2344b33203266aceca1dbDouglas Gregor    return SourceRange(AtLoc, getLocation());
1505e3c60a7ce9e0f42c7ca2344b33203266aceca1dbDouglas Gregor  }
1506e3c60a7ce9e0f42c7ca2344b33203266aceca1dbDouglas Gregor
15079f550ff05d496e6b9480e5619a21d9da0c9e27c1Ted Kremenek  /// Lookup a property by name in the specified DeclContext.
1508de09d0c9694f01a99870a8825266d44a29ebb325Ted Kremenek  static ObjCPropertyDecl *findPropertyDecl(const DeclContext *DC,
15099f550ff05d496e6b9480e5619a21d9da0c9e27c1Ted Kremenek                                            IdentifierInfo *propertyID);
15109f550ff05d496e6b9480e5619a21d9da0c9e27c1Ted Kremenek
151180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1512a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCPropertyDecl *D) { return true; }
151380cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCProperty; }
151482a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian};
1515980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
15161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// ObjCPropertyImplDecl - Represents implementation declaration of a property
151761d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian/// in a class or category implementation block. For example:
151861d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian/// @synthesize prop1 = ivar1;
151961d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian///
15204afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCPropertyImplDecl : public Decl {
152161d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanianpublic:
15229f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar  enum Kind {
15239f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar    Synthesize,
15249f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar    Dynamic
152561d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  };
152661d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanianprivate:
1527559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  SourceLocation AtLoc;   // location of @synthesize or @dynamic
1528a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor
1529a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  /// \brief For @synthesize, the location of the ivar, if it was written in
1530a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  /// the source code.
1531a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  ///
1532a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  /// \code
1533a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  /// @synthesize int a = b
1534a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  /// \endcode
1535a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  SourceLocation IvarLoc;
1536a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor
153761d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  /// Property declaration being implemented
153861d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  ObjCPropertyDecl *PropertyDecl;
1539be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek
154061d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  /// Null for @dynamic. Required for @synthesize.
154161d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  ObjCIvarDecl *PropertyIvarDecl;
154217cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian
154317cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  /// Null for @dynamic. Non-null if property must be copy-constructed in getter
154417cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  Expr *GetterCXXConstructor;
154517cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian
154617cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  /// Null for @dynamic. Non-null if property has assignment operator to call
154717cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  /// in Setter synthesis.
154817cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  Expr *SetterCXXAssignment;
1549be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek
1550d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCPropertyImplDecl(DeclContext *DC, SourceLocation atLoc, SourceLocation L,
15511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                       ObjCPropertyDecl *property,
15521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                       Kind PK,
1553a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor                       ObjCIvarDecl *ivarDecl,
1554a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor                       SourceLocation ivarLoc)
15551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    : Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc),
1556a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor      IvarLoc(ivarLoc), PropertyDecl(property), PropertyIvarDecl(ivarDecl),
155717cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian      GetterCXXConstructor(0), SetterCXXAssignment(0) {
15589f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar    assert (PK == Dynamic || PropertyIvarDecl);
15599f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar  }
15601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
15619f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbarpublic:
1562d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCPropertyImplDecl *Create(ASTContext &C, DeclContext *DC,
15631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                      SourceLocation atLoc, SourceLocation L,
15641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                      ObjCPropertyDecl *property,
15651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                      Kind PK,
1566a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor                                      ObjCIvarDecl *ivarDecl,
1567a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor                                      SourceLocation ivarLoc);
156861d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian
1569da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor  virtual SourceRange getSourceRange() const;
1570a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor
1571d40910b581b09c937a8c1fdcde9b8ec724398fb9Steve Naroff  SourceLocation getLocStart() const { return AtLoc; }
15728818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor  void setAtLoc(SourceLocation Loc) { AtLoc = Loc; }
1573d40910b581b09c937a8c1fdcde9b8ec724398fb9Steve Naroff
1574be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek  ObjCPropertyDecl *getPropertyDecl() const {
1575be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek    return PropertyDecl;
1576be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek  }
15778818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor  void setPropertyDecl(ObjCPropertyDecl *Prop) { PropertyDecl = Prop; }
15788818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor
15799f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar  Kind getPropertyImplementation() const {
15809f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar    return PropertyIvarDecl ? Synthesize : Dynamic;
1581be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek  }
15821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1583af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  ObjCIvarDecl *getPropertyIvarDecl() const {
1584be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek    return PropertyIvarDecl;
1585be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek  }
1586a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  SourceLocation getPropertyIvarDeclLoc() const { return IvarLoc; }
1587a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor
1588a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  void setPropertyIvarDecl(ObjCIvarDecl *Ivar,
1589a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor                           SourceLocation IvarLoc) {
1590a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor    PropertyIvarDecl = Ivar;
1591a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor    this->IvarLoc = IvarLoc;
1592a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  }
159317cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian
159417cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  Expr *getGetterCXXConstructor() const {
159517cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian    return GetterCXXConstructor;
159617cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  }
159717cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  void setGetterCXXConstructor(Expr *getterCXXConstructor) {
159817cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian    GetterCXXConstructor = getterCXXConstructor;
159917cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  }
16008818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor
160117cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  Expr *getSetterCXXAssignment() const {
160217cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian    return SetterCXXAssignment;
160317cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  }
160417cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  void setSetterCXXAssignment(Expr *setterCXXAssignment) {
160517cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian    SetterCXXAssignment = setterCXXAssignment;
160617cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  }
160717cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian
160880cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
16091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const ObjCPropertyImplDecl *D) { return true; }
161080cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Decl::Kind K) { return K == ObjCPropertyImpl; }
1611a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor
1612a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  friend class ASTDeclReader;
161361d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian};
161461d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian
1615980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}  // end namespace clang
1616980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#endif
1617