[C++11] Replacing CXXRecordDecl iterators friend_begin() and friend_end() with iterator_range friends(). Updating all of the usages of the iterators with range-based for loops.

llvm-svn: 203815
This commit is contained in:
Aaron Ballman 2014-03-13 17:00:06 +00:00
parent 2a4bd6d189
commit 522a6ddf9e
3 changed files with 8 additions and 4 deletions

View File

@ -745,6 +745,9 @@ public:
/// An iterator over friend declarations. All of these are defined
/// in DeclFriend.h.
class friend_iterator;
typedef llvm::iterator_range<friend_iterator> friend_range;
friend_range friends() const;
friend_iterator friend_begin() const;
friend_iterator friend_end() const;
void pushFriendDecl(FriendDecl *FD);

View File

@ -227,6 +227,10 @@ inline CXXRecordDecl::friend_iterator CXXRecordDecl::friend_end() const {
return friend_iterator(0);
}
inline CXXRecordDecl::friend_range CXXRecordDecl::friends() const {
return friend_range(friend_begin(), friend_end());
}
inline void CXXRecordDecl::pushFriendDecl(FriendDecl *FD) {
assert(!FD->NextFriend && "friend already has next friend?");
FD->NextFriend = data().FirstFriend;

View File

@ -571,10 +571,7 @@ static AccessResult GetFriendKind(Sema &S,
AccessResult OnFailure = AR_inaccessible;
// Okay, check friends.
for (CXXRecordDecl::friend_iterator I = Class->friend_begin(),
E = Class->friend_end(); I != E; ++I) {
FriendDecl *Friend = *I;
for (auto *Friend : Class->friends()) {
switch (MatchesFriend(S, EC, Friend)) {
case AR_accessible:
return AR_accessible;