1980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//===--- DeclObjC.h - Classes for representing declarations -----*- C++ -*-===//
2980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//
3980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//                     The LLVM Compiler Infrastructure
4980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//
50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source
60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details.
7980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//
8980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//===----------------------------------------------------------------------===//
9980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//
10980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//  This file defines the DeclObjC interface and subclasses.
11980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//
12980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//===----------------------------------------------------------------------===//
13980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
14980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#ifndef LLVM_CLANG_AST_DECLOBJC_H
15980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#define LLVM_CLANG_AST_DECLOBJC_H
16980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
17980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#include "clang/AST/Decl.h"
18491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis#include "clang/AST/SelectorLocationsKind.h"
196ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson#include "llvm/ADT/STLExtras.h"
20aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar#include "llvm/Support/Compiler.h"
21980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
22980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffnamespace clang {
23980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass Expr;
24980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass Stmt;
25980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass FunctionDecl;
2660f8c868ffb346b78451a3eccaecd0461d2ae498Fariborz Jahanianclass RecordDecl;
27a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCIvarDecl;
28a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCMethodDecl;
29a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCProtocolDecl;
30a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCCategoryDecl;
31a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCPropertyDecl;
32f624f8186d8fe474350051c6d3f00b2c204fbeaeFariborz Jahanianclass ObjCPropertyImplDecl;
33cbb67480094b3bcb5b715acd827cbad55e2a204cSean Huntclass CXXCtorInitializer;
3468835718c4125f2f66740cd04de7088645ec695dChris Lattner
35793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerclass ObjCListBase {
36793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  void operator=(const ObjCListBase &);     // DO NOT IMPLEMENT
37793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  ObjCListBase(const ObjCListBase&);        // DO NOT IMPLEMENT
38793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerprotected:
39793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  /// List is an array of pointers to objects that are not owned by this object.
40793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  void **List;
413db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  unsigned NumElts;
42793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner
433db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattnerpublic:
44793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  ObjCListBase() : List(0), NumElts(0) {}
45793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  unsigned size() const { return NumElts; }
46793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  bool empty() const { return NumElts == 0; }
471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
48793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerprotected:
4938af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner  void set(void *const* InList, unsigned Elts, ASTContext &Ctx);
50793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner};
511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
53793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// ObjCList - This is a simple template class used to hold various lists of
54793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// decls etc, which is heavily used by the ObjC front-end.  This only use case
55793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// this supports is setting the list all at once and then reading elements out
56793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner/// of it.
57793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnertemplate <typename T>
58793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerclass ObjCList : public ObjCListBase {
59793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattnerpublic:
6038af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner  void set(T* const* InList, unsigned Elts, ASTContext &Ctx) {
6138af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner    ObjCListBase::set(reinterpret_cast<void*const*>(InList), Elts, Ctx);
62793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  }
631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
64793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  typedef T* const * iterator;
65793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  iterator begin() const { return (iterator)List; }
66793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  iterator end() const { return (iterator)List+NumElts; }
671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
68793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner  T* operator[](unsigned Idx) const {
69793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner    assert(Idx < NumElts && "Invalid access");
70793ccfd646d0388e06c587e962a18fa723b72f02Chris Lattner    return (T*)List[Idx];
713db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  }
723db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner};
733db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner
7418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor/// \brief A list of Objective-C protocols, along with the source
7518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor/// locations at which they were referenced.
7618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregorclass ObjCProtocolList : public ObjCList<ObjCProtocolDecl> {
7718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  SourceLocation *Locations;
7818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor
7918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  using ObjCList<ObjCProtocolDecl>::set;
8018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor
8118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregorpublic:
8218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  ObjCProtocolList() : ObjCList<ObjCProtocolDecl>(), Locations(0) { }
8318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor
8418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  typedef const SourceLocation *loc_iterator;
8518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  loc_iterator loc_begin() const { return Locations; }
8618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  loc_iterator loc_end() const { return Locations + size(); }
8718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor
88ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  void set(ObjCProtocolDecl* const* InList, unsigned Elts,
8918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor           const SourceLocation *Locs, ASTContext &Ctx);
9018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor};
911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
9258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
93a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCMethodDecl - Represents an instance or class method declaration.
9458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// ObjC methods can be declared within 4 contexts: class interfaces,
9558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// categories, protocols, and class implementations. While C++ member
961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// functions leverage C syntax, Objective-C method syntax is modeled after
971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// Smalltalk (using colons to specify argument types/expressions).
9858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Here are some brief examples:
9958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff///
10058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Setter/getter instance methods:
10158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// - (void)setMenu:(NSMenu *)menu;
1021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// - (NSMenu *)menu;
1031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
10458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Instance method that takes 2 NSView arguments:
10558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// - (void)replaceSubview:(NSView *)oldView with:(NSView *)newView;
10658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff///
10758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// Getter class method:
10858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// + (NSMenu *)defaultMenu;
10958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff///
11058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// A selector represents a unique name for a method. The selector names for
11158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff/// the above methods are setMenu:, menu, replaceSubview:with:, and defaultMenu.
11258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff///
1134afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCMethodDecl : public NamedDecl, public DeclContext {
11458dbdeb69c063f82d644504fc638120198f7fad2Steve Naroffpublic:
11558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  enum ImplementationControl { None, Required, Optional };
11658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroffprivate:
11785f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  // The conventional meaning of this method; an ObjCMethodFamily.
11885f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  // This is not serialized; instead, it is computed on demand and
11985f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  // cached.
12085f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  mutable unsigned Family : ObjCMethodFamilyBitWidth;
12185f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall
12258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  /// instance (true) or class (false) method.
12385f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  unsigned IsInstance : 1;
12485f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  unsigned IsVariadic : 1;
1251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1264607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian  // Synthesized declaration method for a property setter/getter
12785f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  unsigned IsSynthesized : 1;
128ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
1293fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian  // Method has a definition.
13085f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  unsigned IsDefined : 1;
1311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
13272b2625aa67c8213acaf4bf6209b67859d60e2cfArgyrios Kyrtzidis  /// \brief Method redeclaration in the same interface.
1333a919e7110407ae7609bb6edc57aac16a5990661Argyrios Kyrtzidis  unsigned IsRedeclaration : 1;
1343a919e7110407ae7609bb6edc57aac16a5990661Argyrios Kyrtzidis
13572b2625aa67c8213acaf4bf6209b67859d60e2cfArgyrios Kyrtzidis  /// \brief Is redeclared in the same interface.
13672b2625aa67c8213acaf4bf6209b67859d60e2cfArgyrios Kyrtzidis  mutable unsigned HasRedeclaration : 1;
13772b2625aa67c8213acaf4bf6209b67859d60e2cfArgyrios Kyrtzidis
138ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  // NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum
13941c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// \@required/\@optional
140ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  unsigned DeclImplementation : 2;
1411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
142ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  // NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum
14358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  /// in, inout, etc.
144ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  unsigned objcDeclQualifier : 6;
1451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
146926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor  /// \brief Indicates whether this method has a related result type.
147926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor  unsigned RelatedResultType : 1;
148ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
149491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  /// \brief Whether the locations of the selector identifiers are in a
150491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  /// "standard" position, a enum SelectorLocationsKind.
151491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  unsigned SelLocsKind : 2;
1527732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian
153e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  /// \brief Whether this method overrides any other in the class hierarchy.
154e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  ///
155e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  /// A method is said to override any method in the class's
156e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  /// base classes, its protocols, or its categories' protocols, that has
157e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  /// the same selector and is of the same kind (class or instance).
158e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  /// A method in an implementation is not considered as overriding the same
159e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  /// method in the interface or its categories.
160e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  unsigned IsOverriding : 1;
161e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis
1624bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor  // Result type of this method.
16358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  QualType MethodDeclType;
164ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
1654bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor  // Type source information for the result type.
1664bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor  TypeSourceInfo *ResultTInfo;
1674bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor
168491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  /// \brief Array of ParmVarDecls for the formal parameters of this method
169491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  /// and optionally followed by selector locations.
170491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  void *ParamsAndSelLocs;
171491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  unsigned NumParams;
1721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
17358dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  /// List of attributes for this method declaration.
174a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis  SourceLocation DeclEndLoc; // the location of the ';' or '{'.
1751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
17658dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  // The following are only used for method definitions, null otherwise.
17758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  // FIXME: space savings opportunity, consider a sub-class.
17858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  Stmt *Body;
179451318c08a6342c10b8986060386fd9274418437Daniel Dunbar
180451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// SelfDecl - Decl for the implicit self parameter. This is lazily
181451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// constructed by createImplicitParams.
1824111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner  ImplicitParamDecl *SelfDecl;
183451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// CmdDecl - Decl for the implicit _cmd parameter. This is lazily
184451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// constructed by createImplicitParams.
1854111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner  ImplicitParamDecl *CmdDecl;
1861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
187491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  SelectorLocationsKind getSelLocsKind() const {
188491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis    return (SelectorLocationsKind)SelLocsKind;
189491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  }
190491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  bool hasStandardSelLocs() const {
191491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis    return getSelLocsKind() != SelLoc_NonStandard;
192491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  }
193491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis
194491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  /// \brief Get a pointer to the stored selector identifiers locations array.
195491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  /// No locations will be stored if HasStandardSelLocs is true.
196491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  SourceLocation *getStoredSelLocs() {
197491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis    return reinterpret_cast<SourceLocation*>(getParams() + NumParams);
198491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  }
199491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  const SourceLocation *getStoredSelLocs() const {
200491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis    return reinterpret_cast<const SourceLocation*>(getParams() + NumParams);
201491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  }
202491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis
203491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  /// \brief Get a pointer to the stored selector identifiers locations array.
204491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  /// No locations will be stored if HasStandardSelLocs is true.
205491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  ParmVarDecl **getParams() {
206491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis    return reinterpret_cast<ParmVarDecl **>(ParamsAndSelLocs);
207491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  }
208491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  const ParmVarDecl *const *getParams() const {
209491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis    return reinterpret_cast<const ParmVarDecl *const *>(ParamsAndSelLocs);
210491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  }
211491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis
212491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  /// \brief Get the number of stored selector identifiers locations.
213491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  /// No locations will be stored if HasStandardSelLocs is true.
214491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  unsigned getNumStoredSelLocs() const {
215491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis    if (hasStandardSelLocs())
216491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis      return 0;
217491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis    return getNumSelectorLocs();
218491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  }
219491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis
220491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  void setParamsAndSelLocs(ASTContext &C,
221491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis                           ArrayRef<ParmVarDecl*> Params,
222491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis                           ArrayRef<SourceLocation> SelLocs);
223491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis
224a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc,
22558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff                 Selector SelInfo, QualType T,
2264bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor                 TypeSourceInfo *ResultTInfo,
2270701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff                 DeclContext *contextDecl,
228f6414927e67e27d9324d8d179c5f7ea620443924Daniel Dunbar                 bool isInstance = true,
22958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff                 bool isVariadic = false,
2304607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian                 bool isSynthesized = false,
23175cf3e86d33ce810c12084126385371b335c30baArgyrios Kyrtzidis                 bool isImplicitlyDeclared = false,
2323fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian                 bool isDefined = false,
2337732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian                 ImplementationControl impControl = None,
234da92a7f91cf88f49e02050919676f7fb8e3bdff8Argyrios Kyrtzidis                 bool HasRelatedResultType = false)
2354afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  : NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo),
23685f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall    DeclContext(ObjCMethod), Family(InvalidObjCMethodFamily),
23758dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff    IsInstance(isInstance), IsVariadic(isVariadic),
2384607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian    IsSynthesized(isSynthesized),
23972b2625aa67c8213acaf4bf6209b67859d60e2cfArgyrios Kyrtzidis    IsDefined(isDefined), IsRedeclaration(0), HasRedeclaration(0),
24058dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff    DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None),
241da92a7f91cf88f49e02050919676f7fb8e3bdff8Argyrios Kyrtzidis    RelatedResultType(HasRelatedResultType),
242e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis    SelLocsKind(SelLoc_StandardNoSpace), IsOverriding(0),
243926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor    MethodDeclType(T), ResultTInfo(ResultTInfo),
244491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis    ParamsAndSelLocs(0), NumParams(0),
245a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis    DeclEndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) {
24675cf3e86d33ce810c12084126385371b335c30baArgyrios Kyrtzidis    setImplicit(isImplicitlyDeclared);
24775cf3e86d33ce810c12084126385371b335c30baArgyrios Kyrtzidis  }
2488a779314870760848e61da2c428a78971fe3f1c3Ted Kremenek
24957ea6bee79cc60ba20c7886b453f40f380dce1b1Argyrios Kyrtzidis  /// \brief A definition will return its interface declaration.
25057ea6bee79cc60ba20c7886b453f40f380dce1b1Argyrios Kyrtzidis  /// An interface declaration will return its definition.
25157ea6bee79cc60ba20c7886b453f40f380dce1b1Argyrios Kyrtzidis  /// Otherwise it will return itself.
252da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor  virtual ObjCMethodDecl *getNextRedeclaration();
253da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor
2546c4ae5de0c356777446f823b573821fb95560d91Chris Lattnerpublic:
2550ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner  static ObjCMethodDecl *Create(ASTContext &C,
2561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                SourceLocation beginLoc,
25711d77169555480ee0a04c6e5bc390d8fde41175dArgyrios Kyrtzidis                                SourceLocation endLoc,
25811d77169555480ee0a04c6e5bc390d8fde41175dArgyrios Kyrtzidis                                Selector SelInfo,
259ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie                                QualType T,
2604bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor                                TypeSourceInfo *ResultTInfo,
2614bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor                                DeclContext *contextDecl,
262f6414927e67e27d9324d8d179c5f7ea620443924Daniel Dunbar                                bool isInstance = true,
2636c4ae5de0c356777446f823b573821fb95560d91Chris Lattner                                bool isVariadic = false,
2644607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian                                bool isSynthesized = false,
26575cf3e86d33ce810c12084126385371b335c30baArgyrios Kyrtzidis                                bool isImplicitlyDeclared = false,
2663fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian                                bool isDefined = false,
2677732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian                                ImplementationControl impControl = None,
268da92a7f91cf88f49e02050919676f7fb8e3bdff8Argyrios Kyrtzidis                                bool HasRelatedResultType = false);
269e7f9d301a10b4b3223e91d9be4362b44cba0a212Argyrios Kyrtzidis
2701e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor  static ObjCMethodDecl *CreateDeserialized(ASTContext &C, unsigned ID);
2711e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor
272da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor  virtual ObjCMethodDecl *getCanonicalDecl();
27313e635c55eb23f736d38abf9c954801bd6482db4Ted Kremenek  const ObjCMethodDecl *getCanonicalDecl() const {
27413e635c55eb23f736d38abf9c954801bd6482db4Ted Kremenek    return const_cast<ObjCMethodDecl*>(this)->getCanonicalDecl();
27513e635c55eb23f736d38abf9c954801bd6482db4Ted Kremenek  }
276e7f9d301a10b4b3223e91d9be4362b44cba0a212Argyrios Kyrtzidis
277ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  ObjCDeclQualifier getObjCDeclQualifier() const {
278ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek    return ObjCDeclQualifier(objcDeclQualifier);
279ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  }
280a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  void setObjCDeclQualifier(ObjCDeclQualifier QV) { objcDeclQualifier = QV; }
2811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
282926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor  /// \brief Determine whether this method has a result type that is related
283926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor  /// to the message receiver's type.
284926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor  bool hasRelatedResultType() const { return RelatedResultType; }
285ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
286926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor  /// \brief Note whether this method has a related result type.
287926df6cfabf3eaa4afc990c097fa4619b76a9b57Douglas Gregor  void SetRelatedResultType(bool RRT = true) { RelatedResultType = RRT; }
2883a919e7110407ae7609bb6edc57aac16a5990661Argyrios Kyrtzidis
2893a919e7110407ae7609bb6edc57aac16a5990661Argyrios Kyrtzidis  /// \brief True if this is a method redeclaration in the same interface.
2903a919e7110407ae7609bb6edc57aac16a5990661Argyrios Kyrtzidis  bool isRedeclaration() const { return IsRedeclaration; }
2913a919e7110407ae7609bb6edc57aac16a5990661Argyrios Kyrtzidis  void setAsRedeclaration(const ObjCMethodDecl *PrevMethod);
292ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
293a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis  /// \brief Returns the location where the declarator ends. It will be
294a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis  /// the location of ';' for a method declaration and the location of '{'
295a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis  /// for a method definition.
296a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis  SourceLocation getDeclaratorEndLoc() const { return DeclEndLoc; }
297a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis
29858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  // Location information, modeled after the Stmt API.
299aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar  SourceLocation getLocStart() const LLVM_READONLY { return getLocation(); }
300a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis  SourceLocation getLocEnd() const LLVM_READONLY;
301aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar  virtual SourceRange getSourceRange() const LLVM_READONLY {
302a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis    return SourceRange(getLocation(), getLocEnd());
3039776ba0d844cf9f6888e871e3fd246ae782f76f4Daniel Dunbar  }
3041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
305746f5bcbfde5b25269169c63c66492311673b67dArgyrios Kyrtzidis  SourceLocation getSelectorStartLoc() const {
306746f5bcbfde5b25269169c63c66492311673b67dArgyrios Kyrtzidis    if (isImplicit())
307746f5bcbfde5b25269169c63c66492311673b67dArgyrios Kyrtzidis      return getLocStart();
308746f5bcbfde5b25269169c63c66492311673b67dArgyrios Kyrtzidis    return getSelectorLoc(0);
309746f5bcbfde5b25269169c63c66492311673b67dArgyrios Kyrtzidis  }
310491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  SourceLocation getSelectorLoc(unsigned Index) const {
311491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis    assert(Index < getNumSelectorLocs() && "Index out of range!");
312491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis    if (hasStandardSelLocs())
313491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis      return getStandardSelectorLoc(Index, getSelector(),
314491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis                                   getSelLocsKind() == SelLoc_StandardWithSpace,
315491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis                      llvm::makeArrayRef(const_cast<ParmVarDecl**>(getParams()),
316491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis                                         NumParams),
317a0cff720d40f239fee0e5ecc8378122b456c1991Argyrios Kyrtzidis                                   DeclEndLoc);
318491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis    return getStoredSelLocs()[Index];
319491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  }
320491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis
321491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  void getSelectorLocs(SmallVectorImpl<SourceLocation> &SelLocs) const;
322491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis
323491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  unsigned getNumSelectorLocs() const {
324491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis    if (isImplicit())
325491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis      return 0;
326491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis    Selector Sel = getSelector();
327491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis    if (Sel.isUnarySelector())
328491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis      return 1;
329491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis    return Sel.getNumArgs();
330491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  }
331491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis
3325619688510185081cbb4621d703daf7ee24cf39aChris Lattner  ObjCInterfaceDecl *getClassInterface();
3335619688510185081cbb4621d703daf7ee24cf39aChris Lattner  const ObjCInterfaceDecl *getClassInterface() const {
3345619688510185081cbb4621d703daf7ee24cf39aChris Lattner    return const_cast<ObjCMethodDecl*>(this)->getClassInterface();
335e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  }
3361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3372e1cd4264d363ca869bf37ef160902f211d21b8cDouglas Gregor  Selector getSelector() const { return getDeclName().getObjCSelector(); }
3383a082d81006e7a2e01a6e431a22e21c78490ff8fAnders Carlsson
33958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  QualType getResultType() const { return MethodDeclType; }
34053c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff  void setResultType(QualType T) { MethodDeclType = T; }
3411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
342ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  /// \brief Determine the type of an expression that sends a message to this
3435291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor  /// function.
3445291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor  QualType getSendResultType() const {
3456398235d7890a81b785ea5af3b6e66d86bf184ccDouglas Gregor    return getResultType().getNonLValueExprType(getASTContext());
3465291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor  }
347ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
3484bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor  TypeSourceInfo *getResultTypeSourceInfo() const { return ResultTInfo; }
3494bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor  void setResultTypeSourceInfo(TypeSourceInfo *TInfo) { ResultTInfo = TInfo; }
3504bc1cb6aa635a5bf8fae99bf69c56c724c1e786cDouglas Gregor
351d57f635d520e8cb5b93d3d770ff58db06c62de54Chris Lattner  // Iterator access to formal parameters.
352491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  unsigned param_size() const { return NumParams; }
353491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  typedef const ParmVarDecl *const *param_const_iterator;
354491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  typedef ParmVarDecl *const *param_iterator;
355491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  param_const_iterator param_begin() const { return getParams(); }
356491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  param_const_iterator param_end() const { return getParams() + NumParams; }
357491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  param_iterator param_begin() { return getParams(); }
358491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  param_iterator param_end() { return getParams() + NumParams; }
3597732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian  // This method returns and of the parameters which are part of the selector
3607732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian  // name mangling requirements.
361ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  param_const_iterator sel_param_end() const {
362ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie    return param_begin() + getSelector().getNumArgs();
3637732cc9c0fdc97a2f8cce4e5933d8103213d1aefFariborz Jahanian  }
36489951a86b594513c2a013532ed45d197413b1087Chris Lattner
3659dd0065e61ea4b48b19eee550704ce964e64e946Argyrios Kyrtzidis  /// \brief Sets the method's parameters and selector source locations.
3669dd0065e61ea4b48b19eee550704ce964e64e946Argyrios Kyrtzidis  /// If the method is implicit (not coming from source) \arg SelLocs is
3679dd0065e61ea4b48b19eee550704ce964e64e946Argyrios Kyrtzidis  /// ignored.
368491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  void setMethodParams(ASTContext &C,
369491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis                       ArrayRef<ParmVarDecl*> Params,
3709dd0065e61ea4b48b19eee550704ce964e64e946Argyrios Kyrtzidis                       ArrayRef<SourceLocation> SelLocs =
3719dd0065e61ea4b48b19eee550704ce964e64e946Argyrios Kyrtzidis                           ArrayRef<SourceLocation>());
3724111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner
3736ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson  // Iterator access to parameter types.
3746ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson  typedef std::const_mem_fun_t<QualType, ParmVarDecl> deref_fun;
375491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  typedef llvm::mapped_iterator<param_const_iterator, deref_fun>
376491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis      arg_type_iterator;
3776ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson
3786ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson  arg_type_iterator arg_type_begin() const {
3796ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson    return llvm::map_iterator(param_begin(), deref_fun(&ParmVarDecl::getType));
3806ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson  }
3816ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson  arg_type_iterator arg_type_end() const {
3826ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson    return llvm::map_iterator(param_end(), deref_fun(&ParmVarDecl::getType));
3836ea8e2152e1ba93b4c80e7268403a582896dc3dcAnders Carlsson  }
3841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
385451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// createImplicitParams - Used to lazily create the self and cmd
386451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// implict parameters. This must be called prior to using getSelfDecl()
387451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// or getCmdDecl(). The call is ignored if the implicit paramters
388451318c08a6342c10b8986060386fd9274418437Daniel Dunbar  /// have already been created.
389fef30b55230064d334a669a065a1c9acdb87cdfeFariborz Jahanian  void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID);
390451318c08a6342c10b8986060386fd9274418437Daniel Dunbar
3914111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner  ImplicitParamDecl * getSelfDecl() const { return SelfDecl; }
39253c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff  void setSelfDecl(ImplicitParamDecl *SD) { SelfDecl = SD; }
3934111024be81e7c0525e42dadcc126d27e5bf2425Chris Lattner  ImplicitParamDecl * getCmdDecl() const { return CmdDecl; }
39453c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff  void setCmdDecl(ImplicitParamDecl *CD) { CmdDecl = CD; }
3951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
39685f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  /// Determines the family of this method.
39785f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall  ObjCMethodFamily getMethodFamily() const;
39885f3d76c0ecfdefcf83ea44a57b7a16119c8a045John McCall
399f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor  bool isInstanceMethod() const { return IsInstance; }
40053c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff  void setInstanceMethod(bool isInst) { IsInstance = isInst; }
40158dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  bool isVariadic() const { return IsVariadic; }
40253c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff  void setVariadic(bool isVar) { IsVariadic = isVar; }
4031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
404f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor  bool isClassMethod() const { return !IsInstance; }
405f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor
4064607034e621aa77378ec75249d1e9eaf5de49b6aFariborz Jahanian  bool isSynthesized() const { return IsSynthesized; }
40753c9d8a4b8f0a76cb9dd2fdd8c433ccf110f2eecSteve Naroff  void setSynthesized(bool isSynth) { IsSynthesized = isSynth; }
408ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
4093fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian  bool isDefined() const { return IsDefined; }
4103fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian  void setDefined(bool isDefined) { IsDefined = isDefined; }
4111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
412e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  /// \brief Whether this method overrides any other in the class hierarchy.
413e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  ///
414e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  /// A method is said to override any method in the class's
415e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  /// base classes, its protocols, or its categories' protocols, that has
416e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  /// the same selector and is of the same kind (class or instance).
417e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  /// A method in an implementation is not considered as overriding the same
418e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  /// method in the interface or its categories.
419e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  bool isOverriding() const { return IsOverriding; }
420e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis  void setOverriding(bool isOverriding) { IsOverriding = isOverriding; }
421e15db6f0d226a3bc88d244512d1004c7c1c07391Argyrios Kyrtzidis
42241c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  // Related to protocols declared in  \@protocol
4231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  void setDeclImplementation(ImplementationControl ic) {
4241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    DeclImplementation = ic;
42558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  }
4261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ImplementationControl getImplementationControl() const {
4271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return ImplementationControl(DeclImplementation);
42858dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  }
429792481eec23d8c1aa92173be589e2ae9d02514a5Ted Kremenek
430da2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0Douglas Gregor  virtual Stmt *getBody() const {
4311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return (Stmt*) Body;
4327297134f128423fce2e88f92421ed135bded7d4eDouglas Gregor  }
4336fb0aee4f9dc261bbec72e1283ad8dc0557a6d96Argyrios Kyrtzidis  CompoundStmt *getCompoundBody() { return (CompoundStmt*)Body; }
434d3a413d3b8eb39bcee5944bc545d9997c1abe492Sebastian Redl  void setBody(Stmt *B) { Body = B; }
43558dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff
43666570b230941651245accbc5680b60e904eb993cArgyrios Kyrtzidis  /// \brief Returns whether this specific method is a definition.
43766570b230941651245accbc5680b60e904eb993cArgyrios Kyrtzidis  bool isThisDeclarationADefinition() const { return Body; }
43866570b230941651245accbc5680b60e904eb993cArgyrios Kyrtzidis
43958dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff  // Implement isa/cast/dyncast/etc.
44080cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
441a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCMethodDecl *D) { return true; }
44280cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCMethod; }
44342220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis  static DeclContext *castToDeclContext(const ObjCMethodDecl *D) {
44442220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis    return static_cast<DeclContext *>(const_cast<ObjCMethodDecl*>(D));
44542220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis  }
44642220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis  static ObjCMethodDecl *castFromDeclContext(const DeclContext *DC) {
44742220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis    return static_cast<ObjCMethodDecl *>(const_cast<DeclContext*>(DC));
44842220c5432c141d47cc8ce786e472b49dc907378Argyrios Kyrtzidis  }
449491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis
450491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  friend class ASTDeclReader;
451491306a83c4f0f49f95a3bcbca8580cb98a91c7aArgyrios Kyrtzidis  friend class ASTDeclWriter;
45258dbdeb69c063f82d644504fc638120198f7fad2Steve Naroff};
453e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
454e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff/// ObjCContainerDecl - Represents a container for method declarations.
455aecae629269fae3bf484baf1d109e9a89d14eeadArgyrios Kyrtzidis/// Current sub-classes are ObjCInterfaceDecl, ObjCCategoryDecl,
4561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// ObjCProtocolDecl, and ObjCImplDecl.
457e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff///
4584afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCContainerDecl : public NamedDecl, public DeclContext {
45999ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie  virtual void anchor();
46099ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie
4611711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis  SourceLocation AtStart;
4621711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis
463782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek  // These two locations in the range mark the end of the method container.
464782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek  // The first points to the '@' token, and the second to the 'end' token.
465782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek  SourceRange AtEnd;
466e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroffpublic:
467e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
4681711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis  ObjCContainerDecl(Kind DK, DeclContext *DC,
4691711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis                    IdentifierInfo *Id, SourceLocation nameLoc,
4701711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis                    SourceLocation atStartLoc)
4711711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis    : NamedDecl(DK, DC, nameLoc, Id), DeclContext(DK), AtStart(atStartLoc) {}
472e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
47393983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff  // Iterator access to properties.
47493983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff  typedef specific_decl_iterator<ObjCPropertyDecl> prop_iterator;
4751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  prop_iterator prop_begin() const {
47617945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return prop_iterator(decls_begin());
47793983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff  }
4781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  prop_iterator prop_end() const {
47917945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return prop_iterator(decls_end());
48009c4719788a5cea09897525e528fa00420f1677bSteve Naroff  }
4811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
4820701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  // Iterator access to instance/class methods.
483f8d49f64ef6ab7e632717a31631fc289aab69428Douglas Gregor  typedef specific_decl_iterator<ObjCMethodDecl> method_iterator;
4841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  method_iterator meth_begin() const {
48517945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return method_iterator(decls_begin());
4867ed4faca5162b3ab85be7f7e57aa40e6ec170971Ted Kremenek  }
4871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  method_iterator meth_end() const {
48817945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return method_iterator(decls_end());
4897ed4faca5162b3ab85be7f7e57aa40e6ec170971Ted Kremenek  }
4900701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff
4911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  typedef filtered_decl_iterator<ObjCMethodDecl,
4921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                 &ObjCMethodDecl::isInstanceMethod>
493669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor    instmeth_iterator;
49417945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  instmeth_iterator instmeth_begin() const {
49517945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return instmeth_iterator(decls_begin());
496e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff  }
49717945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  instmeth_iterator instmeth_end() const {
49817945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return instmeth_iterator(decls_end());
499e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff  }
500e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
5011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  typedef filtered_decl_iterator<ObjCMethodDecl,
5021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                 &ObjCMethodDecl::isClassMethod>
503669c9a28fa4be35e6b6322aa7f2f3b2968189b80Douglas Gregor    classmeth_iterator;
50417945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  classmeth_iterator classmeth_begin() const {
50517945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return classmeth_iterator(decls_begin());
506e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff  }
50717945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  classmeth_iterator classmeth_end() const {
50817945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return classmeth_iterator(decls_end());
5090701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  }
5100701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff
5110701bbb228dfd87e1fe82a0a4b7b9facfecb43daSteve Naroff  // Get the local instance/class method declared in this interface.
512467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis  ObjCMethodDecl *getMethod(Selector Sel, bool isInstance) const;
513467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis  ObjCMethodDecl *getInstanceMethod(Selector Sel) const {
514467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis    return getMethod(Sel, true/*isInstance*/);
51553df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner  }
516467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis  ObjCMethodDecl *getClassMethod(Selector Sel) const {
517467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis    return getMethod(Sel, false/*isInstance*/);
518467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis  }
519467c0b165072689ef87fe8d9cd47a5b63485bcdcArgyrios Kyrtzidis  ObjCIvarDecl *getIvarDecl(IdentifierInfo *Id) const;
5201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
52117945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const;
52293983f8fa120330bf212bfde7e65da2709fb3be8Steve Naroff
5231711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis  SourceLocation getAtStartLoc() const { return AtStart; }
5241711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis  void setAtStartLoc(SourceLocation Loc) { AtStart = Loc; }
5251711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis
526e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff  // Marks the end of the container.
527782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek  SourceRange getAtEndRange() const {
528782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek    return AtEnd;
529782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek  }
530782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek  void setAtEndRange(SourceRange atEnd) {
531782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek    AtEnd = atEnd;
532782f2f52b78d8ca785110398a7f7b56b830b9ac7Ted Kremenek  }
533ddfd4c9eda34765b08fae4cb31ad5a365face107Argyrios Kyrtzidis
534aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar  virtual SourceRange getSourceRange() const LLVM_READONLY {
5351711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis    return SourceRange(AtStart, getAtEndRange().getEnd());
536ddfd4c9eda34765b08fae4cb31ad5a365face107Argyrios Kyrtzidis  }
5371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
53809c4719788a5cea09897525e528fa00420f1677bSteve Naroff  // Implement isa/cast/dyncast/etc.
53980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
54009c4719788a5cea09897525e528fa00420f1677bSteve Naroff  static bool classof(const ObjCContainerDecl *D) { return true; }
54180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) {
5429a55591af3e5506b95a9718e15380129fbfc5ebcSean Hunt    return K >= firstObjCContainer &&
5439a55591af3e5506b95a9718e15380129fbfc5ebcSean Hunt           K <= lastObjCContainer;
54480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  }
54509c4719788a5cea09897525e528fa00420f1677bSteve Naroff
54609c4719788a5cea09897525e528fa00420f1677bSteve Naroff  static DeclContext *castToDeclContext(const ObjCContainerDecl *D) {
54709c4719788a5cea09897525e528fa00420f1677bSteve Naroff    return static_cast<DeclContext *>(const_cast<ObjCContainerDecl*>(D));
54809c4719788a5cea09897525e528fa00420f1677bSteve Naroff  }
54909c4719788a5cea09897525e528fa00420f1677bSteve Naroff  static ObjCContainerDecl *castFromDeclContext(const DeclContext *DC) {
55009c4719788a5cea09897525e528fa00420f1677bSteve Naroff    return static_cast<ObjCContainerDecl *>(const_cast<DeclContext*>(DC));
55109c4719788a5cea09897525e528fa00420f1677bSteve Naroff  }
552e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff};
553e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroff
5540982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \brief Represents an ObjC class declaration.
5550c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
5560982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// For example:
5570982205bade2fb4fc984c27b2ab401e683963b10James Dennett///
5580982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \code
5590c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   // MostPrimitive declares no super class (not particularly useful).
56041c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth///   \@interface MostPrimitive
5610c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     // no instance variables or methods.
56241c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth///   \@end
5630c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
5641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///   // NSResponder inherits from NSObject & implements NSCoding (a protocol).
5650982205bade2fb4fc984c27b2ab401e683963b10James Dennett///   \@interface NSResponder : NSObject \<NSCoding>
566a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek///   { // instance variables are represented by ObjCIvarDecl.
5670c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id nextResponder; // nextResponder instance variable.
5680c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   }
5690c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   - (NSResponder *)nextResponder; // return a pointer to NSResponder.
5700c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   - (void)mouseMoved:(NSEvent *)theEvent; // return void, takes a pointer
57141c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth///   \@end                                    // to an NSEvent.
5720982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \endcode
5730c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
57441c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth///   Unlike C/C++, forward class declarations are accomplished with \@class.
57541c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth///   Unlike C/C++, \@class allows for a list of classes to be forward declared.
5760c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   Unlike C++, ObjC is a single-rooted class model. In Cocoa, classes
5770c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   typically inherit from NSObject (an exception is NSProxy).
5780c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
57953df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregorclass ObjCInterfaceDecl : public ObjCContainerDecl
58053df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor                        , public Redeclarable<ObjCInterfaceDecl> {
58199ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie  virtual void anchor();
58299ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie
5833110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff  /// TypeForDecl - This indicates the Type object that represents this
5843110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff  /// TypeDecl.  It is a cache maintained by ASTContext::getObjCInterfaceType
585f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall  mutable const Type *TypeForDecl;
5863110251f13981689f384eb3c0aba2afffea18d9dSteve Naroff  friend class ASTContext;
5872e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
5882e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  struct DefinitionData {
58926fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor    /// \brief The definition of this class, for quick access from any
59026fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor    /// declaration.
59126fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor    ObjCInterfaceDecl *Definition;
59226fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor
5932e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    /// Class's super class.
5942e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    ObjCInterfaceDecl *SuperClass;
5951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
59641c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth    /// Protocols referenced in the \@interface  declaration
5972e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    ObjCProtocolList ReferencedProtocols;
5981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
59941c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth    /// Protocols reference in both the \@interface and class extensions.
6002e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    ObjCList<ObjCProtocolDecl> AllReferencedProtocols;
601ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
6022e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    /// \brief List of categories and class extensions defined for this class.
6032e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    ///
6042e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    /// Categories are stored as a linked list in the AST, since the categories
6052e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    /// and class extensions come long after the initial interface declaration,
6062e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    /// and we avoid dynamically-resized arrays in the AST wherever possible.
6072e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    ObjCCategoryDecl *CategoryList;
6081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
6092e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    /// IvarList - List of all ivars defined by this class; including class
6102e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    /// extensions and implementation. This list is built lazily.
6112e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    ObjCIvarDecl *IvarList;
612ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
6132e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    /// \brief Indicates that the contents of this Objective-C class will be
6142e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    /// completed by the external AST source when required.
6152e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    mutable bool ExternallyCompleted : 1;
6162e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
61705c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor    /// \brief The location of the superclass, if any.
61805c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor    SourceLocation SuperClassLoc;
619161794732195881c33305f701f6e58721998541fDouglas Gregor
62005c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor    /// \brief The location of the last location in this declaration, before
62105c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor    /// the properties/methods. For example, this will be the '>', '}', or
62205c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor    /// identifier,
62305c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor    SourceLocation EndLoc;
62405c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor
62526fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor    DefinitionData() : Definition(), SuperClass(), CategoryList(), IvarList(),
626161794732195881c33305f701f6e58721998541fDouglas Gregor                       ExternallyCompleted() { }
6272e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  };
6282e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
6292e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  ObjCInterfaceDecl(DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id,
63037f953f021c67e3b97f1ef38e1ef3cb08bd9d146Douglas Gregor                    SourceLocation CLoc, ObjCInterfaceDecl *PrevDecl,
63137f953f021c67e3b97f1ef38e1ef3cb08bd9d146Douglas Gregor                    bool isInternal);
6322e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
6332e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  void LoadExternalDefinition() const;
6342e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
6352e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  /// \brief Contains a pointer to the data associated with this class,
6362e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  /// which will be NULL if this class has not yet been defined.
63726fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor  DefinitionData *Data;
6382e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
6392e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  DefinitionData &data() const {
64026fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor    assert(Data != 0 && "Declaration has no definition!");
64126fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor    return *Data;
6422e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  }
6431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
6442e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  /// \brief Allocate the definition data for this class.
6452e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  void allocateDefinitionData();
6462e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
64753df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor  typedef Redeclarable<ObjCInterfaceDecl> redeclarable_base;
64853df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor  virtual ObjCInterfaceDecl *getNextRedeclaration() {
64953df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor    return RedeclLink.getNext();
65053df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor  }
651ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor  virtual ObjCInterfaceDecl *getPreviousDeclImpl() {
652ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor    return getPreviousDecl();
653ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor  }
654ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor  virtual ObjCInterfaceDecl *getMostRecentDeclImpl() {
655ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor    return getMostRecentDecl();
656ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor  }
65753df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor
6580e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattnerpublic:
659a6ea10e22b600d92e084f6b11b9b9a92d0eb2412Douglas Gregor  static ObjCInterfaceDecl *Create(const ASTContext &C, DeclContext *DC,
6600ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner                                   SourceLocation atLoc,
6611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                   IdentifierInfo *Id,
6620af550115df1f57f17a4f125ff0e8b34820c65d1Douglas Gregor                                   ObjCInterfaceDecl *PrevDecl,
663deacbdca554298ccdf636f19c6094a8825ec6b34Douglas Gregor                                   SourceLocation ClassLoc = SourceLocation(),
6640e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattner                                   bool isInternal = false);
665d1cf3ff6c7e34fce764293cd2900fce99a60ed69Argyrios Kyrtzidis
6661e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor  static ObjCInterfaceDecl *CreateDeserialized(ASTContext &C, unsigned ID);
6670af550115df1f57f17a4f125ff0e8b34820c65d1Douglas Gregor
668aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar  virtual SourceRange getSourceRange() const LLVM_READONLY {
6697723fec9b45b7258c0eddf4cbfd0d335348f5edcDouglas Gregor    if (isThisDeclarationADefinition())
6707723fec9b45b7258c0eddf4cbfd0d335348f5edcDouglas Gregor      return ObjCContainerDecl::getSourceRange();
6717723fec9b45b7258c0eddf4cbfd0d335348f5edcDouglas Gregor
6727723fec9b45b7258c0eddf4cbfd0d335348f5edcDouglas Gregor    return SourceRange(getAtStartLoc(), getLocation());
673d1cf3ff6c7e34fce764293cd2900fce99a60ed69Argyrios Kyrtzidis  }
674ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
67526ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  /// \brief Indicate that this Objective-C class is complete, but that
67626ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  /// the external AST source will be responsible for filling in its contents
67726ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  /// when a complete class is required.
67826ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  void setExternallyCompleted();
679ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
68018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  const ObjCProtocolList &getReferencedProtocols() const {
681a5f4441de7890953460d95f4e88b9fa432b48dc2Argyrios Kyrtzidis    assert(hasDefinition() && "Caller did not check for forward reference!");
6822e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (data().ExternallyCompleted)
68326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
684ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
6852e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    return data().ReferencedProtocols;
6867ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  }
6878a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis
6888a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis  ObjCImplementationDecl *getImplementation() const;
6898a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis  void setImplementation(ObjCImplementationDecl *ImplD);
6908a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis
691559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  ObjCCategoryDecl *FindCategoryDeclaration(IdentifierInfo *CategoryId) const;
6921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
6931cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis  // Get the local instance/class method declared in a category.
6941cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis  ObjCMethodDecl *getCategoryInstanceMethod(Selector Sel) const;
6951cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis  ObjCMethodDecl *getCategoryClassMethod(Selector Sel) const;
6961cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis  ObjCMethodDecl *getCategoryMethod(Selector Sel, bool isInstance) const {
6971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return isInstance ? getInstanceMethod(Sel)
6981cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis                      : getClassMethod(Sel);
6991cb35dd4840d21cec58648361180d5688446a9caArgyrios Kyrtzidis  }
7003db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner
70118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  typedef ObjCProtocolList::iterator protocol_iterator;
702ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
70353b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  protocol_iterator protocol_begin() const {
7042e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    // FIXME: Should make sure no callers ever do this.
7052e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (!hasDefinition())
7062e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor      return protocol_iterator();
7072e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
7082e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (data().ExternallyCompleted)
70926ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
71026ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
7112e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    return data().ReferencedProtocols.begin();
71253b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  }
71353b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  protocol_iterator protocol_end() const {
7142e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    // FIXME: Should make sure no callers ever do this.
7152e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (!hasDefinition())
7162e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor      return protocol_iterator();
7172e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
7182e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (data().ExternallyCompleted)
71926ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
72026ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
7212e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    return data().ReferencedProtocols.end();
72253b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  }
72353b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
72418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  typedef ObjCProtocolList::loc_iterator protocol_loc_iterator;
72553b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
726ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  protocol_loc_iterator protocol_loc_begin() const {
7272e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    // FIXME: Should make sure no callers ever do this.
7282e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (!hasDefinition())
7292e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor      return protocol_loc_iterator();
7302e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
7312e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (data().ExternallyCompleted)
73226ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
73326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
7342e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    return data().ReferencedProtocols.loc_begin();
73518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  }
73653b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
737ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  protocol_loc_iterator protocol_loc_end() const {
7382e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    // FIXME: Should make sure no callers ever do this.
7392e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (!hasDefinition())
7402e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor      return protocol_loc_iterator();
7412e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
7422e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (data().ExternallyCompleted)
74326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
74426ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
7452e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    return data().ReferencedProtocols.loc_end();
74618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  }
747ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
74853b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  typedef ObjCList<ObjCProtocolDecl>::iterator all_protocol_iterator;
749ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
75053b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  all_protocol_iterator all_referenced_protocol_begin() const {
7512e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    // FIXME: Should make sure no callers ever do this.
7522e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (!hasDefinition())
7532e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor      return all_protocol_iterator();
7542e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
7552e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (data().ExternallyCompleted)
75626ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
75726ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
7582e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    return data().AllReferencedProtocols.empty()
7592e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor             ? protocol_begin()
7602e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor             : data().AllReferencedProtocols.begin();
76153b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  }
76253b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  all_protocol_iterator all_referenced_protocol_end() const {
7632e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    // FIXME: Should make sure no callers ever do this.
7642e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (!hasDefinition())
7652e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor      return all_protocol_iterator();
7662e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
7672e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (data().ExternallyCompleted)
76826ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
76926ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
7702e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    return data().AllReferencedProtocols.empty()
7712e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor             ? protocol_end()
7722e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor             : data().AllReferencedProtocols.end();
77353b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  }
774291be393aa33759e6e34b6429c5ffa206ba50115Douglas Gregor
77511062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian  typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator;
77653b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
7772e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  ivar_iterator ivar_begin() const {
7782e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (const ObjCInterfaceDecl *Def = getDefinition())
7792e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor      return ivar_iterator(Def->decls_begin());
7802e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
7812e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    // FIXME: Should make sure no callers ever do this.
7822e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    return ivar_iterator();
7832e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  }
7842e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  ivar_iterator ivar_end() const {
7852e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (const ObjCInterfaceDecl *Def = getDefinition())
7862e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor      return ivar_iterator(Def->decls_end());
7872e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
7882e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    // FIXME: Should make sure no callers ever do this.
7892e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    return ivar_iterator();
7902e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  }
79153b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
79211062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian  unsigned ivar_size() const {
79311062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian    return std::distance(ivar_begin(), ivar_end());
79411062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian  }
795ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
79611062e11236b7bc689dad150e8b490fd6b063ec3Fariborz Jahanian  bool ivar_empty() const { return ivar_begin() == ivar_end(); }
797ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
798db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose  ObjCIvarDecl *all_declared_ivar_begin();
799db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose  const ObjCIvarDecl *all_declared_ivar_begin() const {
800db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose    // Even though this modifies IvarList, it's conceptually const:
801db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose    // the ivar chain is essentially a cached property of ObjCInterfaceDecl.
802db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose    return const_cast<ObjCInterfaceDecl *>(this)->all_declared_ivar_begin();
803db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose  }
8042e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  void setIvarList(ObjCIvarDecl *ivar) { data().IvarList = ivar; }
805ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
80638af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner  /// setProtocolList - Set the list of protocols that this interface
807b752f289026ad8e5f44851b20e009a27ed61eefcChris Lattner  /// implements.
80838af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner  void setProtocolList(ObjCProtocolDecl *const* List, unsigned Num,
80918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor                       const SourceLocation *Locs, ASTContext &C) {
8102e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    data().ReferencedProtocols.set(List, Num, Locs, C);
8113db6cae19c236fe2cef343c90105ce7cca7de965Chris Lattner  }
8121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
813339798eae1eb61c50ca68766ed028c0a16d0a284Fariborz Jahanian  /// mergeClassExtensionProtocolList - Merge class extension's protocol list
814339798eae1eb61c50ca68766ed028c0a16d0a284Fariborz Jahanian  /// into the protocol list for this class.
815ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  void mergeClassExtensionProtocolList(ObjCProtocolDecl *const* List,
81618df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor                                       unsigned Num,
81718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor                                       ASTContext &C);
818339798eae1eb61c50ca68766ed028c0a16d0a284Fariborz Jahanian
81953df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor  /// \brief Determine whether this particular declaration of this class is
82053df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor  /// actually also a definition.
82126fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor  bool isThisDeclarationADefinition() const {
8227723fec9b45b7258c0eddf4cbfd0d335348f5edcDouglas Gregor    return Data && Data->Definition == this;
82326fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor  }
82453df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor
8252e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  /// \brief Determine whether this class has been defined.
82626fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor  bool hasDefinition() const { return Data; }
82753df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor
8282e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  /// \brief Retrieve the definition of this class, or NULL if this class
82941c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// has been forward-declared (with \@class) but not yet defined (with
83041c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// \@interface).
8312e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  ObjCInterfaceDecl *getDefinition() {
83226fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor    return hasDefinition()? Data->Definition : 0;
8332e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  }
834ad834d534e9a5db3d3baa09593775f83ceaff1f2Argyrios Kyrtzidis
8352e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  /// \brief Retrieve the definition of this class, or NULL if this class
83641c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// has been forward-declared (with \@class) but not yet defined (with
83741c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// \@interface).
8382e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  const ObjCInterfaceDecl *getDefinition() const {
83926fec63b14565e9e2d8c9935b276b99be950444aDouglas Gregor    return hasDefinition()? Data->Definition : 0;
8402e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  }
8411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
8422e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  /// \brief Starts the definition of this Objective-C class, taking it from
84341c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// a forward declaration (\@class) to a definition (\@interface).
8442e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  void startDefinition();
8452e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
846ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  ObjCInterfaceDecl *getSuperClass() const {
8472e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    // FIXME: Should make sure no callers ever do this.
8482e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (!hasDefinition())
8492e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor      return 0;
8502e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
8512e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (data().ExternallyCompleted)
85226ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
85326ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
8542e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    return data().SuperClass;
85526ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  }
856ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
8572e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  void setSuperClass(ObjCInterfaceDecl * superCls) {
858712ef874534ee1bef41d1aa4664ae36148ec8b12Fariborz Jahanian    data().SuperClass =
859712ef874534ee1bef41d1aa4664ae36148ec8b12Fariborz Jahanian      (superCls && superCls->hasDefinition()) ? superCls->getDefinition()
860712ef874534ee1bef41d1aa4664ae36148ec8b12Fariborz Jahanian                                              : superCls;
8612e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  }
8621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
863ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  ObjCCategoryDecl* getCategoryList() const {
8642e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    // FIXME: Should make sure no callers ever do this.
8652e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (!hasDefinition())
8662e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor      return 0;
8672e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
8682e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    if (data().ExternallyCompleted)
86926ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor      LoadExternalDefinition();
87026ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor
8712e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    return data().CategoryList;
87226ac3f30ecef21749c00a4b1a08dd15d772dd5aaDouglas Gregor  }
873ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
8741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  void setCategoryList(ObjCCategoryDecl *category) {
8752e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor    data().CategoryList = category;
876980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
877ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
87880aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian  ObjCCategoryDecl* getFirstClassExtension() const;
87937cafb077ad5b170acae77e566638603011ef4c0Ted Kremenek
88037cafb077ad5b170acae77e566638603011ef4c0Ted Kremenek  ObjCPropertyDecl
88137cafb077ad5b170acae77e566638603011ef4c0Ted Kremenek    *FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId) const;
88237cafb077ad5b170acae77e566638603011ef4c0Ted Kremenek
88353efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner  /// isSuperClassOf - Return true if this class is the specified class or is a
88453efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner  /// super class of the specified interface class.
88553efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner  bool isSuperClassOf(const ObjCInterfaceDecl *I) const {
88653efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner    // If RHS is derived from LHS it is OK; else it is not OK.
88753efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner    while (I != NULL) {
88860ef308e51c71b760d7f598c1b763ceb7b768148Douglas Gregor      if (declaresSameEntity(this, I))
88953efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner        return true;
8902e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor
89153efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner      I = I->getSuperClass();
89253efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner    }
89353efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner    return false;
89453efc251792bf2c9c5f295bd3507facc51a1fe7eChris Lattner  }
8951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
8967263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian  /// isArcWeakrefUnavailable - Checks for a class or one of its super classes
8977263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian  /// to be incompatible with __weak references. Returns true if it is.
8987263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian  bool isArcWeakrefUnavailable() const {
8997263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian    const ObjCInterfaceDecl *Class = this;
9007263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian    while (Class) {
9017263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian      if (Class->hasAttr<ArcWeakrefUnavailableAttr>())
9027263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian        return true;
9037263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian      Class = Class->getSuperClass();
9047263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian   }
905ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie   return false;
9067263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian  }
9077263feeb367ab55af7e9a6fd701148b1b8264dbaFariborz Jahanian
90871207fc0470e1eee40a2951cd5cc3ff47725b755Ted Kremenek  /// isObjCRequiresPropertyDefs - Checks that a class or one of its super
90941c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// classes must not be auto-synthesized. Returns class decl. if it must not
91041c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// be; 0, otherwise.
91171207fc0470e1eee40a2951cd5cc3ff47725b755Ted Kremenek  const ObjCInterfaceDecl *isObjCRequiresPropertyDefs() const {
912e23dcf3524fe01208cc79e707412f0a5dd8eed7bFariborz Jahanian    const ObjCInterfaceDecl *Class = this;
913e23dcf3524fe01208cc79e707412f0a5dd8eed7bFariborz Jahanian    while (Class) {
91471207fc0470e1eee40a2951cd5cc3ff47725b755Ted Kremenek      if (Class->hasAttr<ObjCRequiresPropertyDefsAttr>())
915da611a74c408af0f9526acc690b85214bf180852Fariborz Jahanian        return Class;
916e23dcf3524fe01208cc79e707412f0a5dd8eed7bFariborz Jahanian      Class = Class->getSuperClass();
917e23dcf3524fe01208cc79e707412f0a5dd8eed7bFariborz Jahanian   }
918da611a74c408af0f9526acc690b85214bf180852Fariborz Jahanian   return 0;
919e23dcf3524fe01208cc79e707412f0a5dd8eed7bFariborz Jahanian  }
920e23dcf3524fe01208cc79e707412f0a5dd8eed7bFariborz Jahanian
92117945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName,
92268a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner                                       ObjCInterfaceDecl *&ClassDeclared);
92317945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName) {
92468a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner    ObjCInterfaceDecl *ClassDeclared;
92517945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return lookupInstanceVariable(IVarName, ClassDeclared);
92668a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner  }
92768a057b4292f5ff814ec8da53f6cda8cdcfbd2aeChris Lattner
92894a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff  // Lookup a method. First, we search locally. If a method isn't
92994a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff  // found, we search referenced protocols and class categories.
930bb3d14e55d267bf5228699c7bf0c8ccdb71c8f46Fariborz Jahanian  ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance,
931bf393be8a0b8b573ceb23ed19ac953832a2a69e4Fariborz Jahanian                               bool shallowCategoryLookup= false) const;
932bb3d14e55d267bf5228699c7bf0c8ccdb71c8f46Fariborz Jahanian  ObjCMethodDecl *lookupInstanceMethod(Selector Sel,
933bf393be8a0b8b573ceb23ed19ac953832a2a69e4Fariborz Jahanian                            bool shallowCategoryLookup = false) const {
934bf393be8a0b8b573ceb23ed19ac953832a2a69e4Fariborz Jahanian    return lookupMethod(Sel, true/*isInstance*/, shallowCategoryLookup);
935bb3d14e55d267bf5228699c7bf0c8ccdb71c8f46Fariborz Jahanian  }
936bb3d14e55d267bf5228699c7bf0c8ccdb71c8f46Fariborz Jahanian  ObjCMethodDecl *lookupClassMethod(Selector Sel,
937bf393be8a0b8b573ceb23ed19ac953832a2a69e4Fariborz Jahanian                     bool shallowCategoryLookup = false) const {
938bf393be8a0b8b573ceb23ed19ac953832a2a69e4Fariborz Jahanian    return lookupMethod(Sel, false/*isInstance*/, shallowCategoryLookup);
939aa5420c1e36ab8e0e4bb87239d8b73a3a8ce75dbArgyrios Kyrtzidis  }
940cd1876207f5564beba74e4b2524b664bdba0ba9fFariborz Jahanian  ObjCInterfaceDecl *lookupInheritedClass(const IdentifierInfo *ICName);
941ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
942e61354b274ec5aa6acf3d15271896ce7596bb123Anna Zaks  /// \brief Lookup a method in the classes implementation hierarchy.
943ca93ee707d9570b74d24c7d55defe18dac38bcc0Anna Zaks  ObjCMethodDecl *lookupPrivateMethod(const Selector &Sel,
944ca93ee707d9570b74d24c7d55defe18dac38bcc0Anna Zaks                                      bool Instance=true) const;
94560fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff
946e61354b274ec5aa6acf3d15271896ce7596bb123Anna Zaks  ObjCMethodDecl *lookupPrivateClassMethod(const Selector &Sel) {
947e61354b274ec5aa6acf3d15271896ce7596bb123Anna Zaks    return lookupPrivateMethod(Sel, false);
948e61354b274ec5aa6acf3d15271896ce7596bb123Anna Zaks  }
949e61354b274ec5aa6acf3d15271896ce7596bb123Anna Zaks
95005c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor  SourceLocation getEndOfDefinitionLoc() const {
95105c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor    if (!hasDefinition())
95205c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor      return getLocation();
95305c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor
95405c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor    return data().EndLoc;
95505c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor  }
95605c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor
95705c272fed899b8d3142cf080e86a235fc6168862Douglas Gregor  void setEndOfDefinitionLoc(SourceLocation LE) { data().EndLoc = LE; }
9581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
9592e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  void setSuperClassLoc(SourceLocation Loc) { data().SuperClassLoc = Loc; }
9602e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor  SourceLocation getSuperClassLoc() const { return data().SuperClassLoc; }
9611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
96228e71cf851b73a67604735a9a95aef800b144e2eSteve Naroff  /// isImplicitInterfaceDecl - check that this is an implicitly declared
96341c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// ObjCInterfaceDecl node. This is for legacy objective-c \@implementation
96441c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// declaration without an \@interface declaration.
96597bbab2df74cbfe221fb20454738d607a41f3ca4Fariborz Jahanian  bool isImplicitInterfaceDecl() const {
96697bbab2df74cbfe221fb20454738d607a41f3ca4Fariborz Jahanian    return hasDefinition() ? Data->Definition->isImplicit() : isImplicit();
96797bbab2df74cbfe221fb20454738d607a41f3ca4Fariborz Jahanian  }
9681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
9690fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian  /// ClassImplementsProtocol - Checks that 'lProto' protocol
9700fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian  /// has been implemented in IDecl class, its super class or categories (if
9710fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian  /// lookupCategory is true).
9720fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian  bool ClassImplementsProtocol(ObjCProtocolDecl *lProto,
9730fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian                               bool lookupCategory,
9740fd8904c5f71a11d29f67716c3ebdf7ad1c855fbFariborz Jahanian                               bool RHSIsQualifiedID = false);
9751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
976a54fbf2499c7cc999e22abb9be484ce976ed9689Douglas Gregor  typedef redeclarable_base::redecl_iterator redecl_iterator;
977ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor  using redeclarable_base::redecls_begin;
978ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor  using redeclarable_base::redecls_end;
979ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor  using redeclarable_base::getPreviousDecl;
980ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor  using redeclarable_base::getMostRecentDecl;
981f785a7d611404cf4747287a2bbc59b4d0e6a5a8cDouglas Gregor
98253df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor  /// Retrieves the canonical declaration of this Objective-C class.
98353df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor  ObjCInterfaceDecl *getCanonicalDecl() {
98453df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor    return getFirstDeclaration();
98553df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor  }
98653df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor  const ObjCInterfaceDecl *getCanonicalDecl() const {
98753df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor    return getFirstDeclaration();
98853df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor  }
98953df7a1d34f21d8f2309311d1067d463e9064c60Douglas Gregor
99033feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff  // Low-level accessor
991f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall  const Type *getTypeForDecl() const { return TypeForDecl; }
992f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall  void setTypeForDecl(const Type *TD) const { TypeForDecl = TD; }
99333feeb019a5742b286eededd5446ec0fe87c5a61Steve Naroff
99480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
995a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCInterfaceDecl *D) { return true; }
99680cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCInterface; }
99753b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek
998fc529f7fcafe7da0b8a32621e13685891e8ce52aDouglas Gregor  friend class ASTReader;
99953b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  friend class ASTDeclReader;
100053b9441b5a81a24fa1f66f3f6416f1e36baa9c2fTed Kremenek  friend class ASTDeclWriter;
1001980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
1002980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
1003a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCIvarDecl - Represents an ObjC instance variable. In general, ObjC
10040c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// instance variables are identical to C. The only exception is Objective-C
10050c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// supports C++ style access control. For example:
10060c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
100741c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth///   \@interface IvarExample : NSObject
10080c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   {
1009f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek///     id defaultToProtected;
101041c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth///   \@public:
10110c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id canBePublic; // same as C++.
101241c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth///   \@protected:
10130c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id canBeProtected; // same as C++.
101441c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth///   \@package:
10150c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id canBePackage; // framework visibility (not available in C++).
10160c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   }
10170c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
1018a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCIvarDecl : public FieldDecl {
101999ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie  virtual void anchor();
102099ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie
10210e77ba0bf769e2e5a4a93c079f241b02aeb3ef93Chris Lattnerpublic:
1022980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  enum AccessControl {
1023980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    None, Private, Protected, Public, Package
1024980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  };
10251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1026b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenekprivate:
1027ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara  ObjCIvarDecl(ObjCContainerDecl *DC, SourceLocation StartLoc,
1028ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara               SourceLocation IdLoc, IdentifierInfo *Id,
1029ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian               QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW,
1030ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian               bool synthesized)
1031ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara    : FieldDecl(ObjCIvar, DC, StartLoc, IdLoc, Id, T, TInfo, BW,
1032ca5233044ef679840d1ad1c46a36b16e2ee8a6e1Richard Smith                /*Mutable=*/false, /*HasInit=*/ICIS_NoInit),
1033ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara      NextIvar(0), DeclAccess(ac), Synthesized(synthesized) {}
10341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1035b8db21d4df5fbb6ce1ace6411b82d3d623d789deTed Kremenekpublic:
1036a06549226f45d5b72169a3d054415616dd1014a2Daniel Dunbar  static ObjCIvarDecl *Create(ASTContext &C, ObjCContainerDecl *DC,
1037ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara                              SourceLocation StartLoc, SourceLocation IdLoc,
1038ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara                              IdentifierInfo *Id, QualType T,
1039a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall                              TypeSourceInfo *TInfo,
1040ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian                              AccessControl ac, Expr *BW = NULL,
1041ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian                              bool synthesized=false);
10421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
10431e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor  static ObjCIvarDecl *CreateDeserialized(ASTContext &C, unsigned ID);
10441e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor
104527a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar  /// \brief Return the class interface that this ivar is logically contained
104627a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar  /// in; this is either the interface where the ivar was declared, or the
104727a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar  /// interface the ivar is conceptually a part of in the case of synthesized
104827a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar  /// ivars.
104927a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar  const ObjCInterfaceDecl *getContainingInterface() const;
1050ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
10512c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian  ObjCIvarDecl *getNextIvar() { return NextIvar; }
1052db8264e4c5ffd7af6fbad4ca4306bd382bb02691Jordy Rose  const ObjCIvarDecl *getNextIvar() const { return NextIvar; }
10532c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian  void setNextIvar(ObjCIvarDecl *ivar) { NextIvar = ivar; }
105427a961a6adab85cfcf7e48485bbec9237719ae96Daniel Dunbar
1055980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void setAccessControl(AccessControl ac) { DeclAccess = ac; }
1056f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek
1057ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  AccessControl getAccessControl() const { return AccessControl(DeclAccess); }
1058f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek
1059f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek  AccessControl getCanonicalAccessControl() const {
1060f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek    return DeclAccess == None ? Protected : AccessControl(DeclAccess);
1061f079570fcad0d0053e75ebae29c883ec4276e020Ted Kremenek  }
10621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1063ac0021ba802e193e0f9f8207768c7862c7603bc0Fariborz Jahanian  void setSynthesize(bool synth) { Synthesized = synth; }
1064ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian  bool getSynthesize() const { return Synthesized; }
1065ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
1066980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  // Implement isa/cast/dyncast/etc.
106780cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1068a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCIvarDecl *D) { return true; }
106980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCIvar; }
1070980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffprivate:
1071ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  /// NextIvar - Next Ivar in the list of ivars declared in class; class's
10722c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian  /// extensions and class's implementation
10732c18bb7c9fca66c30b6eabbdcbc6399d24a54fa9Fariborz Jahanian  ObjCIvarDecl *NextIvar;
1074ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
1075ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  // NOTE: VC++ treats enums as signed, avoid using the AccessControl enum
1076ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek  unsigned DeclAccess : 3;
1077ad51e74030a59a8aa4ef0ebca1d7a701602ef53bFariborz Jahanian  unsigned Synthesized : 1;
1078980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
1079980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
10801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
10810982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \brief Represents a field declaration created by an \@defs(...).
108201e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenekclass ObjCAtDefsFieldDecl : public FieldDecl {
108399ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie  virtual void anchor();
1084ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara  ObjCAtDefsFieldDecl(DeclContext *DC, SourceLocation StartLoc,
1085ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara                      SourceLocation IdLoc, IdentifierInfo *Id,
108601e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek                      QualType T, Expr *BW)
1087ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara    : FieldDecl(ObjCAtDefsField, DC, StartLoc, IdLoc, Id, T,
1088a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall                /*TInfo=*/0, // FIXME: Do ObjCAtDefs have declarators ?
1089ca5233044ef679840d1ad1c46a36b16e2ee8a6e1Richard Smith                BW, /*Mutable=*/false, /*HasInit=*/ICIS_NoInit) {}
10901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
109101e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenekpublic:
109244b4321feab46299d3f5cfd404680884752a0fcfDouglas Gregor  static ObjCAtDefsFieldDecl *Create(ASTContext &C, DeclContext *DC,
1093ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara                                     SourceLocation StartLoc,
1094ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara                                     SourceLocation IdLoc, IdentifierInfo *Id,
1095ff676cb48fe8bf7be2feaa251dc7c5fb15af4730Abramo Bagnara                                     QualType T, Expr *BW);
10961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
10971e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor  static ObjCAtDefsFieldDecl *CreateDeserialized(ASTContext &C, unsigned ID);
10981e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor
109901e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek  // Implement isa/cast/dyncast/etc.
110080cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
110101e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek  static bool classof(const ObjCAtDefsFieldDecl *D) { return true; }
110280cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCAtDefsField; }
110301e6779faca1e3a3164c697d6e2dfee0881a6981Ted Kremenek};
1104980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
11050982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \brief Represents an Objective-C protocol declaration.
11060982205bade2fb4fc984c27b2ab401e683963b10James Dennett///
11070982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// Objective-C protocols declare a pure abstract type (i.e., no instance
11080982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// variables are permitted).  Protocols originally drew inspiration from
11090982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// C++ pure virtual functions (a C++ feature with nice semantics and lousy
11100982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// syntax:-). Here is an example:
11110c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
11120982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \code
111341c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@protocol NSDraggingInfo <refproto1, refproto2>
11140c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSWindow *)draggingDestinationWindow;
11150c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSImage *)draggedImage;
111641c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@end
11170982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \endcode
11180c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
1119eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// This says that NSDraggingInfo requires two methods and requires everything
1120eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// that the two "referenced protocols" 'refproto1' and 'refproto2' require as
1121eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner/// well.
1122eca7be6b7ebd93682eeaab2c71d59f2995dacdccChris Lattner///
11230982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \code
11240982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \@interface ImplementsNSDraggingInfo : NSObject \<NSDraggingInfo>
112541c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@end
11260982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \endcode
11270c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
1128a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjC protocols inspired Java interfaces. Unlike Java, ObjC classes and
11290c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// protocols are in distinct namespaces. For example, Cocoa defines both
11301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// an NSObject protocol and class (which isn't allowed in Java). As a result,
11310c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// protocols are referenced using angle brackets as follows:
11320c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
11330982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// id \<NSDraggingInfo> anyObjectThatImplementsNSDraggingInfo;
11340c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
11351d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregorclass ObjCProtocolDecl : public ObjCContainerDecl,
11361d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor                         public Redeclarable<ObjCProtocolDecl> {
113799ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie  virtual void anchor();
113899ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie
11395e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  struct DefinitionData {
11401d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor    // \brief The declaration that defines this protocol.
11411d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor    ObjCProtocolDecl *Definition;
11421d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor
1143ec1a58b201b3276966aaade8ac3ac4705aba96c2Douglas Gregor    /// \brief Referenced protocols
11445e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    ObjCProtocolList ReferencedProtocols;
11455e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  };
11465e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor
11475e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  DefinitionData *Data;
11481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
11495e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  DefinitionData &data() const {
11505e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    assert(Data && "Objective-C protocol has no definition!");
11515e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    return *Data;
11525e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  }
11535e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor
11541711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis  ObjCProtocolDecl(DeclContext *DC, IdentifierInfo *Id,
1155b05d7b20171bbd2feb14b059f39332cbe1bf1014Argyrios Kyrtzidis                   SourceLocation nameLoc, SourceLocation atStartLoc,
1156c9d3c7edb513e9b8a6ab65b04133653e71d7a72bDouglas Gregor                   ObjCProtocolDecl *PrevDecl);
11571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
11585e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  void allocateDefinitionData();
11591d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor
11601d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor  typedef Redeclarable<ObjCProtocolDecl> redeclarable_base;
11611d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor  virtual ObjCProtocolDecl *getNextRedeclaration() {
11621d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor    return RedeclLink.getNext();
11631d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor  }
1164ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor  virtual ObjCProtocolDecl *getPreviousDeclImpl() {
1165ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor    return getPreviousDecl();
1166ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor  }
1167ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor  virtual ObjCProtocolDecl *getMostRecentDeclImpl() {
1168ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor    return getMostRecentDecl();
1169ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor  }
11701d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor
1171cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattnerpublic:
11721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static ObjCProtocolDecl *Create(ASTContext &C, DeclContext *DC,
11731711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis                                  IdentifierInfo *Id,
11741711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis                                  SourceLocation nameLoc,
1175b05d7b20171bbd2feb14b059f39332cbe1bf1014Argyrios Kyrtzidis                                  SourceLocation atStartLoc,
1176c9d3c7edb513e9b8a6ab65b04133653e71d7a72bDouglas Gregor                                  ObjCProtocolDecl *PrevDecl);
1177cca59d77c4b84fd2da268018dbaf9431a621e75bChris Lattner
11781e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor  static ObjCProtocolDecl *CreateDeserialized(ASTContext &C, unsigned ID);
11791e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor
118018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  const ObjCProtocolList &getReferencedProtocols() const {
11815e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    assert(hasDefinition() && "No definition available!");
11825e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    return data().ReferencedProtocols;
1183980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
118418df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  typedef ObjCProtocolList::iterator protocol_iterator;
11855e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  protocol_iterator protocol_begin() const {
11865e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    if (!hasDefinition())
11875e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor      return protocol_iterator();
11885e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor
11895e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    return data().ReferencedProtocols.begin();
11905e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  }
11915e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  protocol_iterator protocol_end() const {
11925e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    if (!hasDefinition())
11935e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor      return protocol_iterator();
11945e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor
11955e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    return data().ReferencedProtocols.end();
11965e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  }
119718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  typedef ObjCProtocolList::loc_iterator protocol_loc_iterator;
1198ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  protocol_loc_iterator protocol_loc_begin() const {
11995e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    if (!hasDefinition())
12005e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor      return protocol_loc_iterator();
12015e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor
12025e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    return data().ReferencedProtocols.loc_begin();
120318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  }
1204ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  protocol_loc_iterator protocol_loc_end() const {
12055e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    if (!hasDefinition())
12065e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor      return protocol_loc_iterator();
12075e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor
12085e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    return data().ReferencedProtocols.loc_end();
12095e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  }
12105e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  unsigned protocol_size() const {
12115e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    if (!hasDefinition())
12125e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor      return 0;
12135e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor
12145e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    return data().ReferencedProtocols.size();
121518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  }
12161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
121738af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner  /// setProtocolList - Set the list of protocols that this interface
1218780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  /// implements.
121938af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner  void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num,
122018df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor                       const SourceLocation *Locs, ASTContext &C) {
12215e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    assert(Data && "Protocol is not defined");
12225e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    data().ReferencedProtocols.set(List, Num, Locs, C);
1223aebf0cba02c014ac8b19d615c654248e0e93779fFariborz Jahanian  }
12241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
122591b0b0cf6b537cbcbca0038c7032f87161a41d31Steve Naroff  ObjCProtocolDecl *lookupProtocolNamed(IdentifierInfo *PName);
12261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
122794a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff  // Lookup a method. First, we search locally. If a method isn't
122894a5c3334bba3cc8cd1da85ba1118bc2c080add9Steve Naroff  // found, we search referenced protocols and class categories.
1229094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis  ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance) const;
1230094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis  ObjCMethodDecl *lookupInstanceMethod(Selector Sel) const {
1231094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis    return lookupMethod(Sel, true/*isInstance*/);
1232094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis  }
1233094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis  ObjCMethodDecl *lookupClassMethod(Selector Sel) const {
1234094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis    return lookupMethod(Sel, false/*isInstance*/);
1235094e2bb6730d63e0f6919e4839522a43b7644181Argyrios Kyrtzidis  }
1236b05d7b20171bbd2feb14b059f39332cbe1bf1014Argyrios Kyrtzidis
12375e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  /// \brief Determine whether this protocol has a definition.
12385e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  bool hasDefinition() const { return Data != 0; }
12395e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor
12405e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  /// \brief Retrieve the definition of this protocol, if any.
12415e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  ObjCProtocolDecl *getDefinition() {
12421d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor    return Data? Data->Definition : 0;
12435e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  }
12445e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor
12455e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  /// \brief Retrieve the definition of this protocol, if any.
12465e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  const ObjCProtocolDecl *getDefinition() const {
12471d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor    return Data? Data->Definition : 0;
12485e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  }
12495e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor
12505e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  /// \brief Determine whether this particular declaration is also the
12515e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  /// definition.
12525e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  bool isThisDeclarationADefinition() const {
12535e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor    return getDefinition() == this;
12545e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  }
12555e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor
12565e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  /// \brief Starts the definition of this Objective-C protocol.
12575e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  void startDefinition();
12585e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor
1259aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar  virtual SourceRange getSourceRange() const LLVM_READONLY {
1260ec1a58b201b3276966aaade8ac3ac4705aba96c2Douglas Gregor    if (isThisDeclarationADefinition())
1261ec1a58b201b3276966aaade8ac3ac4705aba96c2Douglas Gregor      return ObjCContainerDecl::getSourceRange();
1262ec1a58b201b3276966aaade8ac3ac4705aba96c2Douglas Gregor
1263ec1a58b201b3276966aaade8ac3ac4705aba96c2Douglas Gregor    return SourceRange(getAtStartLoc(), getLocation());
1264ec1a58b201b3276966aaade8ac3ac4705aba96c2Douglas Gregor  }
1265f785a7d611404cf4747287a2bbc59b4d0e6a5a8cDouglas Gregor
1266a54fbf2499c7cc999e22abb9be484ce976ed9689Douglas Gregor  typedef redeclarable_base::redecl_iterator redecl_iterator;
1267ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor  using redeclarable_base::redecls_begin;
1268ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor  using redeclarable_base::redecls_end;
1269ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor  using redeclarable_base::getPreviousDecl;
1270ef96ee0be5f100789f451641542a69cd719144d2Douglas Gregor  using redeclarable_base::getMostRecentDecl;
1271f785a7d611404cf4747287a2bbc59b4d0e6a5a8cDouglas Gregor
12723fc73ee0c613715ebce78e30b4d050ea715a007dDouglas Gregor  /// Retrieves the canonical declaration of this Objective-C protocol.
12733fc73ee0c613715ebce78e30b4d050ea715a007dDouglas Gregor  ObjCProtocolDecl *getCanonicalDecl() {
12741d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor    return getFirstDeclaration();
12753fc73ee0c613715ebce78e30b4d050ea715a007dDouglas Gregor  }
12763fc73ee0c613715ebce78e30b4d050ea715a007dDouglas Gregor  const ObjCProtocolDecl *getCanonicalDecl() const {
12771d784b277cdfd4eba03680715d2a082b3f28d295Douglas Gregor    return getFirstDeclaration();
12783fc73ee0c613715ebce78e30b4d050ea715a007dDouglas Gregor  }
12793fc73ee0c613715ebce78e30b4d050ea715a007dDouglas Gregor
128080cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1281a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCProtocolDecl *D) { return true; }
128280cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCProtocol; }
1283b05d7b20171bbd2feb14b059f39332cbe1bf1014Argyrios Kyrtzidis
12845e2a1ff9f28d2eab256d2553e76a9c9d54693875Douglas Gregor  friend class ASTReader;
1285b05d7b20171bbd2feb14b059f39332cbe1bf1014Argyrios Kyrtzidis  friend class ASTDeclReader;
1286b05d7b20171bbd2feb14b059f39332cbe1bf1014Argyrios Kyrtzidis  friend class ASTDeclWriter;
1287980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
12881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1289a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCCategoryDecl - Represents a category declaration. A category allows
12900c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// you to add methods to an existing class (without subclassing or modifying
12911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// the original class interface or implementation:-). Categories don't allow
12920c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// you to add instance data. The following example adds "myMethod" to all
12930c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// NSView's within a process:
12940c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
129541c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@interface NSView (MyViewMethods)
12960c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - myMethod;
129741c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@end
12980c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
129933ced0b8550f3e7169f326944731ee02e9338659Douglas Gregor/// Categories also allow you to split the implementation of a class across
13000c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// several files (a feature more naturally supported in C++).
13010c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
13020c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Categories were originally inspired by dynamic languages such as Common
13031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// Lisp and Smalltalk.  More traditional class-based languages (C++, Java)
13040c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// don't support this level of dynamism, which is both powerful and dangerous.
13050c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
1306e4f039e01e797a38bc97bf22aff9832ecd18ff5fSteve Naroffclass ObjCCategoryDecl : public ObjCContainerDecl {
130799ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie  virtual void anchor();
130899ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie
1309980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Interface belonging to this category
1310a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl *ClassInterface;
13111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
131268c82cf61228102aba1194efef222fa1478af2a8Chris Lattner  /// referenced protocols in this category.
131318df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  ObjCProtocolList ReferencedProtocols;
13141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1315a8ff9f455d94d9609766cfd5186b6e21dc2102f1Chris Lattner  /// Next category belonging to this class.
1316a8ff9f455d94d9609766cfd5186b6e21dc2102f1Chris Lattner  /// FIXME: this should not be a singly-linked list.  Move storage elsewhere.
1317a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCCategoryDecl *NextClassCategory;
13181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
13193db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor  /// \brief The location of the category name in this declaration.
13203db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor  SourceLocation CategoryNameLoc;
13211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1322af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian  /// class extension may have private ivars.
1323af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian  SourceLocation IvarLBraceLoc;
1324af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian  SourceLocation IvarRBraceLoc;
1325af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian
1326ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  ObjCCategoryDecl(DeclContext *DC, SourceLocation AtLoc,
13273db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor                   SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc,
1328af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian                   IdentifierInfo *Id, ObjCInterfaceDecl *IDecl,
1329af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian                   SourceLocation IvarLBraceLoc=SourceLocation(),
1330af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian                   SourceLocation IvarRBraceLoc=SourceLocation())
13311711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis    : ObjCContainerDecl(ObjCCategory, DC, Id, ClassNameLoc, AtLoc),
1332ffb0c3adc27d257c8453886957b8d220d1ad14d8Eric Christopher      ClassInterface(IDecl), NextClassCategory(0),
1333af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian      CategoryNameLoc(CategoryNameLoc),
1334af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian      IvarLBraceLoc(IvarLBraceLoc), IvarRBraceLoc(IvarRBraceLoc) {
1335a906135721c350435319347d2672bbb3bf494f91Chris Lattner  }
133661f9d41036e30ff80130f99b31c0626e3ef057ccChris Lattnerpublic:
13371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1338d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCCategoryDecl *Create(ASTContext &C, DeclContext *DC,
1339ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie                                  SourceLocation AtLoc,
13403db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor                                  SourceLocation ClassNameLoc,
13413db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor                                  SourceLocation CategoryNameLoc,
1342955fadbdfecfa24a590febe66a86519096787f2dArgyrios Kyrtzidis                                  IdentifierInfo *Id,
1343af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian                                  ObjCInterfaceDecl *IDecl,
1344af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian                                  SourceLocation IvarLBraceLoc=SourceLocation(),
1345af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian                                  SourceLocation IvarRBraceLoc=SourceLocation());
13461e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor  static ObjCCategoryDecl *CreateDeserialized(ASTContext &C, unsigned ID);
13471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1348e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  ObjCInterfaceDecl *getClassInterface() { return ClassInterface; }
1349e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
13508a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis
13518a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis  ObjCCategoryImplDecl *getImplementation() const;
13528a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis  void setImplementation(ObjCCategoryImplDecl *ImplD);
13538a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis
135438af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner  /// setProtocolList - Set the list of protocols that this interface
1355f7b2c98c16dfb2261ea57d40a1d5bc4738e73175Chris Lattner  /// implements.
135638af2deb27cdfa1a95bde96e30dab15dce53fcefChris Lattner  void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num,
135718df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor                       const SourceLocation *Locs, ASTContext &C) {
135818df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor    ReferencedProtocols.set(List, Num, Locs, C);
1359780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  }
13601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
136118df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  const ObjCProtocolList &getReferencedProtocols() const {
1362780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner    return ReferencedProtocols;
13638f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  }
13641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
136518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  typedef ObjCProtocolList::iterator protocol_iterator;
1366780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
1367780f329cb011bff0da5763e2e9744eec093d0509Chris Lattner  protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
136830833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff  unsigned protocol_size() const { return ReferencedProtocols.size(); }
136918df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  typedef ObjCProtocolList::loc_iterator protocol_loc_iterator;
1370ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  protocol_loc_iterator protocol_loc_begin() const {
1371ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie    return ReferencedProtocols.loc_begin();
137218df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  }
1373ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  protocol_loc_iterator protocol_loc_end() const {
1374ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie    return ReferencedProtocols.loc_end();
137518df52bbb5d28ca082064d31ae7558dbdae52377Douglas Gregor  }
13761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1377a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCCategoryDecl *getNextClassCategory() const { return NextClassCategory; }
13783db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor
137925760611365be23556b32332f8a66ae21ea93ecfFariborz Jahanian  bool IsClassExtension() const { return getIdentifier() == 0; }
138080aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian  const ObjCCategoryDecl *getNextClassExtension() const;
1381ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
13820e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator;
13830e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  ivar_iterator ivar_begin() const {
13840e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian    return ivar_iterator(decls_begin());
13850e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  }
13860e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  ivar_iterator ivar_end() const {
13870e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian    return ivar_iterator(decls_end());
13880e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  }
13890e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  unsigned ivar_size() const {
13900e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian    return std::distance(ivar_begin(), ivar_end());
13910e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  }
13920e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  bool ivar_empty() const {
13930e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian    return ivar_begin() == ivar_end();
13940e5ad255729ee86b8ed57e659029008984517cdeFariborz Jahanian  }
13953db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor
13963db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor  SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; }
13973db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor  void setCategoryNameLoc(SourceLocation Loc) { CategoryNameLoc = Loc; }
1398af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian
1399af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian  void setIvarLBraceLoc(SourceLocation Loc) { IvarLBraceLoc = Loc; }
1400af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian  SourceLocation getIvarLBraceLoc() const { return IvarLBraceLoc; }
1401af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian  void setIvarRBraceLoc(SourceLocation Loc) { IvarRBraceLoc = Loc; }
1402af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian  SourceLocation getIvarRBraceLoc() const { return IvarRBraceLoc; }
14033db211b617c5073aa70eb25d37ed44ae0dca17c4Douglas Gregor
140480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1405a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCCategoryDecl *D) { return true; }
140680cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCCategory; }
1407955fadbdfecfa24a590febe66a86519096787f2dArgyrios Kyrtzidis
1408955fadbdfecfa24a590febe66a86519096787f2dArgyrios Kyrtzidis  friend class ASTDeclReader;
1409955fadbdfecfa24a590febe66a86519096787f2dArgyrios Kyrtzidis  friend class ASTDeclWriter;
1410980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
14110c6b6243d3efd958c17943130e2a773653511edcSteve Naroff
1412aecae629269fae3bf484baf1d109e9a89d14eeadArgyrios Kyrtzidisclass ObjCImplDecl : public ObjCContainerDecl {
141399ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie  virtual void anchor();
141499ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie
14150d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff  /// Class interface for this class/category implementation
1416a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl *ClassInterface;
14171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
14183aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattnerprotected:
14191711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis  ObjCImplDecl(Kind DK, DeclContext *DC,
14201711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis               ObjCInterfaceDecl *classInterface,
14211711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis               SourceLocation nameLoc, SourceLocation atStartLoc)
14221711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis    : ObjCContainerDecl(DK, DC,
14231711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis                        classInterface? classInterface->getIdentifier() : 0,
14241711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis                        nameLoc, atStartLoc),
1425aecae629269fae3bf484baf1d109e9a89d14eeadArgyrios Kyrtzidis      ClassInterface(classInterface) {}
14261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
142775c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattnerpublic:
1428e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
1429e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  ObjCInterfaceDecl *getClassInterface() { return ClassInterface; }
14308a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis  void setClassInterface(ObjCInterfaceDecl *IFace);
14312c2d43c557beca1b4ba4bd743f33978aecb46a97Douglas Gregor
14321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  void addInstanceMethod(ObjCMethodDecl *method) {
14332c2d43c557beca1b4ba4bd743f33978aecb46a97Douglas Gregor    // FIXME: Context should be set correctly before we get here.
1434653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor    method->setLexicalDeclContext(this);
14351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    addDecl(method);
1436e1e6c0d5c79c0ee7ed62fef47a19aa7ecef40db4Steve Naroff  }
14371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  void addClassMethod(ObjCMethodDecl *method) {
14382c2d43c557beca1b4ba4bd743f33978aecb46a97Douglas Gregor    // FIXME: Context should be set correctly before we get here.
1439653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor    method->setLexicalDeclContext(this);
14401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    addDecl(method);
144153df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner  }
14421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
144317945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  void addPropertyImplementation(ObjCPropertyImplDecl *property);
14441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
144517945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  ObjCPropertyImplDecl *FindPropertyImplDecl(IdentifierInfo *propertyId) const;
144617945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis  ObjCPropertyImplDecl *FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const;
1447653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor
1448653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor  // Iterator access to properties.
1449653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor  typedef specific_decl_iterator<ObjCPropertyImplDecl> propimpl_iterator;
14501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  propimpl_iterator propimpl_begin() const {
145117945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return propimpl_iterator(decls_begin());
1452559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  }
14531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  propimpl_iterator propimpl_end() const {
145417945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return propimpl_iterator(decls_end());
1455559c0c4bbecc017aab0716d546c4fefbcc194687Fariborz Jahanian  }
1456653f1b1bf293a9bd96fd4dd6372e779cc7af1597Douglas Gregor
145780cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1458bfb498d0996ef049efe9476f2802976fd145cd60Argyrios Kyrtzidis  static bool classof(const ObjCImplDecl *D) { return true; }
145980cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) {
14609a55591af3e5506b95a9718e15380129fbfc5ebcSean Hunt    return K >= firstObjCImpl && K <= lastObjCImpl;
146180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  }
14623aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner};
14631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
14641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// ObjCCategoryImplDecl - An object of this class encapsulates a category
146541c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@implementation declaration. If a category class has declaration of a
14661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// property, its implementation must be specified in the category's
146741c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@implementation declaration. Example:
146841c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@interface I \@end
146941c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@interface I(CATEGORY)
147041c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth///    \@property int p1, d1;
147141c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@end
147241c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@implementation I(CATEGORY)
147341c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth///  \@dynamic p1,d1;
147441c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@end
14753aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner///
14763aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner/// ObjCCategoryImplDecl
14773aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattnerclass ObjCCategoryImplDecl : public ObjCImplDecl {
147899ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie  virtual void anchor();
147999ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie
14803aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  // Category name
14813aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  IdentifierInfo *Id;
14823aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner
1483c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis  // Category name location
1484c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis  SourceLocation CategoryNameLoc;
1485c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis
14861711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis  ObjCCategoryImplDecl(DeclContext *DC, IdentifierInfo *Id,
14871711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis                       ObjCInterfaceDecl *classInterface,
1488c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis                       SourceLocation nameLoc, SourceLocation atStartLoc,
1489c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis                       SourceLocation CategoryNameLoc)
14901711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis    : ObjCImplDecl(ObjCCategoryImpl, DC, classInterface, nameLoc, atStartLoc),
1491c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis      Id(Id), CategoryNameLoc(CategoryNameLoc) {}
14923aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattnerpublic:
14933aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  static ObjCCategoryImplDecl *Create(ASTContext &C, DeclContext *DC,
14941711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis                                      IdentifierInfo *Id,
14951711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis                                      ObjCInterfaceDecl *classInterface,
14961711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis                                      SourceLocation nameLoc,
1497c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis                                      SourceLocation atStartLoc,
1498c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis                                      SourceLocation CategoryNameLoc);
14991e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor  static ObjCCategoryImplDecl *CreateDeserialized(ASTContext &C, unsigned ID);
15001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
15010d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff  /// getIdentifier - Get the identifier that names the category
15023aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  /// interface associated with this implementation.
15030d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff  /// FIXME: This is a bad API, we are overriding the NamedDecl::getIdentifier()
15040d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff  /// to mean something different. For example:
1505ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  /// ((NamedDecl *)SomeCategoryImplDecl)->getIdentifier()
1506ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  /// returns the class interface name, whereas
1507ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  /// ((ObjCCategoryImplDecl *)SomeCategoryImplDecl)->getIdentifier()
15080d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff  /// returns the category name.
15091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  IdentifierInfo *getIdentifier() const {
15101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return Id;
15113aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  }
151210b0e1fa3aabd8877dbbc0df1f2414e04afd5fddDouglas Gregor  void setIdentifier(IdentifierInfo *II) { Id = II; }
15131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
15140d69b8cc8e90a9364771837cb42d7031b4cbb984Steve Naroff  ObjCCategoryDecl *getCategoryDecl() const;
151510b0e1fa3aabd8877dbbc0df1f2414e04afd5fddDouglas Gregor
1516c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis  SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; }
1517c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis
1518b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar  /// getName - Get the name of identifier for the class interface associated
1519b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar  /// with this implementation as a StringRef.
1520b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar  //
1521b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar  // FIXME: This is a bad API, we are overriding the NamedDecl::getName, to mean
1522b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar  // something different.
1523686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  StringRef getName() const {
1524b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar    return Id ? Id->getNameStart() : "";
1525b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar  }
1526b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar
15273aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  /// @brief Get the name of the class associated with this interface.
15287fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar  //
1529b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar  // FIXME: Deprecated, move clients to getName().
15303aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  std::string getNameAsString() const {
1531b5217efa5be2fd6be48d207267c8bcda6bf9206cDaniel Dunbar    return getName();
15323aa1861bd8b5121e53379b1a00f9d6ad8dead4f6Chris Lattner  }
15331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
153480cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1535a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCCategoryImplDecl *D) { return true; }
153680cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCCategoryImpl;}
1537c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis
1538c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis  friend class ASTDeclReader;
1539c6994005dc9f677c831b8e90bdab483cc2197c29Argyrios Kyrtzidis  friend class ASTDeclWriter;
15408f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian};
15418f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
1542f978059b82db8c0d849c5f992036210b5ca53200Benjamin Kramerraw_ostream &operator<<(raw_ostream &OS, const ObjCCategoryImplDecl &CID);
1543900fc6388e803868a34b9483510c345e9b49d7ebBenjamin Kramer
1544a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCImplementationDecl - Represents a class definition - this is where
15450c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// method definitions are specified. For example:
15460c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
154798abf4bd3526a00a0e5cf71a9462c181f97b1c81Fariborz Jahanian/// @code
154841c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@implementation MyClass
15490c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (void)myMethod { /* do something */ }
155041c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@end
155198abf4bd3526a00a0e5cf71a9462c181f97b1c81Fariborz Jahanian/// @endcode
15520c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
15531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// Typically, instance variables are specified in the class interface,
1554ec0d7a6f4b0699cc9960e6d9fee0f957c64d1cf9Douglas Gregor/// *not* in the implementation. Nevertheless (for legacy reasons), we
155553df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner/// allow instance variables to be specified in the implementation.  When
155653df12d1ba68dbd071d067f8236c16fba815aad5Chris Lattner/// specified, they need to be *identical* to the interface.
15570c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
15581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumpclass ObjCImplementationDecl : public ObjCImplDecl {
155999ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie  virtual void anchor();
1560980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Implementation Class's super class.
1561a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl *SuperClass;
156241c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// \@implementation may have private ivars.
1563af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian  SourceLocation IvarLBraceLoc;
1564af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian  SourceLocation IvarRBraceLoc;
1565af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian
1566e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// Support for ivar initialization.
1567e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// IvarInitializers - The arguments used to initialize the ivars
1568cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt  CXXCtorInitializer **IvarInitializers;
1569e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  unsigned NumIvarInitializers;
1570f85e193739c953358c865005855253af4f68a497John McCall
1571f85e193739c953358c865005855253af4f68a497John McCall  /// true if class has a .cxx_[construct,destruct] method.
1572f85e193739c953358c865005855253af4f68a497John McCall  bool HasCXXStructors : 1;
1573ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
15741711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis  ObjCImplementationDecl(DeclContext *DC,
1575a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek                         ObjCInterfaceDecl *classInterface,
15761711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis                         ObjCInterfaceDecl *superDecl,
1577af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian                         SourceLocation nameLoc, SourceLocation atStartLoc,
1578af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian                         SourceLocation IvarLBraceLoc=SourceLocation(),
1579af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian                         SourceLocation IvarRBraceLoc=SourceLocation())
15801711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis    : ObjCImplDecl(ObjCImplementation, DC, classInterface, nameLoc, atStartLoc),
1581af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian       SuperClass(superDecl), IvarLBraceLoc(IvarLBraceLoc),
1582af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian       IvarRBraceLoc(IvarRBraceLoc),
1583af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian       IvarInitializers(0), NumIvarInitializers(0),
1584ffb0c3adc27d257c8453886957b8d220d1ad14d8Eric Christopher       HasCXXStructors(false) {}
15851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumppublic:
15861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static ObjCImplementationDecl *Create(ASTContext &C, DeclContext *DC,
158775c9cae5f85c72cbb1649e93849e16ede3f07522Chris Lattner                                        ObjCInterfaceDecl *classInterface,
15881711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis                                        ObjCInterfaceDecl *superDecl,
15891711fc91efb36d131f7ba771f73f0154dc1abd1fArgyrios Kyrtzidis                                        SourceLocation nameLoc,
1590af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian                                        SourceLocation atStartLoc,
1591af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian                                        SourceLocation IvarLBraceLoc=SourceLocation(),
1592af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian                                        SourceLocation IvarRBraceLoc=SourceLocation());
1593ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
15941e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor  static ObjCImplementationDecl *CreateDeserialized(ASTContext &C, unsigned ID);
15951e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor
1596e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// init_iterator - Iterates through the ivar initializer list.
1597cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt  typedef CXXCtorInitializer **init_iterator;
1598ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
1599e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// init_const_iterator - Iterates through the ivar initializer list.
1600cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt  typedef CXXCtorInitializer * const * init_const_iterator;
1601ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
1602e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// init_begin() - Retrieve an iterator to the first initializer.
1603e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  init_iterator       init_begin()       { return IvarInitializers; }
1604e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// begin() - Retrieve an iterator to the first initializer.
1605e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  init_const_iterator init_begin() const { return IvarInitializers; }
1606ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
1607e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// init_end() - Retrieve an iterator past the last initializer.
1608e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  init_iterator       init_end()       {
1609e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian    return IvarInitializers + NumIvarInitializers;
1610e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  }
1611e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// end() - Retrieve an iterator past the last initializer.
1612e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  init_const_iterator init_end() const {
1613e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian    return IvarInitializers + NumIvarInitializers;
1614e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  }
1615e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  /// getNumArgs - Number of ivars which must be initialized.
1616e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  unsigned getNumIvarInitializers() const {
1617e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian    return NumIvarInitializers;
1618e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  }
1619ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
1620e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  void setNumIvarInitializers(unsigned numNumIvarInitializers) {
1621e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian    NumIvarInitializers = numNumIvarInitializers;
1622e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  }
1623ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
1624e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian  void setIvarInitializers(ASTContext &C,
1625cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt                           CXXCtorInitializer ** initializers,
1626e4498c6d66a8f472cba29b6158a2e86dfc60d0efFariborz Jahanian                           unsigned numInitializers);
1627f85e193739c953358c865005855253af4f68a497John McCall
1628f85e193739c953358c865005855253af4f68a497John McCall  bool hasCXXStructors() const { return HasCXXStructors; }
1629f85e193739c953358c865005855253af4f68a497John McCall  void setHasCXXStructors(bool val) { HasCXXStructors = val; }
1630ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
16314afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  /// getIdentifier - Get the identifier that names the class
16324afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  /// interface associated with this implementation.
16331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  IdentifierInfo *getIdentifier() const {
16341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return getClassInterface()->getIdentifier();
16354afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  }
16364afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor
1637d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar  /// getName - Get the name of identifier for the class interface associated
1638d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar  /// with this implementation as a StringRef.
1639d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar  //
1640d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar  // FIXME: This is a bad API, we are overriding the NamedDecl::getName, to mean
1641d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar  // something different.
1642686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  StringRef getName() const {
1643d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar    assert(getIdentifier() && "Name is not a simple identifier");
1644d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar    return getIdentifier()->getName();
1645d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar  }
1646d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar
16474afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  /// @brief Get the name of the class associated with this interface.
16487fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar  //
16497fe60650c1133ee74a3395cf1063690e274bb7acDaniel Dunbar  // FIXME: Move to StringRef API.
16504afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  std::string getNameAsString() const {
1651d0c10e20d5ba8c1a8a077db128c03eddc3158673Daniel Dunbar    return getName();
16524afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor  }
16534afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor
1654e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  const ObjCInterfaceDecl *getSuperClass() const { return SuperClass; }
1655e0def7589a8afa8a6acef13476bb3f882c104b91Chris Lattner  ObjCInterfaceDecl *getSuperClass() { return SuperClass; }
16561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1657f3a7af901231535191d14cb524d58f22907ac4d2Chris Lattner  void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; }
16581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1659af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian  void setIvarLBraceLoc(SourceLocation Loc) { IvarLBraceLoc = Loc; }
1660af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian  SourceLocation getIvarLBraceLoc() const { return IvarLBraceLoc; }
1661af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian  void setIvarRBraceLoc(SourceLocation Loc) { IvarRBraceLoc = Loc; }
1662af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian  SourceLocation getIvarRBraceLoc() const { return IvarRBraceLoc; }
1663af300298ab86752fa64e339ba34195888a830756Fariborz Jahanian
16648f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor  typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator;
16651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ivar_iterator ivar_begin() const {
16661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return ivar_iterator(decls_begin());
16678f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor  }
16681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ivar_iterator ivar_end() const {
166917945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return ivar_iterator(decls_end());
16708f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor  }
16711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  unsigned ivar_size() const {
167217945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return std::distance(ivar_begin(), ivar_end());
16738f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor  }
16741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  bool ivar_empty() const {
167517945a0f64fe03ff6ec0c2146005a87636e3ac12Argyrios Kyrtzidis    return ivar_begin() == ivar_end();
16768f36aba016c2d236a90f9ecf0a66904209202202Douglas Gregor  }
16771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
167880cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1679a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCImplementationDecl *D) { return true; }
168080cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCImplementation; }
16819d50c0635fb213b2a1857e3f8488580f0dab2f98Argyrios Kyrtzidis
1682d527cc06d78fe5afa5f20105b51697637eb02c56Sebastian Redl  friend class ASTDeclReader;
16833397c5570369f19b2d6c52e898f708d75ceede1fSebastian Redl  friend class ASTDeclWriter;
1684980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
1685243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian
1686f978059b82db8c0d849c5f992036210b5ca53200Benjamin Kramerraw_ostream &operator<<(raw_ostream &OS, const ObjCImplementationDecl &ID);
1687900fc6388e803868a34b9483510c345e9b49d7ebBenjamin Kramer
16881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is
168941c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// declared as \@compatibility_alias alias class.
16904afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCCompatibleAliasDecl : public NamedDecl {
169199ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie  virtual void anchor();
1692243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian  /// Class that this is an alias of.
1693a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  ObjCInterfaceDecl *AliasedClass;
16941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1695d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCCompatibleAliasDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
1696e8043c39176e7f253fbd92982b077eca6bf2fd59Steve Naroff                          ObjCInterfaceDecl* aliasedClass)
16974afa39deaa245592977136d367251ee2c173dd8dDouglas Gregor    : NamedDecl(ObjCCompatibleAlias, DC, L, Id), AliasedClass(aliasedClass) {}
1698f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattnerpublic:
1699d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCCompatibleAliasDecl *Create(ASTContext &C, DeclContext *DC,
17000ed844b04ea4387caa4e1cf3dc375d269657536bChris Lattner                                         SourceLocation L, IdentifierInfo *Id,
1701f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner                                         ObjCInterfaceDecl* aliasedClass);
1702f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner
17031e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor  static ObjCCompatibleAliasDecl *CreateDeserialized(ASTContext &C,
17041e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor                                                     unsigned ID);
17051e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor
1706f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner  const ObjCInterfaceDecl *getClassInterface() const { return AliasedClass; }
1707f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattner  ObjCInterfaceDecl *getClassInterface() { return AliasedClass; }
170830833f8d77c08f8f16371776fde85a9fde3d9b6eSteve Naroff  void setClassInterface(ObjCInterfaceDecl *D) { AliasedClass = D; }
17091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
171080cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1711a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCCompatibleAliasDecl *D) { return true; }
171280cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCCompatibleAlias; }
17131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1714243b64b0001172405ff803c61bdcaa8e98ec1552Fariborz Jahanian};
17151de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian
17160982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \brief Represents one property declaration in an Objective-C interface.
17170982205bade2fb4fc984c27b2ab401e683963b10James Dennett///
17181de1e74541c25c1a7b721f1c3991ea34c8403420Fariborz Jahanian/// For example:
17190982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \code{.mm}
172041c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@property (assign, readwrite) int MyProperty;
17210982205bade2fb4fc984c27b2ab401e683963b10James Dennett/// \endcode
17224afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCPropertyDecl : public NamedDecl {
172399ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie  virtual void anchor();
172482a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanianpublic:
1725a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner  enum PropertyAttributeKind {
17261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    OBJC_PR_noattr    = 0x00,
17271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    OBJC_PR_readonly  = 0x01,
1728a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    OBJC_PR_getter    = 0x02,
17291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    OBJC_PR_assign    = 0x04,
17301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    OBJC_PR_readwrite = 0x08,
1731a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    OBJC_PR_retain    = 0x10,
17321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    OBJC_PR_copy      = 0x20,
1733a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    OBJC_PR_nonatomic = 0x40,
173445937ae10a0f70f74508165aab4f2b63e18ea747Fariborz Jahanian    OBJC_PR_setter    = 0x80,
1735f85e193739c953358c865005855253af4f68a497John McCall    OBJC_PR_atomic    = 0x100,
1736f85e193739c953358c865005855253af4f68a497John McCall    OBJC_PR_weak      = 0x200,
1737f85e193739c953358c865005855253af4f68a497John McCall    OBJC_PR_strong    = 0x400,
17389f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis    OBJC_PR_unsafe_unretained = 0x800
17399f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis    // Adding a property should change NumPropertyAttrsBits
17409f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis  };
17410a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis
17429f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis  enum {
17430a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis    /// \brief Number of bits fitting all the property attributes.
17449f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis    NumPropertyAttrsBits = 12
1745a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner  };
1746af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar
17473a02b44e3948f7762dbfba94b7961281ca29d022Fariborz Jahanian  enum SetterKind { Assign, Retain, Copy, Weak };
174846b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  enum PropertyControl { None, Required, Optional };
174982a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanianprivate:
175041c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  SourceLocation AtLoc;   // location of \@property
175177bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian  SourceLocation LParenLoc; // location of '(' starting attribute list or null.
175283a230c83a54190366138c1a4f4310ef838b88fcJohn McCall  TypeSourceInfo *DeclType;
17539f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis  unsigned PropertyAttributes : NumPropertyAttrsBits;
17549f3480bab8fcb6547978f8ad9e2b8f468e3658eeArgyrios Kyrtzidis  unsigned PropertyAttributesAsWritten : NumPropertyAttrsBits;
175541c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  // \@required/\@optional
175646b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  unsigned PropertyImplementation : 2;
17571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
17585251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  Selector GetterName;    // getter name of NULL if no getter
17595251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  Selector SetterName;    // setter name of NULL if no setter
17601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
176133de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  ObjCMethodDecl *GetterMethodDecl; // Declaration of getter instance method
176233de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  ObjCMethodDecl *SetterMethodDecl; // Declaration of setter instance method
1763af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian  ObjCIvarDecl *PropertyIvarDecl;   // Synthesize ivar for this property
176433de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian
17651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
176677bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian                   SourceLocation AtLocation,  SourceLocation LParenLocation,
176777bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian                   TypeSourceInfo *T)
176877bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian    : NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation),
176977bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian      LParenLoc(LParenLocation), DeclType(T),
1770ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie      PropertyAttributes(OBJC_PR_noattr),
177180aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian      PropertyAttributesAsWritten(OBJC_PR_noattr),
177280aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian      PropertyImplementation(None),
17731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      GetterName(Selector()),
177433de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian      SetterName(Selector()),
1775af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian      GetterMethodDecl(0), SetterMethodDecl(0) , PropertyIvarDecl(0) {}
1776f8d17a59167d9c2026506ed8813ea434d93b662aChris Lattnerpublic:
17771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC,
17781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                  SourceLocation L,
1779d0502407c1b41b2ace326f355d7b7a6876246223Fariborz Jahanian                                  IdentifierInfo *Id, SourceLocation AtLocation,
178077bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian                                  SourceLocation LParenLocation,
178183a230c83a54190366138c1a4f4310ef838b88fcJohn McCall                                  TypeSourceInfo *T,
178246b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian                                  PropertyControl propControl = None);
17831e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor
17841e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor  static ObjCPropertyDecl *CreateDeserialized(ASTContext &C, unsigned ID);
17851e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor
1786d0502407c1b41b2ace326f355d7b7a6876246223Fariborz Jahanian  SourceLocation getAtLoc() const { return AtLoc; }
1787d0502407c1b41b2ace326f355d7b7a6876246223Fariborz Jahanian  void setAtLoc(SourceLocation L) { AtLoc = L; }
178877bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian
178977bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian  SourceLocation getLParenLoc() const { return LParenLoc; }
179077bfb8b43ec3f7dee3a71f6e854b03ad29dab84fFariborz Jahanian  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
1791ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
179283a230c83a54190366138c1a4f4310ef838b88fcJohn McCall  TypeSourceInfo *getTypeSourceInfo() const { return DeclType; }
179383a230c83a54190366138c1a4f4310ef838b88fcJohn McCall  QualType getType() const { return DeclType->getType(); }
179483a230c83a54190366138c1a4f4310ef838b88fcJohn McCall  void setType(TypeSourceInfo *T) { DeclType = T; }
179570e5a14c6076d63833c62d1d6d628c26309897c1Douglas Gregor
1796a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner  PropertyAttributeKind getPropertyAttributes() const {
1797f4af5154571e0c5eadb19df10e65464766ef6683Chris Lattner    return PropertyAttributeKind(PropertyAttributes);
1798f4af5154571e0c5eadb19df10e65464766ef6683Chris Lattner  }
17991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  void setPropertyAttributes(PropertyAttributeKind PRVal) {
1800a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11Chris Lattner    PropertyAttributes |= PRVal;
180182a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian  }
1802394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar
180380aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian  PropertyAttributeKind getPropertyAttributesAsWritten() const {
180480aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian    return PropertyAttributeKind(PropertyAttributesAsWritten);
180580aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian  }
18060a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis
18070a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis  bool hasWrittenStorageAttribute() const {
18080a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis    return PropertyAttributesAsWritten & (OBJC_PR_assign | OBJC_PR_copy |
18090a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis        OBJC_PR_unsafe_unretained | OBJC_PR_retain | OBJC_PR_strong |
18100a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis        OBJC_PR_weak);
18110a68dc7f04be1542ce249ff4adb169453698ad91Argyrios Kyrtzidis  }
1812ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
181380aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian  void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal) {
181480aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian    PropertyAttributesAsWritten = PRVal;
181580aa1cd7973561889e51c1c152c8990a8de9c953Fariborz Jahanian  }
1816ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
18178cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian void makeitReadWriteAttribute(void) {
18188cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian    PropertyAttributes &= ~OBJC_PR_readonly;
18198cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian    PropertyAttributes |= OBJC_PR_readwrite;
18201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump }
18218cf0bb3c2a798ce3acacaac2d3178648cd4c65c6Fariborz Jahanian
1822af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  // Helper methods for accessing attributes.
1823af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar
1824af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  /// isReadOnly - Return true iff the property has a setter.
1825394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar  bool isReadOnly() const {
1826394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar    return (PropertyAttributes & OBJC_PR_readonly);
1827394d33f1f602f7681032a659dff5bb09061ee510Daniel Dunbar  }
1828af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar
1829265941bc308d65cc270d5c4de5806f37ce405606John McCall  /// isAtomic - Return true if the property is atomic.
1830265941bc308d65cc270d5c4de5806f37ce405606John McCall  bool isAtomic() const {
1831265941bc308d65cc270d5c4de5806f37ce405606John McCall    return (PropertyAttributes & OBJC_PR_atomic);
1832265941bc308d65cc270d5c4de5806f37ce405606John McCall  }
1833265941bc308d65cc270d5c4de5806f37ce405606John McCall
1834265941bc308d65cc270d5c4de5806f37ce405606John McCall  /// isRetaining - Return true if the property retains its value.
1835265941bc308d65cc270d5c4de5806f37ce405606John McCall  bool isRetaining() const {
1836265941bc308d65cc270d5c4de5806f37ce405606John McCall    return (PropertyAttributes &
1837265941bc308d65cc270d5c4de5806f37ce405606John McCall            (OBJC_PR_retain | OBJC_PR_strong | OBJC_PR_copy));
1838265941bc308d65cc270d5c4de5806f37ce405606John McCall  }
1839265941bc308d65cc270d5c4de5806f37ce405606John McCall
1840af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  /// getSetterKind - Return the method used for doing assignment in
1841af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  /// the property setter. This is only valid if the property has been
1842af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  /// defined to have a setter.
1843af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  SetterKind getSetterKind() const {
18446dc6f008994472cf4da321855e8c51c39720f3edJohn McCall    if (PropertyAttributes & OBJC_PR_strong)
18456dc6f008994472cf4da321855e8c51c39720f3edJohn McCall      return getType()->isBlockPointerType() ? Copy : Retain;
18466dc6f008994472cf4da321855e8c51c39720f3edJohn McCall    if (PropertyAttributes & OBJC_PR_retain)
1847af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar      return Retain;
1848af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar    if (PropertyAttributes & OBJC_PR_copy)
1849af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar      return Copy;
18503a02b44e3948f7762dbfba94b7961281ca29d022Fariborz Jahanian    if (PropertyAttributes & OBJC_PR_weak)
18513a02b44e3948f7762dbfba94b7961281ca29d022Fariborz Jahanian      return Weak;
1852af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar    return Assign;
1853af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  }
1854af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar
18555251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  Selector getGetterName() const { return GetterName; }
18565251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  void setGetterName(Selector Sel) { GetterName = Sel; }
18571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18585251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  Selector getSetterName() const { return SetterName; }
18595251e130a23d997f7c0dfdc250cdc41f179e5bedFariborz Jahanian  void setSetterName(Selector Sel) { SetterName = Sel; }
18601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
186133de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  ObjCMethodDecl *getGetterMethodDecl() const { return GetterMethodDecl; }
186233de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  void setGetterMethodDecl(ObjCMethodDecl *gDecl) { GetterMethodDecl = gDecl; }
186333de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian
186433de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  ObjCMethodDecl *getSetterMethodDecl() const { return SetterMethodDecl; }
186533de3f0333ca0b5274291b8d76c86758c0484691Fariborz Jahanian  void setSetterMethodDecl(ObjCMethodDecl *gDecl) { SetterMethodDecl = gDecl; }
18661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
186741c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  // Related to \@optional/\@required declared in \@protocol
186846b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  void setPropertyImplementation(PropertyControl pc) {
186946b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian    PropertyImplementation = pc;
187046b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  }
187146b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian  PropertyControl getPropertyImplementation() const {
187246b55e56d029aec699fc2701e43d70264da9ecd8Fariborz Jahanian    return PropertyControl(PropertyImplementation);
18731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  }
18741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1875af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian  void setPropertyIvarDecl(ObjCIvarDecl *Ivar) {
1876af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian    PropertyIvarDecl = Ivar;
1877af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian  }
1878af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian  ObjCIvarDecl *getPropertyIvarDecl() const {
1879af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian    return PropertyIvarDecl;
1880af3e72285238369c2ea4ebd40a1c9a87bd3eabb7Fariborz Jahanian  }
18811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1882aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar  virtual SourceRange getSourceRange() const LLVM_READONLY {
1883e3c60a7ce9e0f42c7ca2344b33203266aceca1dbDouglas Gregor    return SourceRange(AtLoc, getLocation());
1884e3c60a7ce9e0f42c7ca2344b33203266aceca1dbDouglas Gregor  }
1885e3c60a7ce9e0f42c7ca2344b33203266aceca1dbDouglas Gregor
18869f550ff05d496e6b9480e5619a21d9da0c9e27c1Ted Kremenek  /// Lookup a property by name in the specified DeclContext.
1887de09d0c9694f01a99870a8825266d44a29ebb325Ted Kremenek  static ObjCPropertyDecl *findPropertyDecl(const DeclContext *DC,
18889f550ff05d496e6b9480e5619a21d9da0c9e27c1Ted Kremenek                                            IdentifierInfo *propertyID);
18899f550ff05d496e6b9480e5619a21d9da0c9e27c1Ted Kremenek
189080cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1891a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  static bool classof(const ObjCPropertyDecl *D) { return true; }
189280cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Kind K) { return K == ObjCProperty; }
189382a5fe3d1cf204b672cdab24d72275b6ad2c3527Fariborz Jahanian};
1894980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
18951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// ObjCPropertyImplDecl - Represents implementation declaration of a property
189661d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian/// in a class or category implementation block. For example:
189741c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth/// \@synthesize prop1 = ivar1;
189861d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian///
18994afa39deaa245592977136d367251ee2c173dd8dDouglas Gregorclass ObjCPropertyImplDecl : public Decl {
190061d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanianpublic:
19019f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar  enum Kind {
19029f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar    Synthesize,
19039f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar    Dynamic
190461d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  };
190561d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanianprivate:
190641c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  SourceLocation AtLoc;   // location of \@synthesize or \@dynamic
1907ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
190841c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// \brief For \@synthesize, the location of the ivar, if it was written in
1909a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  /// the source code.
1910a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  ///
1911a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  /// \code
191241c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// \@synthesize int a = b
1913a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  /// \endcode
1914a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  SourceLocation IvarLoc;
1915ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
191661d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  /// Property declaration being implemented
191761d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  ObjCPropertyDecl *PropertyDecl;
1918be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek
191941c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// Null for \@dynamic. Required for \@synthesize.
192061d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian  ObjCIvarDecl *PropertyIvarDecl;
1921ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
192241c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// Null for \@dynamic. Non-null if property must be copy-constructed in
192341c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// getter.
192417cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  Expr *GetterCXXConstructor;
1925ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
192641c2bcff88a23a046ee8d71451bc03717a4248f6Chandler Carruth  /// Null for \@dynamic. Non-null if property has assignment operator to call
192717cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  /// in Setter synthesis.
192817cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  Expr *SetterCXXAssignment;
1929be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek
1930d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  ObjCPropertyImplDecl(DeclContext *DC, SourceLocation atLoc, SourceLocation L,
19311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                       ObjCPropertyDecl *property,
19321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                       Kind PK,
1933a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor                       ObjCIvarDecl *ivarDecl,
1934a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor                       SourceLocation ivarLoc)
19351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    : Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc),
1936ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie      IvarLoc(ivarLoc), PropertyDecl(property), PropertyIvarDecl(ivarDecl),
193717cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian      GetterCXXConstructor(0), SetterCXXAssignment(0) {
19389f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar    assert (PK == Dynamic || PropertyIvarDecl);
19399f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar  }
19401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
19419f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbarpublic:
1942d04341000d35c8808a72838b057eed7bf13b7661Douglas Gregor  static ObjCPropertyImplDecl *Create(ASTContext &C, DeclContext *DC,
19431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                      SourceLocation atLoc, SourceLocation L,
19441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                      ObjCPropertyDecl *property,
19451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                      Kind PK,
1946a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor                                      ObjCIvarDecl *ivarDecl,
1947a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor                                      SourceLocation ivarLoc);
194861d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian
19491e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor  static ObjCPropertyImplDecl *CreateDeserialized(ASTContext &C, unsigned ID);
19501e68ecc4fcce12f683c4fd38acfd1a004001b04fDouglas Gregor
1951aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar  virtual SourceRange getSourceRange() const LLVM_READONLY;
1952ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
1953aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar  SourceLocation getLocStart() const LLVM_READONLY { return AtLoc; }
19548818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor  void setAtLoc(SourceLocation Loc) { AtLoc = Loc; }
1955d40910b581b09c937a8c1fdcde9b8ec724398fb9Steve Naroff
1956be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek  ObjCPropertyDecl *getPropertyDecl() const {
1957be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek    return PropertyDecl;
1958be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek  }
19598818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor  void setPropertyDecl(ObjCPropertyDecl *Prop) { PropertyDecl = Prop; }
19608818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor
19619f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar  Kind getPropertyImplementation() const {
19629f0afd4e79601d9982072ff9318e6f9a982c770eDaniel Dunbar    return PropertyIvarDecl ? Synthesize : Dynamic;
1963be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek  }
19641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1965af05bb9073319d8381b71c4325188853fd4b8ed6Daniel Dunbar  ObjCIvarDecl *getPropertyIvarDecl() const {
1966be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek    return PropertyIvarDecl;
1967be57c3a3fef0776fca57ad88b2db263f37b074c4Ted Kremenek  }
1968a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  SourceLocation getPropertyIvarDeclLoc() const { return IvarLoc; }
1969ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
1970a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  void setPropertyIvarDecl(ObjCIvarDecl *Ivar,
1971ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie                           SourceLocation IvarLoc) {
1972ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie    PropertyIvarDecl = Ivar;
1973a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor    this->IvarLoc = IvarLoc;
1974a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  }
1975ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
1976135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis  /// \brief For \@synthesize, returns true if an ivar name was explicitly
1977135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis  /// specified.
1978135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis  ///
1979135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis  /// \code
1980135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis  /// \@synthesize int a = b; // true
1981135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis  /// \@synthesize int a; // false
1982135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis  /// \endcode
1983135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis  bool isIvarNameSpecified() const {
1984135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis    return IvarLoc.isValid() && IvarLoc != getLocation();
1985135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis  }
1986135bf8ee69e2ae2daea4f713381995028c41e264Argyrios Kyrtzidis
198717cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  Expr *getGetterCXXConstructor() const {
198817cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian    return GetterCXXConstructor;
198917cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  }
199017cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  void setGetterCXXConstructor(Expr *getterCXXConstructor) {
199117cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian    GetterCXXConstructor = getterCXXConstructor;
199217cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  }
19938818c4fb69cb2a4eec94b217a90f94f9e075296eDouglas Gregor
199417cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  Expr *getSetterCXXAssignment() const {
199517cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian    return SetterCXXAssignment;
199617cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  }
199717cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  void setSetterCXXAssignment(Expr *setterCXXAssignment) {
199817cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian    SetterCXXAssignment = setterCXXAssignment;
199917cb326cb62a59f53d92236394af40eaae4eddbdFariborz Jahanian  }
2000ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
200180cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
20021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const ObjCPropertyImplDecl *D) { return true; }
200380cd64a8450d8e2c079dc134d9711cd45ba89d63John McCall  static bool classofKind(Decl::Kind K) { return K == ObjCPropertyImpl; }
2004ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
2005a4ffd85a6684e42f900aad5459e58ad91bb88755Douglas Gregor  friend class ASTDeclReader;
200661d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian};
200761d46159af2a740207de8dc024211d531ae290d9Fariborz Jahanian
2008980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}  // end namespace clang
2009980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#endif
2010