DeclObjC.h revision 0b7ebb3dba0df0a6cbf221e5edbc6a4b8848478c
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"
18c7229c338c21ef26b01ef3ecf9eec4fd373fa9ecChris Lattner#include "clang/Basic/IdentifierTable.h"
19b85cce6498c8c1c20f701571d85a3b2fe53338ebFariborz Jahanian#include "llvm/ADT/DenseMap.h"
20980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
21980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffnamespace clang {
22980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass Expr;
23980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass Stmt;
24980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass FunctionDecl;
25980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass AttributeList;
2660f8c868ffb346b78451a3eccaecd0461d2ae498Fariborz Jahanianclass RecordDecl;
27a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCIvarDecl;
28a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCMethodDecl;
29a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCProtocolDecl;
30a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCCategoryDecl;
31a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCPropertyDecl;
32f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanianclass ObjCPropertyImplDecl;
333db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner
343db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner
353db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner/// ObjCList - This is a simple template class used to hold various lists of
363db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner/// decls etc, which is heavily used by the ObjC front-end.  This only use case
373db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner/// this supports is setting the list all at once and then reading elements out
383db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner/// of it.
393db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattnertemplate <typename T>
403db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattnerclass ObjCList {
413db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  /// List is a new[]'d array of pointers to objects that are not owned by this
423db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  /// list.
433db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  T **List;
443db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  unsigned NumElts;
453db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner
463db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  void operator=(const ObjCList &); // DO NOT IMPLEMENT
473db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  ObjCList(const ObjCList&);        // DO NOT IMPLEMENT
483db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattnerpublic:
493db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  ObjCList() : List(0), NumElts(0) {}
503db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  ~ObjCList() {
513db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner    delete[] List;
523db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  }
533db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner
543db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  void set(T* const* InList, unsigned Elts) {
553db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner    assert(List == 0 && "Elements already set!");
563db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner    List = new T*[Elts];
573db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner    NumElts = Elts;
583db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner    memcpy(List, InList, sizeof(T*)*Elts);
593db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  }
603db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner
613db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  typedef T* const * iterator;
623db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  iterator begin() const { return List; }
633db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  iterator end() const { return List+NumElts; }
643db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner
653db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  unsigned size() const { return NumElts; }
663db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  bool empty() const { return NumElts == 0; }
673db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner
68780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  T* operator[](unsigned idx) const {
693db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner    assert(idx < NumElts && "Invalid access");
703db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner    return List[idx];
713db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  }
723db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner};
733db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner
743db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner
7558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
76a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCMethodDecl - Represents an instance or class method declaration.
7758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// ObjC methods can be declared within 4 contexts: class interfaces,
7858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// categories, protocols, and class implementations. While C++ member
7958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// functions leverage C syntax, Objective-C method syntax is modeled after
8058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Smalltalk (using colons to specify argument types/expressions).
8158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Here are some brief examples:
8258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff///
8358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Setter/getter instance methods:
8458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// - (void)setMenu:(NSMenu *)menu;
8558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// - (NSMenu *)menu;
8658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff///
8758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Instance method that takes 2 NSView arguments:
8858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// - (void)replaceSubview:(NSView *)oldView with:(NSView *)newView;
8958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff///
9058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Getter class method:
9158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// + (NSMenu *)defaultMenu;
9258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff///
9358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// A selector represents a unique name for a method. The selector names for
9458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// the above methods are setMenu:, menu, replaceSubview:with:, and defaultMenu.
9558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff///
964afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCMethodDecl : public NamedDecl, public DeclContext {
9758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroffpublic:
9858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  enum ImplementationControl { None, Required, Optional };
9958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroffprivate:
10058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  /// Bitfields must be first fields in this class so they pack with those
10158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  /// declared in class Decl.
10258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  /// instance (true) or class (false) method.
10358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  bool IsInstance : 1;
10458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  bool IsVariadic : 1;
10558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
1064607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian  // Synthesized declaration method for a property setter/getter
1074607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian  bool IsSynthesized : 1;
1084607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian
109ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  // NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum
11058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  /// @required/@optional
111ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  unsigned DeclImplementation : 2;
11258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
113ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  // NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum
11458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  /// in, inout, etc.
115ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  unsigned objcDeclQualifier : 6;
11658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
11758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  // Type of this method.
11858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  QualType MethodDeclType;
11958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  /// ParamInfo - new[]'d array of pointers to VarDecls for the formal
12058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  /// parameters of this Method.  This is null if there are no formals.
12158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  ParmVarDecl **ParamInfo;
12258cce3b0dcbdcc95b7e713795834b4cb2c8a008aChris Lattner  unsigned NumMethodParams;
12358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
12458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  /// List of attributes for this method declaration.
12558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  SourceLocation EndLoc; // the location of the ';' or '{'.
12658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
12758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  // The following are only used for method definitions, null otherwise.
12858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  // FIXME: space savings opportunity, consider a sub-class.
12958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  Stmt *Body;
130451318c08a6342c10b8986060386fd9274418437Daniel Dunbar
131451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// SelfDecl - Decl for the implicit self parameter. This is lazily
132451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// constructed by createImplicitParams.
1334111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner  ImplicitParamDecl *SelfDecl;
134451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// CmdDecl - Decl for the implicit _cmd parameter. This is lazily
135451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// constructed by createImplicitParams.
1364111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner  ImplicitParamDecl *CmdDecl;
1376c4ae5de0c356777446f823b573821fb95560d91Chris Lattner
138a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc,
13958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff                 Selector SelInfo, QualType T,
1400701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff                 DeclContext *contextDecl,
141f6414927e67e27d9324d8d179c5f7ea620443924Daniel Dunbar                 bool isInstance = true,
14258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff                 bool isVariadic = false,
1434607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian                 bool isSynthesized = false,
14458cce3b0dcbdcc95b7e713795834b4cb2c8a008aChris Lattner                 ImplementationControl impControl = None)
1454afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  : NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo),
146b048c9835969c4f7fe06264748be18ed4b442116Chris Lattner    DeclContext(ObjCMethod),
14758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff    IsInstance(isInstance), IsVariadic(isVariadic),
1484607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian    IsSynthesized(isSynthesized),
14958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff    DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None),
1502e1cd4264d363ca869bf37ef160902f211d21b8cDouglas Gregor    MethodDeclType(T),
151f6414927e67e27d9324d8d179c5f7ea620443924Daniel Dunbar    ParamInfo(0), NumMethodParams(0),
1524111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner    EndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) {}
1538a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek
154411280e5b25ba7dcd7c8a82a5c23880fe7632a3cChris Lattner  virtual ~ObjCMethodDecl() {
155411280e5b25ba7dcd7c8a82a5c23880fe7632a3cChris Lattner    assert(ParamInfo == 0 && "Destroy not called?");
156411280e5b25ba7dcd7c8a82a5c23880fe7632a3cChris Lattner  }
1571c8a413c1e00636c77666ddf1e3b0311f3fa8c81Ted Kremenek
1586c4ae5de0c356777446f823b573821fb95560d91Chris Lattnerpublic:
1598a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek
1608a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek  /// Destroy - Call destructors and release memory.
1618a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek  virtual void Destroy(ASTContext& C);
1626c4ae5de0c356777446f823b573821fb95560d91Chris Lattner
1630ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner  static ObjCMethodDecl *Create(ASTContext &C,
1640ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner                                SourceLocation beginLoc,
1656c4ae5de0c356777446f823b573821fb95560d91Chris Lattner                                SourceLocation endLoc, Selector SelInfo,
1660701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff                                QualType T, DeclContext *contextDecl,
167f6414927e67e27d9324d8d179c5f7ea620443924Daniel Dunbar                                bool isInstance = true,
1686c4ae5de0c356777446f823b573821fb95560d91Chris Lattner                                bool isVariadic = false,
1694607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian                                bool isSynthesized = false,
170b06fa3b86951b9f179c99c3768331536c32e902dChris Lattner                                ImplementationControl impControl = None);
17158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
172ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  ObjCDeclQualifier getObjCDeclQualifier() const {
173ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek    return ObjCDeclQualifier(objcDeclQualifier);
174ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  }
175a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  void setObjCDeclQualifier(ObjCDeclQualifier QV) { objcDeclQualifier = QV; }
17658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
17758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  // Location information, modeled after the Stmt API.
17858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  SourceLocation getLocStart() const { return getLocation(); }
17958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  SourceLocation getLocEnd() const { return EndLoc; }
1809776ba0d844cf9f6888e871e3fd246ae782f76f4Daniel Dunbar  SourceRange getSourceRange() const {
1819776ba0d844cf9f6888e871e3fd246ae782f76f4Daniel Dunbar    return SourceRange(getLocation(), EndLoc);
1829776ba0d844cf9f6888e871e3fd246ae782f76f4Daniel Dunbar  }
1833e0a540b6d846178857289ec0eb8470a278d11a3Steve Naroff
1845619688510185081cbb4621d703daf7ee24cf39aChris Lattner  ObjCInterfaceDecl *getClassInterface();
1855619688510185081cbb4621d703daf7ee24cf39aChris Lattner  const ObjCInterfaceDecl *getClassInterface() const {
1865619688510185081cbb4621d703daf7ee24cf39aChris Lattner    return const_cast<ObjCMethodDecl*>(this)->getClassInterface();
187e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  }
18858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
1892e1cd4264d363ca869bf37ef160902f211d21b8cDouglas Gregor  Selector getSelector() const { return getDeclName().getObjCSelector(); }
190faf5e779d16bb4590f2a97e1c7ded255eddd90f3Fariborz Jahanian  unsigned getSynthesizedMethodSize() const;
19158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  QualType getResultType() const { return MethodDeclType; }
19258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
193d57f635d520e8cb5b93d3d770ff58db06c62de54Chris Lattner  // Iterator access to formal parameters.
19458cce3b0dcbdcc95b7e713795834b4cb2c8a008aChris Lattner  unsigned param_size() const { return NumMethodParams; }
195d57f635d520e8cb5b93d3d770ff58db06c62de54Chris Lattner  typedef ParmVarDecl **param_iterator;
196d57f635d520e8cb5b93d3d770ff58db06c62de54Chris Lattner  typedef ParmVarDecl * const *param_const_iterator;
197d57f635d520e8cb5b93d3d770ff58db06c62de54Chris Lattner  param_iterator param_begin() { return ParamInfo; }
198d57f635d520e8cb5b93d3d770ff58db06c62de54Chris Lattner  param_iterator param_end() { return ParamInfo+param_size(); }
199d57f635d520e8cb5b93d3d770ff58db06c62de54Chris Lattner  param_const_iterator param_begin() const { return ParamInfo; }
200d57f635d520e8cb5b93d3d770ff58db06c62de54Chris Lattner  param_const_iterator param_end() const { return ParamInfo+param_size(); }
201d57f635d520e8cb5b93d3d770ff58db06c62de54Chris Lattner
20258cce3b0dcbdcc95b7e713795834b4cb2c8a008aChris Lattner  unsigned getNumParams() const { return NumMethodParams; }
20358cce3b0dcbdcc95b7e713795834b4cb2c8a008aChris Lattner  ParmVarDecl *getParamDecl(unsigned i) const {
20458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff    assert(i < getNumParams() && "Illegal param #");
20558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff    return ParamInfo[i];
20658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  }
2072338d58a905191c4205d4f73affd0bdaa13493b4Fariborz Jahanian  void setParamDecl(int i, ParmVarDecl *pDecl) {
2082338d58a905191c4205d4f73affd0bdaa13493b4Fariborz Jahanian    ParamInfo[i] = pDecl;
2092338d58a905191c4205d4f73affd0bdaa13493b4Fariborz Jahanian  }
21058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  void setMethodParams(ParmVarDecl **NewParamInfo, unsigned NumParams);
2114111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner
212451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// createImplicitParams - Used to lazily create the self and cmd
213451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// implict parameters. This must be called prior to using getSelfDecl()
214451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// or getCmdDecl(). The call is ignored if the implicit paramters
215451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// have already been created.
216fef30b55230064d334a669a065a1c9acdb87cdfeFariborz Jahanian  void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID);
217451318c08a6342c10b8986060386fd9274418437Daniel Dunbar
2184111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner  ImplicitParamDecl * getSelfDecl() const { return SelfDecl; }
2194111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner  ImplicitParamDecl * getCmdDecl() const { return CmdDecl; }
22058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
221f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor  bool isInstanceMethod() const { return IsInstance; }
22258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  bool isVariadic() const { return IsVariadic; }
22358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
224f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor  bool isClassMethod() const { return !IsInstance; }
225f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor
2264607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian  bool isSynthesized() const { return IsSynthesized; }
22791b51a92f2e9fc8025b6a9df88442840eb62823aFariborz Jahanian  void setIsSynthesized() { IsSynthesized = true; }
2284607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian
22958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  // Related to protocols declared in  @protocol
23058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  void setDeclImplementation(ImplementationControl ic) {
23158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff    DeclImplementation = ic;
23258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  }
23358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  ImplementationControl getImplementationControl() const {
234ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek    return ImplementationControl(DeclImplementation);
23558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  }
236792481eec23d8c1aa92173be589e2ae9d02514a5Ted Kremenek
23769c8f0aab655257e9e532d9d53756acf4f7a2d78Ted Kremenek  virtual Stmt *getBody() const { return Body; }
23858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  void setBody(Stmt *B) { Body = B; }
23958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
24058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  // Implement isa/cast/dyncast/etc.
241a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const Decl *D) { return D->getKind() == ObjCMethod; }
242a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCMethodDecl *D) { return true; }
24342220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis  static DeclContext *castToDeclContext(const ObjCMethodDecl *D) {
24442220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis    return static_cast<DeclContext *>(const_cast<ObjCMethodDecl*>(D));
24542220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis  }
24642220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis  static ObjCMethodDecl *castFromDeclContext(const DeclContext *DC) {
24742220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis    return static_cast<ObjCMethodDecl *>(const_cast<DeclContext*>(DC));
24842220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis  }
24958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff};
250e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
251e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff/// ObjCContainerDecl - Represents a container for method declarations.
252e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff/// Current sub-classes are ObjCInterfaceDecl, ObjCCategoryDecl, and
2530701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff/// ObjCProtocolDecl.
2540701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff/// FIXME: Use for ObjC implementation decls.
255e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff///
2564afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCContainerDecl : public NamedDecl, public DeclContext {
257e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff  SourceLocation AtEndLoc; // marks the end of the method container.
258e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroffpublic:
259e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
260d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCContainerDecl(Kind DK, DeclContext *DC, SourceLocation L,
261d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor                    IdentifierInfo *Id)
2624afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor    : NamedDecl(DK, DC, L, Id), DeclContext(DK) {}
263e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
2640b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner  virtual ~ObjCContainerDecl() {}
26509c4719788a5cea09897525e528fa00420f1677bSteve Naroff
26693983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff  // Iterator access to properties.
26793983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff  typedef specific_decl_iterator<ObjCPropertyDecl> prop_iterator;
26893983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff  prop_iterator prop_begin() const {
269d6f0b4e97e681ea5d165125960f34b3b8c19e1dcDouglas Gregor    return prop_iterator(decls_begin());
27093983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff  }
27193983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff  prop_iterator prop_end() const {
272d6f0b4e97e681ea5d165125960f34b3b8c19e1dcDouglas Gregor    return prop_iterator(decls_end());
27309c4719788a5cea09897525e528fa00420f1677bSteve Naroff  }
27409c4719788a5cea09897525e528fa00420f1677bSteve Naroff
2750701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  // Iterator access to instance/class methods.
276f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor  typedef specific_decl_iterator<ObjCMethodDecl> method_iterator;
277f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor  method_iterator meth_begin() const {
278d6f0b4e97e681ea5d165125960f34b3b8c19e1dcDouglas Gregor    return method_iterator(decls_begin());
2797ed4faca5162b3ab85be7f7e57aa40e6ec170971Ted Kremenek  }
280f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor  method_iterator meth_end() const {
281d6f0b4e97e681ea5d165125960f34b3b8c19e1dcDouglas Gregor    return method_iterator(decls_end());
2827ed4faca5162b3ab85be7f7e57aa40e6ec170971Ted Kremenek  }
2830701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff
284669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor  typedef filtered_decl_iterator<ObjCMethodDecl,
285669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor                                 &ObjCMethodDecl::isInstanceMethod>
286669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor    instmeth_iterator;
2870701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  instmeth_iterator instmeth_begin() const {
288669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor    return instmeth_iterator(decls_begin());
289e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff  }
2900701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  instmeth_iterator instmeth_end() const {
291669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor    return instmeth_iterator(decls_end());
292e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff  }
293e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
294669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor  typedef filtered_decl_iterator<ObjCMethodDecl,
295669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor                                 &ObjCMethodDecl::isClassMethod>
296669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor    classmeth_iterator;
2970701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  classmeth_iterator classmeth_begin() const {
298669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor    return classmeth_iterator(decls_begin());
299e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff  }
3000701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  classmeth_iterator classmeth_end() const {
301669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor    return classmeth_iterator(decls_end());
3020701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  }
3030701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff
3040701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  // Get the local instance/class method declared in this interface.
3050701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  ObjCMethodDecl *getInstanceMethod(Selector Sel) const;
3060701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  ObjCMethodDecl *getClassMethod(Selector Sel) const;
30753df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner  ObjCMethodDecl *getMethod(Selector Sel, bool isInstance) const {
30853df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner    return isInstance ? getInstanceMethod(Sel) : getClassMethod(Sel);
30953df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner  }
3106327e0d55c590b3c2766fa76ef1db241a0467df2Steve Naroff
31193983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff  ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const;
31293983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff
3136327e0d55c590b3c2766fa76ef1db241a0467df2Steve Naroff  // Get the number of methods, properties. These methods are slow, O(n).
3140701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  unsigned getNumInstanceMethods() const;
3150701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  unsigned getNumClassMethods() const;
3166327e0d55c590b3c2766fa76ef1db241a0467df2Steve Naroff  unsigned getNumProperties() const;
317b245a33e6f562377946dc9cb5694a2d3cb8a98a3Fariborz Jahanian
318e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff  // Marks the end of the container.
319e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff  SourceLocation getAtEndLoc() const { return AtEndLoc; }
3200701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  void setAtEndLoc(SourceLocation L) { AtEndLoc = L; }
32109c4719788a5cea09897525e528fa00420f1677bSteve Naroff
32209c4719788a5cea09897525e528fa00420f1677bSteve Naroff  // Implement isa/cast/dyncast/etc.
32309c4719788a5cea09897525e528fa00420f1677bSteve Naroff  static bool classof(const Decl *D) {
32409c4719788a5cea09897525e528fa00420f1677bSteve Naroff    return D->getKind() >= ObjCContainerFirst &&
32509c4719788a5cea09897525e528fa00420f1677bSteve Naroff           D->getKind() <= ObjCContainerLast;
32609c4719788a5cea09897525e528fa00420f1677bSteve Naroff  }
32709c4719788a5cea09897525e528fa00420f1677bSteve Naroff  static bool classof(const ObjCContainerDecl *D) { return true; }
32809c4719788a5cea09897525e528fa00420f1677bSteve Naroff
32909c4719788a5cea09897525e528fa00420f1677bSteve Naroff  static DeclContext *castToDeclContext(const ObjCContainerDecl *D) {
33009c4719788a5cea09897525e528fa00420f1677bSteve Naroff    return static_cast<DeclContext *>(const_cast<ObjCContainerDecl*>(D));
33109c4719788a5cea09897525e528fa00420f1677bSteve Naroff  }
33209c4719788a5cea09897525e528fa00420f1677bSteve Naroff  static ObjCContainerDecl *castFromDeclContext(const DeclContext *DC) {
33309c4719788a5cea09897525e528fa00420f1677bSteve Naroff    return static_cast<ObjCContainerDecl *>(const_cast<DeclContext*>(DC));
33409c4719788a5cea09897525e528fa00420f1677bSteve Naroff  }
335e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff};
336e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
337a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCInterfaceDecl - Represents an ObjC class declaration. For example:
3380c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
3390c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   // MostPrimitive declares no super class (not particularly useful).
3400c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @interface MostPrimitive
3410c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     // no instance variables or methods.
3420c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @end
3430c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
344fd5de471478a507dd2495c4ea9bcab801ea5fa65Chris Lattner///   // NSResponder inherits from NSObject & implements NSCoding (a protocol).
3450c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @interface NSResponder : NSObject <NSCoding>
346a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek///   { // instance variables are represented by ObjCIvarDecl.
3470c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id nextResponder; // nextResponder instance variable.
3480c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   }
3490c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   - (NSResponder *)nextResponder; // return a pointer to NSResponder.
3500c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   - (void)mouseMoved:(NSEvent *)theEvent; // return void, takes a pointer
3510c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @end                                    // to an NSEvent.
3520c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
3530c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   Unlike C/C++, forward class declarations are accomplished with @class.
3540c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   Unlike C/C++, @class allows for a list of classes to be forward declared.
3550c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   Unlike C++, ObjC is a single-rooted class model. In Cocoa, classes
3560c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   typically inherit from NSObject (an exception is NSProxy).
3570c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
3580701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroffclass ObjCInterfaceDecl : public ObjCContainerDecl {
3593110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff  /// TypeForDecl - This indicates the Type object that represents this
3603110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff  /// TypeDecl.  It is a cache maintained by ASTContext::getObjCInterfaceType
3613110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff  Type *TypeForDecl;
3623110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff  friend class ASTContext;
363980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
364980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Class's super class.
365a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl *SuperClass;
366980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
367980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Protocols referenced in interface header declaration
3683db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  ObjCList<ObjCProtocolDecl> ReferencedProtocols;
369980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
370980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Ivars/NumIvars - This is a new[]'d array of pointers to Decls.
371a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCIvarDecl **Ivars;   // Null if not defined.
372f3a7af901231535191d14cb524d58f22907ac4d2Chris Lattner  unsigned NumIvars;      // 0 if none.
373980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
374980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// List of categories defined for this class.
375a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCCategoryDecl *CategoryList;
37682a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian
3773a3ca1b35a7121aea0bf465a192dce748465e10fFariborz Jahanian  bool ForwardDecl:1; // declared with @class.
3783a3ca1b35a7121aea0bf465a192dce748465e10fFariborz Jahanian  bool InternalInterface:1; // true - no @interface for @implementation
37960fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff
380d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff  SourceLocation ClassLoc; // location of the class identifier.
381d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff  SourceLocation SuperClassLoc; // location of the super class identifier.
382f908a87299d278164540f90b5b6e6cab7b14fb41Steve Naroff  SourceLocation EndLoc; // marks the '>', '}', or identifier.
3830e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattner
384d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCInterfaceDecl(DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id,
3850b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner                    SourceLocation CLoc, bool FD, bool isInternal);
3868a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek
3870b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner  virtual ~ObjCInterfaceDecl() {
3880b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner    assert(Ivars == 0 && "Destroy not called?");
3890b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner  }
3908a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek
3910e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattnerpublic:
3920e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattner
3938a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek  /// Destroy - Call destructors and release memory.
3948a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek  virtual void Destroy(ASTContext& C);
3958a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek
396d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCInterfaceDecl *Create(ASTContext &C, DeclContext *DC,
3970ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner                                   SourceLocation atLoc,
398d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff                                   IdentifierInfo *Id,
399d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff                                   SourceLocation ClassLoc = SourceLocation(),
4000e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattner                                   bool ForwardDecl = false,
4010e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattner                                   bool isInternal = false);
4023db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  const ObjCList<ObjCProtocolDecl> &getReferencedProtocols() const {
4037ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian    return ReferencedProtocols;
4047ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  }
405980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
406559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  ObjCCategoryDecl *FindCategoryDeclaration(IdentifierInfo *CategoryId) const;
4073db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner
4083db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  typedef ObjCList<ObjCProtocolDecl>::iterator protocol_iterator;
4093db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
4103db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
411aebf0cba02c014ac8b19d615c654248e0e93779fFariborz Jahanian
412a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  typedef ObjCIvarDecl * const *ivar_iterator;
413be6df088d69bca0e99c7845a6cd8c1ca85034f31Chris Lattner  ivar_iterator ivar_begin() const { return Ivars; }
4145564e07af5e62875f3b83fc2e5a8823588b5adeaChris Lattner  ivar_iterator ivar_end() const { return Ivars + ivar_size();}
415f3a7af901231535191d14cb524d58f22907ac4d2Chris Lattner  unsigned ivar_size() const { return NumIvars; }
416a0fb5861dec7aa1da0d21d5759678d76b00464f4Ted Kremenek  bool ivar_empty() const { return NumIvars == 0; }
417e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
418b752f289026ad8e5f44851b20e009a27ed61eefcChris Lattner  /// addReferencedProtocols - Set the list of protocols that this interface
419b752f289026ad8e5f44851b20e009a27ed61eefcChris Lattner  /// implements.
420780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  void addReferencedProtocols(ObjCProtocolDecl *const*List, unsigned NumRPs) {
421780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner    ReferencedProtocols.set(List, NumRPs);
4223db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  }
423b752f289026ad8e5f44851b20e009a27ed61eefcChris Lattner
424a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  void addInstanceVariablesToClass(ObjCIvarDecl **ivars, unsigned numIvars,
42560fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff                                   SourceLocation RBracLoc);
426fd64bb635dc221baa19f81d5d2a084f7eb269f7fFariborz Jahanian  FieldDecl *lookupFieldDeclForIvar(ASTContext &Context,
427fd64bb635dc221baa19f81d5d2a084f7eb269f7fFariborz Jahanian                                    const ObjCIvarDecl *ivar);
428980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
429768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff  bool isForwardDecl() const { return ForwardDecl; }
430768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff  void setForwardDecl(bool val) { ForwardDecl = val; }
431980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
432a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl *getSuperClass() const { return SuperClass; }
433a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; }
434980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
435a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCCategoryDecl* getCategoryList() const { return CategoryList; }
436a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  void setCategoryList(ObjCCategoryDecl *category) {
43753efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner    CategoryList = category;
438980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
43953efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner
44053efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner  /// isSuperClassOf - Return true if this class is the specified class or is a
44153efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner  /// super class of the specified interface class.
44253efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner  bool isSuperClassOf(const ObjCInterfaceDecl *I) const {
44353efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner    // If RHS is derived from LHS it is OK; else it is not OK.
44453efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner    while (I != NULL) {
44553efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner      if (this == I)
44653efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner        return true;
44753efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner      I = I->getSuperClass();
44853efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner    }
44953efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner    return false;
45053efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner  }
45153efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner
45268a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner  ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName,
45368a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner                                       ObjCInterfaceDecl *&ClassDeclared);
45468a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner  ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName) {
45568a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner    ObjCInterfaceDecl *ClassDeclared;
45668a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner    return lookupInstanceVariable(IVarName, ClassDeclared);
45768a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner  }
45868a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner
45994a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff  // Lookup a method. First, we search locally. If a method isn't
46094a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff  // found, we search referenced protocols and class categories.
461a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCMethodDecl *lookupInstanceMethod(Selector Sel);
462a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCMethodDecl *lookupClassMethod(Selector Sel);
46360fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff
464f908a87299d278164540f90b5b6e6cab7b14fb41Steve Naroff  // Location information, modeled after the Stmt API.
46560fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff  SourceLocation getLocStart() const { return getLocation(); } // '@'interface
466f908a87299d278164540f90b5b6e6cab7b14fb41Steve Naroff  SourceLocation getLocEnd() const { return EndLoc; }
467f908a87299d278164540f90b5b6e6cab7b14fb41Steve Naroff  void setLocEnd(SourceLocation LE) { EndLoc = LE; };
46860fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff
469d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff  SourceLocation getClassLoc() const { return ClassLoc; }
470d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff  void setSuperClassLoc(SourceLocation Loc) { SuperClassLoc = Loc; }
471d6a07aaf62b40cdfbd96f6b874d02b06fc22d015Steve Naroff  SourceLocation getSuperClassLoc() const { return SuperClassLoc; }
472e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
4734b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian  /// ImplicitInterfaceDecl - check that this is an implicitely declared
474a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  /// ObjCInterfaceDecl node. This is for legacy objective-c @implementation
4754b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian  /// declaration without an @interface declaration.
4763a3ca1b35a7121aea0bf465a192dce748465e10fFariborz Jahanian  bool ImplicitInterfaceDecl() const { return InternalInterface; }
4774b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian
478a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const Decl *D) { return D->getKind() == ObjCInterface; }
479a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCInterfaceDecl *D) { return true; }
480980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
481980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
482a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCIvarDecl - Represents an ObjC instance variable. In general, ObjC
4830c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// instance variables are identical to C. The only exception is Objective-C
4840c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// supports C++ style access control. For example:
4850c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
4860c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @interface IvarExample : NSObject
4870c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   {
488f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek///     id defaultToProtected;
4890c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @public:
4900c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id canBePublic; // same as C++.
4910c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @protected:
4920c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id canBeProtected; // same as C++.
4930c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @package:
4940c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id canBePackage; // framework visibility (not available in C++).
4950c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   }
4960c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
497a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCIvarDecl : public FieldDecl {
4980e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattnerpublic:
499980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  enum AccessControl {
500980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    None, Private, Protected, Public, Package
501980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  };
502f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek
503b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenekprivate:
5040c00aac5d618f39afc406c5b2e07642930af1d56Argyrios Kyrtzidis  ObjCIvarDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
5050c00aac5d618f39afc406c5b2e07642930af1d56Argyrios Kyrtzidis               QualType T, AccessControl ac, Expr *BW)
5060c00aac5d618f39afc406c5b2e07642930af1d56Argyrios Kyrtzidis    : FieldDecl(ObjCIvar, DC, L, Id, T, BW, /*Mutable=*/false),
50744b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor      DeclAccess(ac) {}
508b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenek
509b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenekpublic:
5100c00aac5d618f39afc406c5b2e07642930af1d56Argyrios Kyrtzidis  static ObjCIvarDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
511b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenek                              IdentifierInfo *Id, QualType T,
512b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenek                              AccessControl ac, Expr *BW = NULL);
513b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenek
514980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void setAccessControl(AccessControl ac) { DeclAccess = ac; }
515f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek
516ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  AccessControl getAccessControl() const { return AccessControl(DeclAccess); }
517f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek
518f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek  AccessControl getCanonicalAccessControl() const {
519f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek    return DeclAccess == None ? Protected : AccessControl(DeclAccess);
520f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek  }
521980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
522980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  // Implement isa/cast/dyncast/etc.
523a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const Decl *D) { return D->getKind() == ObjCIvar; }
524a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCIvarDecl *D) { return true; }
525980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffprivate:
526ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  // NOTE: VC++ treats enums as signed, avoid using the AccessControl enum
527ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  unsigned DeclAccess : 3;
528980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
529980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
53001e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek
53101e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek/// ObjCAtDefsFieldDecl - Represents a field declaration created by an
53201e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek///  @defs(...).
53301e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenekclass ObjCAtDefsFieldDecl : public FieldDecl {
53401e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenekprivate:
53544b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor  ObjCAtDefsFieldDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
53601e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek                      QualType T, Expr *BW)
5374afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor    : FieldDecl(ObjCAtDefsField, DC, L, Id, T, BW, /*Mutable=*/false) {}
53801e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek
53901e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenekpublic:
54044b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor  static ObjCAtDefsFieldDecl *Create(ASTContext &C, DeclContext *DC,
54144b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor                                     SourceLocation L,
54201e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek                                     IdentifierInfo *Id, QualType T,
54301e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek                                     Expr *BW);
54401e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek
54501e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek  virtual void Destroy(ASTContext& C);
54601e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek
54701e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek  // Implement isa/cast/dyncast/etc.
54801e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek  static bool classof(const Decl *D) { return D->getKind() == ObjCAtDefsField; }
54901e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek  static bool classof(const ObjCAtDefsFieldDecl *D) { return true; }
55001e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek};
551980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
552a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCProtocolDecl - Represents a protocol declaration. ObjC protocols
5530c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// declare a pure abstract type (i.e no instance variables are permitted).
5540c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Protocols orginally drew inspiration from C++ pure virtual functions (a C++
5550c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// feature with nice semantics and lousy syntax:-). Here is an example:
5560c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
557eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// @protocol NSDraggingInfo <refproto1, refproto2>
5580c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSWindow *)draggingDestinationWindow;
5590c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSImage *)draggedImage;
5600c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end
5610c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
562eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// This says that NSDraggingInfo requires two methods and requires everything
563eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// that the two "referenced protocols" 'refproto1' and 'refproto2' require as
564eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// well.
565eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner///
5660c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @interface ImplementsNSDraggingInfo : NSObject <NSDraggingInfo>
5670c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end
5680c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
569a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjC protocols inspired Java interfaces. Unlike Java, ObjC classes and
5700c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// protocols are in distinct namespaces. For example, Cocoa defines both
5710c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// an NSObject protocol and class (which isn't allowed in Java). As a result,
5720c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// protocols are referenced using angle brackets as follows:
5730c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
5740c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id <NSDraggingInfo> anyObjectThatImplementsNSDraggingInfo;
5750c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
576e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroffclass ObjCProtocolDecl : public ObjCContainerDecl {
577780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  /// Referenced protocols
578780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  ObjCList<ObjCProtocolDecl> ReferencedProtocols;
579980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
5803dd4ba4068e953125b95ce85c723322cdd0a3cb5Fariborz Jahanian  /// protocol properties
5813dd4ba4068e953125b95ce85c723322cdd0a3cb5Fariborz Jahanian  ObjCPropertyDecl **PropertyDecl;  // Null if no property
5823dd4ba4068e953125b95ce85c723322cdd0a3cb5Fariborz Jahanian  unsigned NumPropertyDecl;  // 0 if none
5833dd4ba4068e953125b95ce85c723322cdd0a3cb5Fariborz Jahanian
584980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  bool isForwardProtoDecl; // declared with @protocol.
585423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff
586423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff  SourceLocation EndLoc; // marks the '>' or identifier.
587423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff  SourceLocation AtEndLoc; // marks the end of the entire interface.
588cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattner
589d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCProtocolDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id)
590d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor    : ObjCContainerDecl(ObjCProtocol, DC, L, Id),
5913dd4ba4068e953125b95ce85c723322cdd0a3cb5Fariborz Jahanian      PropertyDecl(0), NumPropertyDecl(0),
592c858105d41602a2dadb2efbc1af80a7b791ebac3Chris Lattner      isForwardProtoDecl(true) {
593cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattner  }
5941c8a413c1e00636c77666ddf1e3b0311f3fa8c81Ted Kremenek
595411280e5b25ba7dcd7c8a82a5c23880fe7632a3cChris Lattner  virtual ~ObjCProtocolDecl() {
596411280e5b25ba7dcd7c8a82a5c23880fe7632a3cChris Lattner    assert(PropertyDecl == 0 && "Destroy not called?");
597411280e5b25ba7dcd7c8a82a5c23880fe7632a3cChris Lattner  }
5981c8a413c1e00636c77666ddf1e3b0311f3fa8c81Ted Kremenek
599cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattnerpublic:
600d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCProtocolDecl *Create(ASTContext &C, DeclContext *DC,
601d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor                                  SourceLocation L, IdentifierInfo *Id);
602cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattner
603411280e5b25ba7dcd7c8a82a5c23880fe7632a3cChris Lattner  /// Destroy - Call destructors and release memory.
604411280e5b25ba7dcd7c8a82a5c23880fe7632a3cChris Lattner  virtual void Destroy(ASTContext& C);
605411280e5b25ba7dcd7c8a82a5c23880fe7632a3cChris Lattner
606780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  const ObjCList<ObjCProtocolDecl> &getReferencedProtocols() const {
607780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner    return ReferencedProtocols;
608980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
609dbc933701d20918add13b6a3c9d47ff8c75419cfDaniel Dunbar  typedef ObjCList<ObjCProtocolDecl>::iterator protocol_iterator;
610780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
611780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
612780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner
613780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  /// addReferencedProtocols - Set the list of protocols that this interface
614780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  /// implements.
615780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  void addReferencedProtocols(ObjCProtocolDecl *const*List, unsigned NumRPs) {
616780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner    ReferencedProtocols.set(List, NumRPs);
617aebf0cba02c014ac8b19d615c654248e0e93779fFariborz Jahanian  }
618aebf0cba02c014ac8b19d615c654248e0e93779fFariborz Jahanian
61994a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff  // Lookup a method. First, we search locally. If a method isn't
62094a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff  // found, we search referenced protocols and class categories.
621a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCMethodDecl *lookupInstanceMethod(Selector Sel);
622a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCMethodDecl *lookupClassMethod(Selector Sel);
623a66793ee8d2589ead81739d9b8a968650db3d452Fariborz Jahanian
624768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff  bool isForwardDecl() const { return isForwardProtoDecl; }
625768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff  void setForwardDecl(bool val) { isForwardProtoDecl = val; }
626980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
627423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff  // Location information, modeled after the Stmt API.
628423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff  SourceLocation getLocStart() const { return getLocation(); } // '@'protocol
629423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff  SourceLocation getLocEnd() const { return EndLoc; }
630423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff  void setLocEnd(SourceLocation LE) { EndLoc = LE; };
631423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff
632a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const Decl *D) { return D->getKind() == ObjCProtocol; }
633a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCProtocolDecl *D) { return true; }
634980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
635980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
636a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCClassDecl - Specifies a list of forward class declarations. For example:
63706ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff///
63806ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff/// @class NSCursor, NSImage, NSPasteboard, NSWindow;
6390c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
640d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor/// FIXME: This could be a transparent DeclContext (!)
6414afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCClassDecl : public Decl {
642a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl **ForwardDecls;
6437e620729fcb5a0042107f999dcf524f7357ce819Chris Lattner  unsigned NumForwardDecls;
64461f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner
645d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCClassDecl(DeclContext *DC, SourceLocation L,
6460b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner                ObjCInterfaceDecl **Elts, unsigned nElts);
6470b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner  virtual ~ObjCClassDecl() {
6480b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner    assert(ForwardDecls == 0 && "Destroy not called?");
64906ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  }
65061f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattnerpublic:
651400d95fb7bb9fac609f8613862b84f3a2a7d510fTed Kremenek
652400d95fb7bb9fac609f8613862b84f3a2a7d510fTed Kremenek  /// Destroy - Call destructors and release memory.
653400d95fb7bb9fac609f8613862b84f3a2a7d510fTed Kremenek  virtual void Destroy(ASTContext& C);
654400d95fb7bb9fac609f8613862b84f3a2a7d510fTed Kremenek
655d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCClassDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
65661f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner                               ObjCInterfaceDecl **Elts, unsigned nElts);
65761f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner
658a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  void setInterfaceDecl(unsigned idx, ObjCInterfaceDecl *OID) {
6597e620729fcb5a0042107f999dcf524f7357ce819Chris Lattner    assert(idx < NumForwardDecls && "index out of range");
66006ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff    ForwardDecls[idx] = OID;
66106ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  }
662a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl** getForwardDecls() const { return ForwardDecls; }
6637e15891fc89256fc013bd1003676ad3197b85c25Steve Naroff  int getNumForwardDecls() const { return NumForwardDecls; }
6647e15891fc89256fc013bd1003676ad3197b85c25Steve Naroff
665400d95fb7bb9fac609f8613862b84f3a2a7d510fTed Kremenek  typedef ObjCInterfaceDecl * const * iterator;
666400d95fb7bb9fac609f8613862b84f3a2a7d510fTed Kremenek  iterator begin() const { return ForwardDecls; }
667400d95fb7bb9fac609f8613862b84f3a2a7d510fTed Kremenek  iterator end() const { return ForwardDecls+NumForwardDecls; }
668400d95fb7bb9fac609f8613862b84f3a2a7d510fTed Kremenek
669a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const Decl *D) { return D->getKind() == ObjCClass; }
670a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCClassDecl *D) { return true; }
67106ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff};
67206ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff
673a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCForwardProtocolDecl - Specifies a list of forward protocol declarations.
67406ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff/// For example:
67506ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff///
6760c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @protocol NSTextInput, NSChangeSpelling, NSDraggingInfo;
6770c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
678d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor/// FIXME: Should this be a transparent DeclContext?
6794afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCForwardProtocolDecl : public Decl {
680a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCProtocolDecl **ReferencedProtocols;
6819fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner  unsigned NumReferencedProtocols;
68261f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner
683d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L,
6840b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner                          ObjCProtocolDecl **Elts, unsigned nElts);
6850b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner  virtual ~ObjCForwardProtocolDecl() {
6860b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner    assert(ReferencedProtocols == 0 && "Destroy not called?");
68706ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  }
68805ac3ef08f9d06e0a4439073c9edabf7f912f946Ted Kremenek
68961f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattnerpublic:
690d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCForwardProtocolDecl *Create(ASTContext &C, DeclContext *DC,
691d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor                                         SourceLocation L,
69261f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner                                         ObjCProtocolDecl **Elts, unsigned Num);
69361f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner
6940b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner  /// Destroy - Call destructors and release memory.
6950b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner  virtual void Destroy(ASTContext& C);
6960b7ebb3dba0df0a6cbf221e5edbc6a4b8848478cChris Lattner
697a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  void setForwardProtocolDecl(unsigned idx, ObjCProtocolDecl *OID) {
6989fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner    assert(idx < NumReferencedProtocols && "index out of range");
6997ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian    ReferencedProtocols[idx] = OID;
70006ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  }
7019fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner
7029fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner  unsigned getNumForwardDecls() const { return NumReferencedProtocols; }
7039fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner
704a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCProtocolDecl *getForwardProtocolDecl(unsigned idx) {
7059fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner    assert(idx < NumReferencedProtocols && "index out of range");
7069fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner    return ReferencedProtocols[idx];
7079fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner  }
708a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  const ObjCProtocolDecl *getForwardProtocolDecl(unsigned idx) const {
7099fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner    assert(idx < NumReferencedProtocols && "index out of range");
7109fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner    return ReferencedProtocols[idx];
7119fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner  }
7129fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner
71305ac3ef08f9d06e0a4439073c9edabf7f912f946Ted Kremenek  typedef ObjCProtocolDecl * const * iterator;
71405ac3ef08f9d06e0a4439073c9edabf7f912f946Ted Kremenek  iterator begin() const { return ReferencedProtocols; }
71505ac3ef08f9d06e0a4439073c9edabf7f912f946Ted Kremenek  iterator end() const { return ReferencedProtocols+NumReferencedProtocols; }
71605ac3ef08f9d06e0a4439073c9edabf7f912f946Ted Kremenek
71706ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  static bool classof(const Decl *D) {
718a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek    return D->getKind() == ObjCForwardProtocol;
71906ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  }
720a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCForwardProtocolDecl *D) { return true; }
721980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
722980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
723a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCCategoryDecl - Represents a category declaration. A category allows
7240c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// you to add methods to an existing class (without subclassing or modifying
7250c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// the original class interface or implementation:-). Categories don't allow
7260c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// you to add instance data. The following example adds "myMethod" to all
7270c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// NSView's within a process:
7280c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
7290c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @interface NSView (MyViewMethods)
7300c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - myMethod;
7310c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end
7320c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
7330c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Cateogries also allow you to split the implementation of a class across
7340c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// several files (a feature more naturally supported in C++).
7350c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
7360c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Categories were originally inspired by dynamic languages such as Common
73768c82cf61228102aba1194efef222fa1478af2a8Chris Lattner/// Lisp and Smalltalk.  More traditional class-based languages (C++, Java)
7380c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// don't support this level of dynamism, which is both powerful and dangerous.
7390c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
740e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroffclass ObjCCategoryDecl : public ObjCContainerDecl {
741980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Interface belonging to this category
742a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl *ClassInterface;
743980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
74468c82cf61228102aba1194efef222fa1478af2a8Chris Lattner  /// referenced protocols in this category.
745780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  ObjCList<ObjCProtocolDecl> ReferencedProtocols;
746980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
747980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Next category belonging to this class
748a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCCategoryDecl *NextClassCategory;
749ca3adf7e8cac8c9fbaf592b1e5c2be6f082de7baFariborz Jahanian
7507e7e3872b584bc5e7de7a34c8b9c092032303b72Fariborz Jahanian  /// category properties
7517e7e3872b584bc5e7de7a34c8b9c092032303b72Fariborz Jahanian  ObjCPropertyDecl **PropertyDecl;  // Null if no property
7527e7e3872b584bc5e7de7a34c8b9c092032303b72Fariborz Jahanian  unsigned NumPropertyDecl;  // 0 if none
7537e7e3872b584bc5e7de7a34c8b9c092032303b72Fariborz Jahanian
754423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff  SourceLocation EndLoc; // marks the '>' or identifier.
75561f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner
756d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCCategoryDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id)
757d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor    : ObjCContainerDecl(ObjCCategory, DC, L, Id),
758780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner      ClassInterface(0),
7597e7e3872b584bc5e7de7a34c8b9c092032303b72Fariborz Jahanian      NextClassCategory(0), PropertyDecl(0),  NumPropertyDecl(0) {
760a906135721c350435319347d2672bbb3bf494f91Chris Lattner  }
76161f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattnerpublic:
76261f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner
763d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCCategoryDecl *Create(ASTContext &C, DeclContext *DC,
7640ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner                                  SourceLocation L, IdentifierInfo *Id);
76561f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattner
766e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  ObjCInterfaceDecl *getClassInterface() { return ClassInterface; }
767e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
768a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  void setClassInterface(ObjCInterfaceDecl *IDecl) { ClassInterface = IDecl; }
769980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
770f7b2c98c16dfb2261ea57d40a1d5bc4738e73175Chris Lattner  /// addReferencedProtocols - Set the list of protocols that this interface
771f7b2c98c16dfb2261ea57d40a1d5bc4738e73175Chris Lattner  /// implements.
772780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  void addReferencedProtocols(ObjCProtocolDecl *const*List, unsigned NumRPs) {
773780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner    ReferencedProtocols.set(List, NumRPs);
774780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  }
775980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
776780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  const ObjCList<ObjCProtocolDecl> &getReferencedProtocols() const {
777780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner    return ReferencedProtocols;
7788f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  }
779780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner
780780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  typedef ObjCProtocolDecl * const * protocol_iterator;
781780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
782780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
783780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner
784a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCCategoryDecl *getNextClassCategory() const { return NextClassCategory; }
785980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void insertNextClassCategory() {
7863d58138992b9bc7b34aaa680f3ddf3971292eb7dSteve Naroff    NextClassCategory = ClassInterface->getCategoryList();
7873d58138992b9bc7b34aaa680f3ddf3971292eb7dSteve Naroff    ClassInterface->setCategoryList(this);
788980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
789423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff  // Location information, modeled after the Stmt API.
790423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff  SourceLocation getLocStart() const { return getLocation(); } // '@'interface
791423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff  SourceLocation getLocEnd() const { return EndLoc; }
792423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff  void setLocEnd(SourceLocation LE) { EndLoc = LE; };
793423cb565abc681b770fb4b9b4bc24d398c98157bSteve Naroff
794a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const Decl *D) { return D->getKind() == ObjCCategory; }
795a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCCategoryDecl *D) { return true; }
796980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
7970c6b6243d3efd958c17943130e2a773653511edcSteve Naroff
798a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCCategoryImplDecl - An object of this class encapsulates a category
799559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian/// @implementation declaration. If a category class has declaration of a
800559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian/// property, its implementation must be specified in the category's
801559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian/// @implementation declaration. Example:
802559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian/// @interface I @end
803559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian/// @interface I(CATEGORY)
804559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian///    @property int p1, d1;
805559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian/// @end
806559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian/// @implementation I(CATEGORY)
807559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian///  @dynamic p1,d1;
808559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian/// @end
809559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian///
8104afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCCategoryImplDecl : public NamedDecl, public DeclContext {
8118f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  /// Class interface for this category implementation
812a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl *ClassInterface;
8138f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
814e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff  /// implemented instance methods
815a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  llvm::SmallVector<ObjCMethodDecl*, 32> InstanceMethods;
8168f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
817e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff  /// implemented class methods
818a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  llvm::SmallVector<ObjCMethodDecl*, 32> ClassMethods;
819f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian
820559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  /// Property Implementations in this category
821f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian  llvm::SmallVector<ObjCPropertyImplDecl*, 8> PropertyImplementations;
822e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff
823e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff  SourceLocation EndLoc;
82475c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattner
825d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCCategoryImplDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
826a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek                       ObjCInterfaceDecl *classInterface)
8274afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor    : NamedDecl(ObjCCategoryImpl, DC, L, Id), DeclContext(ObjCCategoryImpl),
8280701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff      ClassInterface(classInterface) {}
82975c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattnerpublic:
830d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCCategoryImplDecl *Create(ASTContext &C, DeclContext *DC,
8310ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner                                      SourceLocation L, IdentifierInfo *Id,
83275c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattner                                      ObjCInterfaceDecl *classInterface);
8338f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
834e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
835e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  ObjCInterfaceDecl *getClassInterface() { return ClassInterface; }
8368f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
837ab4c4d5e5ececa77aae7e291fafcba3049319cdcChris Lattner  unsigned getNumInstanceMethods() const { return InstanceMethods.size(); }
838ab4c4d5e5ececa77aae7e291fafcba3049319cdcChris Lattner  unsigned getNumClassMethods() const { return ClassMethods.size(); }
839e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff
840a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  void addInstanceMethod(ObjCMethodDecl *method) {
841e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff    InstanceMethods.push_back(method);
842e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff  }
843a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  void addClassMethod(ObjCMethodDecl *method) {
844e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff    ClassMethods.push_back(method);
845f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian  }
84653df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner
84753df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner  // Get the local instance/class method declared in this interface.
8483216dcdebb8ae0f2993ac5f5249caa217444bacfDaniel Dunbar  ObjCMethodDecl *getInstanceMethod(Selector Sel) const;
8493216dcdebb8ae0f2993ac5f5249caa217444bacfDaniel Dunbar  ObjCMethodDecl *getClassMethod(Selector Sel) const;
85053df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner  ObjCMethodDecl *getMethod(Selector Sel, bool isInstance) const {
85153df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner    return isInstance ? getInstanceMethod(Sel) : getClassMethod(Sel);
85253df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner  }
853f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian
854f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian  void addPropertyImplementation(ObjCPropertyImplDecl *property) {
855f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian    PropertyImplementations.push_back(property);
856f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian  }
857e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff
858ae6f6fd1527a1da84679a6f0439dec3bbbd6ca7bFariborz Jahanian  ObjCPropertyImplDecl *FindPropertyImplDecl(IdentifierInfo *propertyId) const;
859ae6f6fd1527a1da84679a6f0439dec3bbbd6ca7bFariborz Jahanian  ObjCPropertyImplDecl *FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const;
860ae6f6fd1527a1da84679a6f0439dec3bbbd6ca7bFariborz Jahanian
861f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian  unsigned getNumPropertyImplementations() const
862f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian  { return PropertyImplementations.size(); }
863f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian
864559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian
865559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  typedef llvm::SmallVector<ObjCPropertyImplDecl*, 8>::const_iterator
866559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian    propimpl_iterator;
867559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  propimpl_iterator propimpl_begin() const {
868559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian    return PropertyImplementations.begin();
869559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  }
870559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  propimpl_iterator propimpl_end() const {
871559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian    return PropertyImplementations.end();
872559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  }
873559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian
874a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  typedef llvm::SmallVector<ObjCMethodDecl*, 32>::const_iterator
875ab4c4d5e5ececa77aae7e291fafcba3049319cdcChris Lattner    instmeth_iterator;
876ab4c4d5e5ececa77aae7e291fafcba3049319cdcChris Lattner  instmeth_iterator instmeth_begin() const { return InstanceMethods.begin(); }
877ab4c4d5e5ececa77aae7e291fafcba3049319cdcChris Lattner  instmeth_iterator instmeth_end() const { return InstanceMethods.end(); }
878ab4c4d5e5ececa77aae7e291fafcba3049319cdcChris Lattner
879a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  typedef llvm::SmallVector<ObjCMethodDecl*, 32>::const_iterator
880ab4c4d5e5ececa77aae7e291fafcba3049319cdcChris Lattner    classmeth_iterator;
881ab4c4d5e5ececa77aae7e291fafcba3049319cdcChris Lattner  classmeth_iterator classmeth_begin() const { return ClassMethods.begin(); }
882ab4c4d5e5ececa77aae7e291fafcba3049319cdcChris Lattner  classmeth_iterator classmeth_end() const { return ClassMethods.end(); }
883ab4c4d5e5ececa77aae7e291fafcba3049319cdcChris Lattner
884ab4c4d5e5ececa77aae7e291fafcba3049319cdcChris Lattner
885e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff  // Location information, modeled after the Stmt API.
886e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff  SourceLocation getLocStart() const { return getLocation(); }
887e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff  SourceLocation getLocEnd() const { return EndLoc; }
888e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff  void setLocEnd(SourceLocation LE) { EndLoc = LE; };
889e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff
890a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const Decl *D) { return D->getKind() == ObjCCategoryImpl;}
891a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCCategoryImplDecl *D) { return true; }
892b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff  static DeclContext *castToDeclContext(const ObjCCategoryImplDecl *D) {
893b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff    return static_cast<DeclContext *>(const_cast<ObjCCategoryImplDecl*>(D));
894b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff  }
895b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff  static ObjCCategoryImplDecl *castFromDeclContext(const DeclContext *DC) {
896b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff    return static_cast<ObjCCategoryImplDecl *>(const_cast<DeclContext*>(DC));
897b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff  }
8988f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian};
8998f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
900a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCImplementationDecl - Represents a class definition - this is where
9010c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// method definitions are specified. For example:
9020c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
90398abf4bd3526a00a0e5cf71a9462c181f97b1c81Fariborz Jahanian/// @code
9040c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @implementation MyClass
9050c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (void)myMethod { /* do something */ }
9060c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end
90798abf4bd3526a00a0e5cf71a9462c181f97b1c81Fariborz Jahanian/// @endcode
9080c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
9090c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Typically, instance variables are specified in the class interface,
910ec0d7a6f4b0699cc9960e6d9fee0f957c64d1cf9Douglas Gregor/// *not* in the implementation. Nevertheless (for legacy reasons), we
91153df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner/// allow instance variables to be specified in the implementation.  When
91253df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner/// specified, they need to be *identical* to the interface.
9130c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
9144afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCImplementationDecl : public Decl, public DeclContext {
915dae1a1a2aa4f245b1958dc8db6089f24c575ef13Fariborz Jahanian  /// Class interface for this implementation
916a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl *ClassInterface;
917f4d331dd922f92478ebf30e808c0ca97ce49418bFariborz Jahanian
918980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Implementation Class's super class.
919a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl *SuperClass;
920980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
921980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Optional Ivars/NumIvars - This is a new[]'d array of pointers to Decls.
922a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCIvarDecl **Ivars;   // Null if not specified
923f3a7af901231535191d14cb524d58f22907ac4d2Chris Lattner  unsigned NumIvars;      // 0 if none.
9240416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff
925980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// implemented instance methods
926a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  llvm::SmallVector<ObjCMethodDecl*, 32> InstanceMethods;
9270416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff
928980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// implemented class methods
929a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  llvm::SmallVector<ObjCMethodDecl*, 32> ClassMethods;
9300416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff
931f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian  /// Propertys' being implemented
932f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian  llvm::SmallVector<ObjCPropertyImplDecl*, 8> PropertyImplementations;
933f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian
9340416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff  SourceLocation EndLoc;
93575c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattner
9364afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  ObjCImplementationDecl(DeclContext *DC, SourceLocation L,
937a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek                         ObjCInterfaceDecl *classInterface,
938a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek                         ObjCInterfaceDecl *superDecl)
9394afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor    : Decl(ObjCImplementation, DC, L), DeclContext(ObjCImplementation),
9400416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff      ClassInterface(classInterface), SuperClass(superDecl),
941f3a7af901231535191d14cb524d58f22907ac4d2Chris Lattner      Ivars(0), NumIvars(0) {}
94275c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattnerpublic:
943d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCImplementationDecl *Create(ASTContext &C, DeclContext *DC,
9444afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor                                        SourceLocation L,
94575c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattner                                        ObjCInterfaceDecl *classInterface,
94675c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattner                                        ObjCInterfaceDecl *superDecl);
94775c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattner
948980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
949a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  void ObjCAddInstanceVariablesToClassImpl(ObjCIvarDecl **ivars,
950980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff                                           unsigned numIvars);
951980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
952a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  void addInstanceMethod(ObjCMethodDecl *method) {
9530416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff    InstanceMethods.push_back(method);
9540416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff  }
955a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  void addClassMethod(ObjCMethodDecl *method) {
9560416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff    ClassMethods.push_back(method);
9570416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff  }
958f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian
959f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian  void addPropertyImplementation(ObjCPropertyImplDecl *property) {
960f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian    PropertyImplementations.push_back(property);
961f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian  }
962ae6f6fd1527a1da84679a6f0439dec3bbbd6ca7bFariborz Jahanian
963ae6f6fd1527a1da84679a6f0439dec3bbbd6ca7bFariborz Jahanian  ObjCPropertyImplDecl *FindPropertyImplDecl(IdentifierInfo *propertyId) const;
964ae6f6fd1527a1da84679a6f0439dec3bbbd6ca7bFariborz Jahanian  ObjCPropertyImplDecl *FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const;
965ae6f6fd1527a1da84679a6f0439dec3bbbd6ca7bFariborz Jahanian
966559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  typedef llvm::SmallVector<ObjCPropertyImplDecl*, 8>::const_iterator
967559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  propimpl_iterator;
968559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  propimpl_iterator propimpl_begin() const {
969559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian    return PropertyImplementations.begin();
970559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  }
971559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  propimpl_iterator propimpl_end() const {
972559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian    return PropertyImplementations.end();
973559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  }
974f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian
9750416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff  // Location information, modeled after the Stmt API.
9760416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff  SourceLocation getLocStart() const { return getLocation(); }
9770416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff  SourceLocation getLocEnd() const { return EndLoc; }
9780416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff  void setLocEnd(SourceLocation LE) { EndLoc = LE; };
9790416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff
9804afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  /// getIdentifier - Get the identifier that names the class
9814afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  /// interface associated with this implementation.
9824afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  IdentifierInfo *getIdentifier() const {
9834afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor    return getClassInterface()->getIdentifier();
9844afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  }
9854afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor
9864afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  /// getNameAsCString - Get the name of identifier for the class
9874afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  /// interface associated with this implementation as a C string
9884afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  /// (const char*).
9894afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  const char *getNameAsCString() const {
9904afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor    assert(getIdentifier() && "Name is not a simple identifier");
9914afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor    return getIdentifier()->getName();
9924afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  }
9934afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor
9944afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  /// @brief Get the name of the class associated with this interface.
9954afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  std::string getNameAsString() const {
9964afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor    return getClassInterface()->getNameAsString();
9974afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  }
9984afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor
999e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
1000e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  ObjCInterfaceDecl *getClassInterface() { return ClassInterface; }
1001e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  const ObjCInterfaceDecl *getSuperClass() const { return SuperClass; }
1002e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  ObjCInterfaceDecl *getSuperClass() { return SuperClass; }
1003980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
1004f3a7af901231535191d14cb524d58f22907ac4d2Chris Lattner  void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; }
1005980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
1006b5feb35360526da42ad7e3fa7ef3d44a5992b83cChris Lattner  unsigned getNumInstanceMethods() const { return InstanceMethods.size(); }
100762db2f4214c1589082960f12c9cb8924fe0cf8c5Chris Lattner  unsigned getNumClassMethods() const { return ClassMethods.size(); }
1008f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian
1009f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian  unsigned getNumPropertyImplementations() const
1010f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanian    { return PropertyImplementations.size(); }
1011c43d868355374d48296ad3be2c9c536698a5e9a8Steve Naroff
1012a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  typedef llvm::SmallVector<ObjCMethodDecl*, 32>::const_iterator
10130157c5144513438bb74aebf50d18f95df4104acbChris Lattner       instmeth_iterator;
10140157c5144513438bb74aebf50d18f95df4104acbChris Lattner  instmeth_iterator instmeth_begin() const { return InstanceMethods.begin(); }
10150157c5144513438bb74aebf50d18f95df4104acbChris Lattner  instmeth_iterator instmeth_end() const { return InstanceMethods.end(); }
10160157c5144513438bb74aebf50d18f95df4104acbChris Lattner
1017a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  typedef llvm::SmallVector<ObjCMethodDecl*, 32>::const_iterator
10180157c5144513438bb74aebf50d18f95df4104acbChris Lattner    classmeth_iterator;
10190157c5144513438bb74aebf50d18f95df4104acbChris Lattner  classmeth_iterator classmeth_begin() const { return ClassMethods.begin(); }
10200157c5144513438bb74aebf50d18f95df4104acbChris Lattner  classmeth_iterator classmeth_end() const { return ClassMethods.end(); }
10210157c5144513438bb74aebf50d18f95df4104acbChris Lattner
102253df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner  // Get the local instance/class method declared in this interface.
10233216dcdebb8ae0f2993ac5f5249caa217444bacfDaniel Dunbar  ObjCMethodDecl *getInstanceMethod(Selector Sel) const;
10243216dcdebb8ae0f2993ac5f5249caa217444bacfDaniel Dunbar  ObjCMethodDecl *getClassMethod(Selector Sel) const;
102553df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner  ObjCMethodDecl *getMethod(Selector Sel, bool isInstance) const {
102653df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner    return isInstance ? getInstanceMethod(Sel) : getClassMethod(Sel);
102753df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner  }
10280157c5144513438bb74aebf50d18f95df4104acbChris Lattner
1029a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  typedef ObjCIvarDecl * const *ivar_iterator;
10300157c5144513438bb74aebf50d18f95df4104acbChris Lattner  ivar_iterator ivar_begin() const { return Ivars; }
1031f3a7af901231535191d14cb524d58f22907ac4d2Chris Lattner  ivar_iterator ivar_end() const { return Ivars+NumIvars; }
1032f3a7af901231535191d14cb524d58f22907ac4d2Chris Lattner  unsigned ivar_size() const { return NumIvars; }
1033f3a7af901231535191d14cb524d58f22907ac4d2Chris Lattner  bool ivar_empty() const { return NumIvars == 0; }
10340157c5144513438bb74aebf50d18f95df4104acbChris Lattner
1035980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  static bool classof(const Decl *D) {
1036a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek    return D->getKind() == ObjCImplementation;
1037980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
1038a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCImplementationDecl *D) { return true; }
1039b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff  static DeclContext *castToDeclContext(const ObjCImplementationDecl *D) {
1040b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff    return static_cast<DeclContext *>(const_cast<ObjCImplementationDecl*>(D));
1041b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff  }
1042b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff  static ObjCImplementationDecl *castFromDeclContext(const DeclContext *DC) {
1043b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff    return static_cast<ObjCImplementationDecl *>(const_cast<DeclContext*>(DC));
1044b718b407db1f921c5a2dc0164a23582c322f8ce0Steve Naroff  }
1045980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
1046243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian
1047a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is
1048243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian/// declared as @compatibility_alias alias class.
10494afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCCompatibleAliasDecl : public NamedDecl {
1050243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian  /// Class that this is an alias of.
1051a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl *AliasedClass;
1052243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian
1053d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCCompatibleAliasDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
1054e8043c39176e7f253fbd92982b077eca6bf2fd59Steve Naroff                          ObjCInterfaceDecl* aliasedClass)
10554afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor    : NamedDecl(ObjCCompatibleAlias, DC, L, Id), AliasedClass(aliasedClass) {}
1056f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattnerpublic:
1057d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCCompatibleAliasDecl *Create(ASTContext &C, DeclContext *DC,
10580ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner                                         SourceLocation L, IdentifierInfo *Id,
1059f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner                                         ObjCInterfaceDecl* aliasedClass);
1060f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner
1061f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner  const ObjCInterfaceDecl *getClassInterface() const { return AliasedClass; }
1062f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner  ObjCInterfaceDecl *getClassInterface() { return AliasedClass; }
1063980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
1064243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian  static bool classof(const Decl *D) {
10658a934233d1582b5bde9d270bc0705aa81e471a79Chris Lattner    return D->getKind() == ObjCCompatibleAlias;
1066243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian  }
1067a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCCompatibleAliasDecl *D) { return true; }
1068243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian
1069243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian};
10701de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian
10711de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian/// ObjCPropertyDecl - Represents one property declaration in an interface.
10721de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian/// For example:
10731de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian/// @property (assign, readwrite) int MyProperty;
10741de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian///
10754afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCPropertyDecl : public NamedDecl {
107682a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanianpublic:
1077a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner  enum PropertyAttributeKind {
1078a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    OBJC_PR_noattr    = 0x00,
1079a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    OBJC_PR_readonly  = 0x01,
1080a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    OBJC_PR_getter    = 0x02,
1081a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    OBJC_PR_assign    = 0x04,
1082a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    OBJC_PR_readwrite = 0x08,
1083a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    OBJC_PR_retain    = 0x10,
1084a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    OBJC_PR_copy      = 0x20,
1085a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    OBJC_PR_nonatomic = 0x40,
1086a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    OBJC_PR_setter    = 0x80
1087a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner  };
1088af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar
1089af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  enum SetterKind { Assign, Retain, Copy };
109046b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  enum PropertyControl { None, Required, Optional };
109182a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanianprivate:
1092dae1a1a2aa4f245b1958dc8db6089f24c575ef13Fariborz Jahanian  QualType DeclType;
1093ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  unsigned PropertyAttributes : 8;
109482a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian
109546b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  // @required/@optional
109646b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  unsigned PropertyImplementation : 2;
109746b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian
10985251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  Selector GetterName;    // getter name of NULL if no getter
10995251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  Selector SetterName;    // setter name of NULL if no setter
110082a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian
110133de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  ObjCMethodDecl *GetterMethodDecl; // Declaration of getter instance method
110233de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  ObjCMethodDecl *SetterMethodDecl; // Declaration of setter instance method
110333de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian
1104d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
1105d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor                   QualType T)
11064afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor    : NamedDecl(ObjCProperty, DC, L, Id), DeclType(T),
110733de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian      PropertyAttributes(OBJC_PR_noattr), PropertyImplementation(None),
110833de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian      GetterName(Selector()),
110933de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian      SetterName(Selector()),
111033de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian      GetterMethodDecl(0), SetterMethodDecl(0) {}
1111f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattnerpublic:
1112d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC,
1113d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor                                  SourceLocation L,
111446b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian                                  IdentifierInfo *Id, QualType T,
111546b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian                                  PropertyControl propControl = None);
1116dae1a1a2aa4f245b1958dc8db6089f24c575ef13Fariborz Jahanian  QualType getType() const { return DeclType; }
1117c35b9e4e2efad727538c848cf30d4b0eb1031dc9Fariborz Jahanian
1118a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner  PropertyAttributeKind getPropertyAttributes() const {
1119f4af5154571e0c5eadb19df10e65464766ef6683Chris Lattner    return PropertyAttributeKind(PropertyAttributes);
1120f4af5154571e0c5eadb19df10e65464766ef6683Chris Lattner  }
1121564576b225386cbff375351597dd5e2a92872d38Fariborz Jahanian  void setPropertyAttributes(PropertyAttributeKind PRVal) {
1122a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    PropertyAttributes |= PRVal;
112382a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian  }
1124394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar
11258cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian void makeitReadWriteAttribute(void) {
11268cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian    PropertyAttributes &= ~OBJC_PR_readonly;
11278cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian    PropertyAttributes |= OBJC_PR_readwrite;
11288cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian }
11298cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian
1130af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  // Helper methods for accessing attributes.
1131af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar
1132af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  /// isReadOnly - Return true iff the property has a setter.
1133394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar  bool isReadOnly() const {
1134394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar    return (PropertyAttributes & OBJC_PR_readonly);
1135394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar  }
1136af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar
1137af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  /// getSetterKind - Return the method used for doing assignment in
1138af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  /// the property setter. This is only valid if the property has been
1139af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  /// defined to have a setter.
1140af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  SetterKind getSetterKind() const {
1141af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar    if (PropertyAttributes & OBJC_PR_retain)
1142af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar      return Retain;
1143af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar    if (PropertyAttributes & OBJC_PR_copy)
1144af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar      return Copy;
1145af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar    return Assign;
1146af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  }
1147af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar
11485251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  Selector getGetterName() const { return GetterName; }
11495251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  void setGetterName(Selector Sel) { GetterName = Sel; }
115082a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian
11515251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  Selector getSetterName() const { return SetterName; }
11525251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  void setSetterName(Selector Sel) { SetterName = Sel; }
115382a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian
115433de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  ObjCMethodDecl *getGetterMethodDecl() const { return GetterMethodDecl; }
115533de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  void setGetterMethodDecl(ObjCMethodDecl *gDecl) { GetterMethodDecl = gDecl; }
115633de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian
115733de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  ObjCMethodDecl *getSetterMethodDecl() const { return SetterMethodDecl; }
115833de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  void setSetterMethodDecl(ObjCMethodDecl *gDecl) { SetterMethodDecl = gDecl; }
115933de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian
116046b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  // Related to @optional/@required declared in @protocol
116146b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  void setPropertyImplementation(PropertyControl pc) {
116246b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian    PropertyImplementation = pc;
116346b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  }
116446b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  PropertyControl getPropertyImplementation() const {
116546b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian    return PropertyControl(PropertyImplementation);
116646b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  }
116746b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian
116882a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian  static bool classof(const Decl *D) {
1169670aa9d7639278f507930e95dc89c12032ab7c7eSam Bishop    return D->getKind() == ObjCProperty;
117082a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian  }
1171a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCPropertyDecl *D) { return true; }
117282a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian};
1173980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
117461d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian/// ObjCPropertyImplDecl - Represents implementation declaration of a property
117561d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian/// in a class or category implementation block. For example:
117661d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian/// @synthesize prop1 = ivar1;
117761d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian///
11784afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCPropertyImplDecl : public Decl {
117961d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanianpublic:
11809f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar  enum Kind {
11819f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar    Synthesize,
11829f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar    Dynamic
118361d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  };
118461d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanianprivate:
1185559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  SourceLocation AtLoc;   // location of @synthesize or @dynamic
118661d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  /// Property declaration being implemented
118761d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  ObjCPropertyDecl *PropertyDecl;
1188be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek
118961d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  /// Null for @dynamic. Required for @synthesize.
119061d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  ObjCIvarDecl *PropertyIvarDecl;
1191be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek
1192d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCPropertyImplDecl(DeclContext *DC, SourceLocation atLoc, SourceLocation L,
1193628b96f34e93b643b6e15e75eabb8d96079a7e27Fariborz Jahanian                       ObjCPropertyDecl *property,
11949f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar                       Kind PK,
1195628b96f34e93b643b6e15e75eabb8d96079a7e27Fariborz Jahanian                       ObjCIvarDecl *ivarDecl)
11964afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor    : Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc),
1197d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor      PropertyDecl(property), PropertyIvarDecl(ivarDecl) {
11989f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar    assert (PK == Dynamic || PropertyIvarDecl);
11999f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar  }
1200628b96f34e93b643b6e15e75eabb8d96079a7e27Fariborz Jahanian
12019f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbarpublic:
1202d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCPropertyImplDecl *Create(ASTContext &C, DeclContext *DC,
1203d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor                                      SourceLocation atLoc, SourceLocation L,
1204628b96f34e93b643b6e15e75eabb8d96079a7e27Fariborz Jahanian                                      ObjCPropertyDecl *property,
12059f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar                                      Kind PK,
1206628b96f34e93b643b6e15e75eabb8d96079a7e27Fariborz Jahanian                                      ObjCIvarDecl *ivarDecl);
120761d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian
1208d40910b581b09c937a8c1fdcde9b8ec724398fb9Steve Naroff  SourceLocation getLocStart() const { return AtLoc; }
1209d40910b581b09c937a8c1fdcde9b8ec724398fb9Steve Naroff
1210be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek  ObjCPropertyDecl *getPropertyDecl() const {
1211be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek    return PropertyDecl;
1212be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek  }
121361d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian
12149f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar  Kind getPropertyImplementation() const {
12159f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar    return PropertyIvarDecl ? Synthesize : Dynamic;
1216be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek  }
121761d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian
1218af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  ObjCIvarDecl *getPropertyIvarDecl() const {
1219be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek    return PropertyIvarDecl;
1220be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek  }
122161d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian
122261d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  static bool classof(const Decl *D) {
122361d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian    return D->getKind() == ObjCPropertyImpl;
122461d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  }
122561d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  static bool classof(const ObjCPropertyImplDecl *D) { return true; }
122661d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian};
122761d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian
1228980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}  // end namespace clang
1229980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#endif
1230