[cfe-commits] r117480 - in /cfe/trunk: include/clang/AST/DeclFriend.h lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriterDecl.cpp
Douglas Gregor
dgregor at apple.com
Wed Oct 27 13:23:41 PDT 2010
Author: dgregor
Date: Wed Oct 27 15:23:41 2010
New Revision: 117480
URL: http://llvm.org/viewvc/llvm-project?rev=117480&view=rev
Log:
Lazily load the next friend in the chain of FriendDecls, to eliminate
some excessive recursion and deserialization.
Modified:
cfe/trunk/include/clang/AST/DeclFriend.h
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
Modified: cfe/trunk/include/clang/AST/DeclFriend.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclFriend.h?rev=117480&r1=117479&r2=117480&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclFriend.h (original)
+++ cfe/trunk/include/clang/AST/DeclFriend.h Wed Oct 27 15:23:41 2010
@@ -43,7 +43,7 @@
FriendUnion Friend;
// A pointer to the next friend in the sequence.
- FriendDecl *NextFriend;
+ LazyDeclPtr NextFriend;
// Location of the 'friend' specifier.
SourceLocation FriendLoc;
@@ -60,14 +60,19 @@
SourceLocation FriendL)
: Decl(Decl::Friend, DC, L),
Friend(Friend),
- NextFriend(0),
+ NextFriend(),
FriendLoc(FriendL),
UnsupportedFriend(false) {
}
explicit FriendDecl(EmptyShell Empty)
- : Decl(Decl::Friend, Empty), NextFriend(0) { }
+ : Decl(Decl::Friend, Empty), NextFriend() { }
+ FriendDecl *getNextFriend() {
+ return cast_or_null<FriendDecl>(
+ NextFriend.get(getASTContext().getExternalSource()));
+ }
+
public:
static FriendDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, FriendUnion Friend_,
@@ -129,7 +134,7 @@
friend_iterator &operator++() {
assert(Ptr && "attempt to increment past end of friend list");
- Ptr = Ptr->NextFriend;
+ Ptr = Ptr->getNextFriend();
return *this;
}
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=117480&r1=117479&r2=117480&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Oct 27 15:23:41 2010
@@ -933,7 +933,7 @@
D->Friend = GetTypeSourceInfo(Record, Idx);
else
D->Friend = cast<NamedDecl>(Reader.GetDecl(Record[Idx++]));
- D->NextFriend = cast_or_null<FriendDecl>(Reader.GetDecl(Record[Idx++]));
+ D->NextFriend = Record[Idx++];
D->UnsupportedFriend = (Record[Idx++] != 0);
D->FriendLoc = ReadSourceLocation(Record, Idx);
}
Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=117480&r1=117479&r2=117480&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Wed Oct 27 15:23:41 2010
@@ -803,7 +803,7 @@
Writer.AddTypeSourceInfo(D->Friend.get<TypeSourceInfo*>(), Record);
else
Writer.AddDeclRef(D->Friend.get<NamedDecl*>(), Record);
- Writer.AddDeclRef(D->NextFriend, Record);
+ Writer.AddDeclRef(D->getNextFriend(), Record);
Record.push_back(D->UnsupportedFriend);
Writer.AddSourceLocation(D->FriendLoc, Record);
Code = serialization::DECL_FRIEND;
More information about the cfe-commits
mailing list