summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/PCHWriterDecl.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-06-29 22:47:00 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-06-29 22:47:00 +0000
commit74d28bd084a29eac89aa16ed452582df91cfa1fd (patch)
tree071f643dbf3e1e54a0df522cef266277a232d76a /clang/lib/Frontend/PCHWriterDecl.cpp
parent26d7201d5d6eca1eb5dcf04c0f7a2af97fc46d4d (diff)
downloadbcm5719-llvm-74d28bd084a29eac89aa16ed452582df91cfa1fd.tar.gz
bcm5719-llvm-74d28bd084a29eac89aa16ed452582df91cfa1fd.zip
Support C++ friend declarations for PCH.
This commit 'introduces' a slightly different way to restore the state of the AST object. It makes PCHDeclReader/PCHDeclWriter friends and gives them access to the private members of the object. The rationale is to avoid using/modifying the AST interfaces for PCH read/write so that to: -Avoid complications with objects that have side-effects during creation or when using some setters. -Not 'pollute' the AST interface with methods only used by the PCH reader/writer -Allow AST objects to be read-only. llvm-svn: 107219
Diffstat (limited to 'clang/lib/Frontend/PCHWriterDecl.cpp')
-rw-r--r--clang/lib/Frontend/PCHWriterDecl.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/clang/lib/Frontend/PCHWriterDecl.cpp b/clang/lib/Frontend/PCHWriterDecl.cpp
index 42d506953cb..309cc3536d9 100644
--- a/clang/lib/Frontend/PCHWriterDecl.cpp
+++ b/clang/lib/Frontend/PCHWriterDecl.cpp
@@ -25,7 +25,7 @@ using namespace clang;
// Declaration serialization
//===----------------------------------------------------------------------===//
-namespace {
+namespace clang {
class PCHDeclWriter : public DeclVisitor<PCHDeclWriter, void> {
PCHWriter &Writer;
@@ -82,6 +82,7 @@ namespace {
void VisitLinkageSpecDecl(LinkageSpecDecl *D);
void VisitFileScopeAsmDecl(FileScopeAsmDecl *D);
void VisitAccessSpecDecl(AccessSpecDecl *D);
+ void VisitFriendDecl(FriendDecl *D);
void VisitFriendTemplateDecl(FriendTemplateDecl *D);
void VisitStaticAssertDecl(StaticAssertDecl *D);
void VisitBlockDecl(BlockDecl *D);
@@ -636,7 +637,6 @@ void PCHDeclWriter::WriteCXXBaseSpecifier(const CXXBaseSpecifier *Base) {
}
void PCHDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
- // assert(false && "cannot write CXXRecordDecl");
VisitRecordDecl(D);
enum {
@@ -664,6 +664,8 @@ void PCHDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
for (CXXRecordDecl::base_class_iterator I = D->bases_begin(),
E = D->bases_end(); I != E; ++I)
WriteCXXBaseSpecifier(&*I);
+
+ Writer.AddDeclRef(D->data().FirstFriend, Record);
}
Code = pch::DECL_CXX_RECORD;
}
@@ -698,6 +700,17 @@ void PCHDeclWriter::VisitAccessSpecDecl(AccessSpecDecl *D) {
Code = pch::DECL_ACCESS_SPEC;
}
+void PCHDeclWriter::VisitFriendDecl(FriendDecl *D) {
+ Record.push_back(D->Friend.is<TypeSourceInfo*>());
+ if (D->Friend.is<TypeSourceInfo*>())
+ Writer.AddTypeSourceInfo(D->Friend.get<TypeSourceInfo*>(), Record);
+ else
+ Writer.AddDeclRef(D->Friend.get<NamedDecl*>(), Record);
+ Writer.AddDeclRef(D->NextFriend, Record);
+ Writer.AddSourceLocation(D->FriendLoc, Record);
+ Code = pch::DECL_FRIEND;
+}
+
void PCHDeclWriter::VisitFriendTemplateDecl(FriendTemplateDecl *D) {
assert(false && "cannot write FriendTemplateDecl");
}
OpenPOWER on IntegriCloud