aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclGroup.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-10-07 23:06:01 +0000
committerTed Kremenek <kremenek@apple.com>2008-10-07 23:06:01 +0000
commit401adfad4af45b083ad067f3ebec5cf23a1e91cf (patch)
tree9e80dde84c9eced6daa9716e8caf856205349052 /lib/AST/DeclGroup.cpp
parent3e6d1203b3346147cee51a8a6d374f1867f2cd23 (diff)
Add const_iterator to DeclGroup.
Serialization for OwningDeclGroupRefs now works. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57272 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclGroup.cpp')
-rw-r--r--lib/AST/DeclGroup.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/AST/DeclGroup.cpp b/lib/AST/DeclGroup.cpp
index bd79fafc8f..5ddcd5954d 100644
--- a/lib/AST/DeclGroup.cpp
+++ b/lib/AST/DeclGroup.cpp
@@ -21,6 +21,7 @@
using namespace clang;
DeclGroup* DeclGroup::Create(ASTContext& C, unsigned numdecls, Decl** decls) {
+ assert (numdecls > 0);
unsigned size = sizeof(DeclGroup) + sizeof(Decl*) * numdecls;
unsigned alignment = llvm::AlignOf<DeclGroup>::Alignment;
void* mem = C.getAllocator().Allocate(size, alignment);
@@ -46,7 +47,7 @@ DeclGroup* DeclGroup::Create(llvm::Deserializer& D, ASTContext& C) {
return DG;
}
-DeclGroup::DeclGroup(unsigned numdecls, Decl** decls) {
+DeclGroup::DeclGroup(unsigned numdecls, Decl** decls) : NumDecls(numdecls) {
assert (numdecls > 0);
assert (decls);
memcpy(this+1, decls, numdecls * sizeof(*decls));
@@ -110,13 +111,15 @@ void DeclGroupOwningRef::Emit(llvm::Serializer& S) const {
}
}
-DeclGroupOwningRef DeclGroupOwningRef::ReadVal(llvm::Deserializer& D,
- ASTContext& C) {
- if (D.ReadBool()) {
- DeclGroupOwningRef DG(D.ReadOwnedPtr<Decl>(C));
- return DG;
+DeclGroupOwningRef& DeclGroupOwningRef::Read(llvm::Deserializer& Dezr,
+ ASTContext& C) {
+
+ if (!Dezr.ReadBool())
+ D = Dezr.ReadOwnedPtr<Decl>(C);
+ else {
+ uintptr_t x = reinterpret_cast<uintptr_t>(Dezr.ReadOwnedPtr<DeclGroup>(C));
+ D = reinterpret_cast<Decl*>(x | DeclGroupKind);
}
-
- DeclGroupOwningRef DG(D.ReadOwnedPtr<DeclGroup>(C));
- return DG;
+
+ return *this;
}