192b7f70c924cbf4514e9e434cea7def51ab49860John McCall//===-- DeclFriend.h - Classes for C++ friend declarations -*- C++ -*------===//
292b7f70c924cbf4514e9e434cea7def51ab49860John McCall//
392b7f70c924cbf4514e9e434cea7def51ab49860John McCall//                     The LLVM Compiler Infrastructure
492b7f70c924cbf4514e9e434cea7def51ab49860John McCall//
592b7f70c924cbf4514e9e434cea7def51ab49860John McCall// This file is distributed under the University of Illinois Open Source
692b7f70c924cbf4514e9e434cea7def51ab49860John McCall// License. See LICENSE.TXT for details.
792b7f70c924cbf4514e9e434cea7def51ab49860John McCall//
892b7f70c924cbf4514e9e434cea7def51ab49860John McCall//===----------------------------------------------------------------------===//
992b7f70c924cbf4514e9e434cea7def51ab49860John McCall//
1092b7f70c924cbf4514e9e434cea7def51ab49860John McCall// This file defines the section of the AST representing C++ friend
1192b7f70c924cbf4514e9e434cea7def51ab49860John McCall// declarations.
1292b7f70c924cbf4514e9e434cea7def51ab49860John McCall//
1392b7f70c924cbf4514e9e434cea7def51ab49860John McCall//===----------------------------------------------------------------------===//
1492b7f70c924cbf4514e9e434cea7def51ab49860John McCall
1592b7f70c924cbf4514e9e434cea7def51ab49860John McCall#ifndef LLVM_CLANG_AST_DECLFRIEND_H
1692b7f70c924cbf4514e9e434cea7def51ab49860John McCall#define LLVM_CLANG_AST_DECLFRIEND_H
1792b7f70c924cbf4514e9e434cea7def51ab49860John McCall
1892b7f70c924cbf4514e9e434cea7def51ab49860John McCall#include "clang/AST/DeclCXX.h"
1903a400510fb8ba2e88e27c95ec797d944d944c4bAbramo Bagnara#include "clang/AST/DeclTemplate.h"
20aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar#include "llvm/Support/Compiler.h"
2192b7f70c924cbf4514e9e434cea7def51ab49860John McCall
2292b7f70c924cbf4514e9e434cea7def51ab49860John McCallnamespace clang {
2392b7f70c924cbf4514e9e434cea7def51ab49860John McCall
2492b7f70c924cbf4514e9e434cea7def51ab49860John McCall/// FriendDecl - Represents the declaration of a friend entity,
2592b7f70c924cbf4514e9e434cea7def51ab49860John McCall/// which can be a function, a type, or a templated function or type.
2692b7f70c924cbf4514e9e434cea7def51ab49860John McCall//  For example:
2792b7f70c924cbf4514e9e434cea7def51ab49860John McCall///
2892b7f70c924cbf4514e9e434cea7def51ab49860John McCall/// @code
2992b7f70c924cbf4514e9e434cea7def51ab49860John McCall/// template <typename T> class A {
3092b7f70c924cbf4514e9e434cea7def51ab49860John McCall///   friend int foo(T);
3192b7f70c924cbf4514e9e434cea7def51ab49860John McCall///   friend class B;
3292b7f70c924cbf4514e9e434cea7def51ab49860John McCall///   friend T; // only in C++0x
3392b7f70c924cbf4514e9e434cea7def51ab49860John McCall///   template <typename U> friend class C;
3492b7f70c924cbf4514e9e434cea7def51ab49860John McCall///   template <typename U> friend A& operator+=(A&, const U&) { ... }
3592b7f70c924cbf4514e9e434cea7def51ab49860John McCall/// };
3692b7f70c924cbf4514e9e434cea7def51ab49860John McCall/// @endcode
3792b7f70c924cbf4514e9e434cea7def51ab49860John McCall///
3892b7f70c924cbf4514e9e434cea7def51ab49860John McCall/// The semantic context of a friend decl is its declaring class.
3992b7f70c924cbf4514e9e434cea7def51ab49860John McCallclass FriendDecl : public Decl {
4099ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie  virtual void anchor();
4192b7f70c924cbf4514e9e434cea7def51ab49860John McCallpublic:
4232f2fb53d9d7c28c94d8569fd0fcf06cccee0c3dJohn McCall  typedef llvm::PointerUnion<NamedDecl*,TypeSourceInfo*> FriendUnion;
4392b7f70c924cbf4514e9e434cea7def51ab49860John McCall
4492b7f70c924cbf4514e9e434cea7def51ab49860John McCallprivate:
4592b7f70c924cbf4514e9e434cea7def51ab49860John McCall  // The declaration that's a friend of this class.
4692b7f70c924cbf4514e9e434cea7def51ab49860John McCall  FriendUnion Friend;
4792b7f70c924cbf4514e9e434cea7def51ab49860John McCall
48d60e22e601852ae1345f01514318a0951dc09f89John McCall  // A pointer to the next friend in the sequence.
4969aecc6252bf4a5ee59f9b51c3728ea07b6342bfDouglas Gregor  LazyDeclPtr NextFriend;
50d60e22e601852ae1345f01514318a0951dc09f89John McCall
5192b7f70c924cbf4514e9e434cea7def51ab49860John McCall  // Location of the 'friend' specifier.
5292b7f70c924cbf4514e9e434cea7def51ab49860John McCall  SourceLocation FriendLoc;
5392b7f70c924cbf4514e9e434cea7def51ab49860John McCall
546102ca1d490836096678d7d934f0b2b78f9293ecJohn McCall  /// True if this 'friend' declaration is unsupported.  Eventually we
556102ca1d490836096678d7d934f0b2b78f9293ecJohn McCall  /// will support every possible friend declaration, but for now we
566102ca1d490836096678d7d934f0b2b78f9293ecJohn McCall  /// silently ignore some and set this flag to authorize all access.
578c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella  bool UnsupportedFriend : 1;
588c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella
598c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella  // The number of "outer" template parameter lists in non-templatic
608c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella  // (currently unsupported) friend type declarations, such as
618c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella  //     template <class T> friend class A<T>::B;
628c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella  unsigned NumTPLists : 31;
638c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella
648c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella  // The tail-allocated friend type template parameter lists (if any).
658c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella  TemplateParameterList* const *getTPLists() const {
668c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella    return reinterpret_cast<TemplateParameterList* const *>(this + 1);
678c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella  }
688c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella  TemplateParameterList **getTPLists() {
698c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella    return reinterpret_cast<TemplateParameterList**>(this + 1);
708c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella  }
716102ca1d490836096678d7d934f0b2b78f9293ecJohn McCall
72d60e22e601852ae1345f01514318a0951dc09f89John McCall  friend class CXXRecordDecl::friend_iterator;
73d60e22e601852ae1345f01514318a0951dc09f89John McCall  friend class CXXRecordDecl;
74d60e22e601852ae1345f01514318a0951dc09f89John McCall
7592b7f70c924cbf4514e9e434cea7def51ab49860John McCall  FriendDecl(DeclContext *DC, SourceLocation L, FriendUnion Friend,
768c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella             SourceLocation FriendL,
778c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella             ArrayRef<TemplateParameterList*> FriendTypeTPLists)
7892b7f70c924cbf4514e9e434cea7def51ab49860John McCall    : Decl(Decl::Friend, DC, L),
7992b7f70c924cbf4514e9e434cea7def51ab49860John McCall      Friend(Friend),
8069aecc6252bf4a5ee59f9b51c3728ea07b6342bfDouglas Gregor      NextFriend(),
816102ca1d490836096678d7d934f0b2b78f9293ecJohn McCall      FriendLoc(FriendL),
828c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella      UnsupportedFriend(false),
838c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella      NumTPLists(FriendTypeTPLists.size()) {
848c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella    for (unsigned i = 0; i < NumTPLists; ++i)
858c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella      getTPLists()[i] = FriendTypeTPLists[i];
8692b7f70c924cbf4514e9e434cea7def51ab49860John McCall  }
8792b7f70c924cbf4514e9e434cea7def51ab49860John McCall
888c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella  FriendDecl(EmptyShell Empty, unsigned NumFriendTypeTPLists)
898c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella    : Decl(Decl::Friend, Empty), NextFriend(),
908c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella      NumTPLists(NumFriendTypeTPLists) { }
916764334dfa73d67cbbb1b1fc8fe00440aad00f2aArgyrios Kyrtzidis
9269aecc6252bf4a5ee59f9b51c3728ea07b6342bfDouglas Gregor  FriendDecl *getNextFriend() {
93471c8b49982d1132f30b0b0da27fef94fd6e4f67Benjamin Kramer    if (!NextFriend.isOffset())
94471c8b49982d1132f30b0b0da27fef94fd6e4f67Benjamin Kramer      return cast_or_null<FriendDecl>(NextFriend.get(0));
95471c8b49982d1132f30b0b0da27fef94fd6e4f67Benjamin Kramer    return getNextFriendSlowCase();
9669aecc6252bf4a5ee59f9b51c3728ea07b6342bfDouglas Gregor  }
97471c8b49982d1132f30b0b0da27fef94fd6e4f67Benjamin Kramer  FriendDecl *getNextFriendSlowCase();
98471c8b49982d1132f30b0b0da27fef94fd6e4f67Benjamin Kramer
9992b7f70c924cbf4514e9e434cea7def51ab49860John McCallpublic:
10092b7f70c924cbf4514e9e434cea7def51ab49860John McCall  static FriendDecl *Create(ASTContext &C, DeclContext *DC,
10192b7f70c924cbf4514e9e434cea7def51ab49860John McCall                            SourceLocation L, FriendUnion Friend_,
1028c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella                            SourceLocation FriendL,
1038c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella                            ArrayRef<TemplateParameterList*> FriendTypeTPLists
1045543169296beeb183b9c9392debc774fcf493eebDmitri Gribenko                            = None);
1058c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella  static FriendDecl *CreateDeserialized(ASTContext &C, unsigned ID,
1068c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella                                        unsigned FriendTypeNumTPLists);
10792b7f70c924cbf4514e9e434cea7def51ab49860John McCall
108710672485039d3dd355748876299fff88e8ad84cCraig Silverstein  /// If this friend declaration names an (untemplated but possibly
109710672485039d3dd355748876299fff88e8ad84cCraig Silverstein  /// dependent) type, return the type; otherwise return null.  This
110710672485039d3dd355748876299fff88e8ad84cCraig Silverstein  /// is used for elaborated-type-specifiers and, in C++0x, for
111710672485039d3dd355748876299fff88e8ad84cCraig Silverstein  /// arbitrary friend type declarations.
11232f2fb53d9d7c28c94d8569fd0fcf06cccee0c3dJohn McCall  TypeSourceInfo *getFriendType() const {
11332f2fb53d9d7c28c94d8569fd0fcf06cccee0c3dJohn McCall    return Friend.dyn_cast<TypeSourceInfo*>();
11492b7f70c924cbf4514e9e434cea7def51ab49860John McCall  }
1158c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella  unsigned getFriendTypeNumTemplateParameterLists() const {
1168c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella    return NumTPLists;
1178c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella  }
1188c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella  TemplateParameterList *getFriendTypeTemplateParameterList(unsigned N) const {
1198c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella    assert(N < NumTPLists);
1208c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella    return getTPLists()[N];
1218c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella  }
12292b7f70c924cbf4514e9e434cea7def51ab49860John McCall
123710672485039d3dd355748876299fff88e8ad84cCraig Silverstein  /// If this friend declaration doesn't name a type, return the inner
124710672485039d3dd355748876299fff88e8ad84cCraig Silverstein  /// declaration.
12592b7f70c924cbf4514e9e434cea7def51ab49860John McCall  NamedDecl *getFriendDecl() const {
12692b7f70c924cbf4514e9e434cea7def51ab49860John McCall    return Friend.dyn_cast<NamedDecl*>();
12792b7f70c924cbf4514e9e434cea7def51ab49860John McCall  }
12892b7f70c924cbf4514e9e434cea7def51ab49860John McCall
12992b7f70c924cbf4514e9e434cea7def51ab49860John McCall  /// Retrieves the location of the 'friend' keyword.
13092b7f70c924cbf4514e9e434cea7def51ab49860John McCall  SourceLocation getFriendLoc() const {
13192b7f70c924cbf4514e9e434cea7def51ab49860John McCall    return FriendLoc;
13292b7f70c924cbf4514e9e434cea7def51ab49860John McCall  }
13392b7f70c924cbf4514e9e434cea7def51ab49860John McCall
1348fbb7628e9fc364bbfb65bdf2c2468b0d06a7e5bAbramo Bagnara  /// Retrieves the source range for the friend declaration.
135aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar  SourceRange getSourceRange() const LLVM_READONLY {
13603a400510fb8ba2e88e27c95ec797d944d944c4bAbramo Bagnara    if (NamedDecl *ND = getFriendDecl()) {
13703a400510fb8ba2e88e27c95ec797d944d944c4bAbramo Bagnara      if (FunctionTemplateDecl *FTD = dyn_cast<FunctionTemplateDecl>(ND))
13803a400510fb8ba2e88e27c95ec797d944d944c4bAbramo Bagnara        return FTD->getSourceRange();
13903a400510fb8ba2e88e27c95ec797d944d944c4bAbramo Bagnara      if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(ND)) {
14003a400510fb8ba2e88e27c95ec797d944d944c4bAbramo Bagnara        if (DD->getOuterLocStart() != DD->getInnerLocStart())
14103a400510fb8ba2e88e27c95ec797d944d944c4bAbramo Bagnara          return DD->getSourceRange();
14203a400510fb8ba2e88e27c95ec797d944d944c4bAbramo Bagnara      }
1438fbb7628e9fc364bbfb65bdf2c2468b0d06a7e5bAbramo Bagnara      return SourceRange(getFriendLoc(), ND->getLocEnd());
14403a400510fb8ba2e88e27c95ec797d944d944c4bAbramo Bagnara    }
1458c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella    else if (TypeSourceInfo *TInfo = getFriendType()) {
1468c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella      SourceLocation StartL = (NumTPLists == 0)
1478c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella        ? getFriendLoc()
1488c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella        : getTPLists()[0]->getTemplateLoc();
1498c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella      return SourceRange(StartL, TInfo->getTypeLoc().getEndLoc());
1508c84028ed9aa0dfd54ab729dee78f29c961d7f37Enea Zaffanella    }
1518fbb7628e9fc364bbfb65bdf2c2468b0d06a7e5bAbramo Bagnara    else
1528fbb7628e9fc364bbfb65bdf2c2468b0d06a7e5bAbramo Bagnara      return SourceRange(getFriendLoc(), getLocation());
1538fbb7628e9fc364bbfb65bdf2c2468b0d06a7e5bAbramo Bagnara  }
1548fbb7628e9fc364bbfb65bdf2c2468b0d06a7e5bAbramo Bagnara
1556102ca1d490836096678d7d934f0b2b78f9293ecJohn McCall  /// Determines if this friend kind is unsupported.
1566102ca1d490836096678d7d934f0b2b78f9293ecJohn McCall  bool isUnsupportedFriend() const {
1576102ca1d490836096678d7d934f0b2b78f9293ecJohn McCall    return UnsupportedFriend;
1586102ca1d490836096678d7d934f0b2b78f9293ecJohn McCall  }
1596102ca1d490836096678d7d934f0b2b78f9293ecJohn McCall  void setUnsupportedFriend(bool Unsupported) {
1606102ca1d490836096678d7d934f0b2b78f9293ecJohn McCall    UnsupportedFriend = Unsupported;
1616102ca1d490836096678d7d934f0b2b78f9293ecJohn McCall  }
1626102ca1d490836096678d7d934f0b2b78f9293ecJohn McCall
16392b7f70c924cbf4514e9e434cea7def51ab49860John McCall  // Implement isa/cast/dyncast/etc.
16492b7f70c924cbf4514e9e434cea7def51ab49860John McCall  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
16592b7f70c924cbf4514e9e434cea7def51ab49860John McCall  static bool classofKind(Kind K) { return K == Decl::Friend; }
1666764334dfa73d67cbbb1b1fc8fe00440aad00f2aArgyrios Kyrtzidis
167d527cc06d78fe5afa5f20105b51697637eb02c56Sebastian Redl  friend class ASTDeclReader;
1683397c5570369f19b2d6c52e898f708d75ceede1fSebastian Redl  friend class ASTDeclWriter;
16992b7f70c924cbf4514e9e434cea7def51ab49860John McCall};
170d60e22e601852ae1345f01514318a0951dc09f89John McCall
171d60e22e601852ae1345f01514318a0951dc09f89John McCall/// An iterator over the friend declarations of a class.
172d60e22e601852ae1345f01514318a0951dc09f89John McCallclass CXXRecordDecl::friend_iterator {
173d60e22e601852ae1345f01514318a0951dc09f89John McCall  FriendDecl *Ptr;
174d60e22e601852ae1345f01514318a0951dc09f89John McCall
175d60e22e601852ae1345f01514318a0951dc09f89John McCall  friend class CXXRecordDecl;
176d60e22e601852ae1345f01514318a0951dc09f89John McCall  explicit friend_iterator(FriendDecl *Ptr) : Ptr(Ptr) {}
177d60e22e601852ae1345f01514318a0951dc09f89John McCallpublic:
178d60e22e601852ae1345f01514318a0951dc09f89John McCall  friend_iterator() {}
179d60e22e601852ae1345f01514318a0951dc09f89John McCall
180d60e22e601852ae1345f01514318a0951dc09f89John McCall  typedef FriendDecl *value_type;
181d60e22e601852ae1345f01514318a0951dc09f89John McCall  typedef FriendDecl *reference;
182d60e22e601852ae1345f01514318a0951dc09f89John McCall  typedef FriendDecl *pointer;
183d60e22e601852ae1345f01514318a0951dc09f89John McCall  typedef int difference_type;
184d60e22e601852ae1345f01514318a0951dc09f89John McCall  typedef std::forward_iterator_tag iterator_category;
185d60e22e601852ae1345f01514318a0951dc09f89John McCall
186d60e22e601852ae1345f01514318a0951dc09f89John McCall  reference operator*() const { return Ptr; }
187d60e22e601852ae1345f01514318a0951dc09f89John McCall
188d60e22e601852ae1345f01514318a0951dc09f89John McCall  friend_iterator &operator++() {
189d60e22e601852ae1345f01514318a0951dc09f89John McCall    assert(Ptr && "attempt to increment past end of friend list");
19069aecc6252bf4a5ee59f9b51c3728ea07b6342bfDouglas Gregor    Ptr = Ptr->getNextFriend();
191d60e22e601852ae1345f01514318a0951dc09f89John McCall    return *this;
192d60e22e601852ae1345f01514318a0951dc09f89John McCall  }
193d60e22e601852ae1345f01514318a0951dc09f89John McCall
194d60e22e601852ae1345f01514318a0951dc09f89John McCall  friend_iterator operator++(int) {
195d60e22e601852ae1345f01514318a0951dc09f89John McCall    friend_iterator tmp = *this;
196d60e22e601852ae1345f01514318a0951dc09f89John McCall    ++*this;
197d60e22e601852ae1345f01514318a0951dc09f89John McCall    return tmp;
198d60e22e601852ae1345f01514318a0951dc09f89John McCall  }
199d60e22e601852ae1345f01514318a0951dc09f89John McCall
200d60e22e601852ae1345f01514318a0951dc09f89John McCall  bool operator==(const friend_iterator &Other) const {
201d60e22e601852ae1345f01514318a0951dc09f89John McCall    return Ptr == Other.Ptr;
202d60e22e601852ae1345f01514318a0951dc09f89John McCall  }
203d60e22e601852ae1345f01514318a0951dc09f89John McCall
204d60e22e601852ae1345f01514318a0951dc09f89John McCall  bool operator!=(const friend_iterator &Other) const {
205d60e22e601852ae1345f01514318a0951dc09f89John McCall    return Ptr != Other.Ptr;
206d60e22e601852ae1345f01514318a0951dc09f89John McCall  }
207d60e22e601852ae1345f01514318a0951dc09f89John McCall
208d60e22e601852ae1345f01514318a0951dc09f89John McCall  friend_iterator &operator+=(difference_type N) {
209d60e22e601852ae1345f01514318a0951dc09f89John McCall    assert(N >= 0 && "cannot rewind a CXXRecordDecl::friend_iterator");
210d60e22e601852ae1345f01514318a0951dc09f89John McCall    while (N--)
211d60e22e601852ae1345f01514318a0951dc09f89John McCall      ++*this;
212d60e22e601852ae1345f01514318a0951dc09f89John McCall    return *this;
213d60e22e601852ae1345f01514318a0951dc09f89John McCall  }
214d60e22e601852ae1345f01514318a0951dc09f89John McCall
215d60e22e601852ae1345f01514318a0951dc09f89John McCall  friend_iterator operator+(difference_type N) const {
216d60e22e601852ae1345f01514318a0951dc09f89John McCall    friend_iterator tmp = *this;
217d60e22e601852ae1345f01514318a0951dc09f89John McCall    tmp += N;
218d60e22e601852ae1345f01514318a0951dc09f89John McCall    return tmp;
219d60e22e601852ae1345f01514318a0951dc09f89John McCall  }
220d60e22e601852ae1345f01514318a0951dc09f89John McCall};
221d60e22e601852ae1345f01514318a0951dc09f89John McCall
222d60e22e601852ae1345f01514318a0951dc09f89John McCallinline CXXRecordDecl::friend_iterator CXXRecordDecl::friend_begin() const {
2234fc5089e306fe606f2e3e4fa58063ebab35deb62Richard Smith  return friend_iterator(getFirstFriend());
224d60e22e601852ae1345f01514318a0951dc09f89John McCall}
225d60e22e601852ae1345f01514318a0951dc09f89John McCall
226d60e22e601852ae1345f01514318a0951dc09f89John McCallinline CXXRecordDecl::friend_iterator CXXRecordDecl::friend_end() const {
227d60e22e601852ae1345f01514318a0951dc09f89John McCall  return friend_iterator(0);
228d60e22e601852ae1345f01514318a0951dc09f89John McCall}
229d60e22e601852ae1345f01514318a0951dc09f89John McCall
230d60e22e601852ae1345f01514318a0951dc09f89John McCallinline void CXXRecordDecl::pushFriendDecl(FriendDecl *FD) {
2317247c88d1e41514a41085f83ebf03dd5220e054aDavid Blaikie  assert(!FD->NextFriend && "friend already has next friend?");
232d60e22e601852ae1345f01514318a0951dc09f89John McCall  FD->NextFriend = data().FirstFriend;
233d60e22e601852ae1345f01514318a0951dc09f89John McCall  data().FirstFriend = FD;
234d60e22e601852ae1345f01514318a0951dc09f89John McCall}
23592b7f70c924cbf4514e9e434cea7def51ab49860John McCall
23692b7f70c924cbf4514e9e434cea7def51ab49860John McCall}
23792b7f70c924cbf4514e9e434cea7def51ab49860John McCall
23892b7f70c924cbf4514e9e434cea7def51ab49860John McCall#endif
239