summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/CFG.cpp7
-rw-r--r--clang/lib/AST/DeclGroup.cpp51
-rw-r--r--clang/lib/AST/Stmt.cpp1
-rw-r--r--clang/lib/AST/StmtSerialization.cpp3
-rw-r--r--clang/lib/Sema/SemaStmt.cpp4
5 files changed, 7 insertions, 59 deletions
diff --git a/clang/lib/AST/CFG.cpp b/clang/lib/AST/CFG.cpp
index 2ea83882876..e08a00b8a5e 100644
--- a/clang/lib/AST/CFG.cpp
+++ b/clang/lib/AST/CFG.cpp
@@ -379,11 +379,8 @@ CFGBlock* CFGBuilder::WalkAST(Stmt* Terminator, bool AlwaysAddStmt = false) {
? 8 : llvm::AlignOf<DeclStmt>::Alignment;
// Allocate the DeclStmt using the BumpPtrAllocator. It will
- // get automatically freed with the CFG. Note that even though
- // we are using a DeclGroupOwningRef that wraps a singe Decl*,
- // that Decl* will not get deallocated because the destroy method
- // of DG is never called.
- DeclGroupOwningRef DG(*I);
+ // get automatically freed with the CFG.
+ DeclGroupRef DG(*I);
Decl* D = *I;
void* Mem = cfg->getAllocator().Allocate(sizeof(DeclStmt), A);
diff --git a/clang/lib/AST/DeclGroup.cpp b/clang/lib/AST/DeclGroup.cpp
index e7f84e1f46c..35cb6d3bc61 100644
--- a/clang/lib/AST/DeclGroup.cpp
+++ b/clang/lib/AST/DeclGroup.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file defines the DeclGroup, DeclGroupRef, and OwningDeclGroup classes.
+// This file defines the DeclGroup and DeclGroupRef classes.
//
//===----------------------------------------------------------------------===//
@@ -36,7 +36,7 @@ void DeclGroup::Emit(llvm::Serializer& S) const {
}
/// Read - Deserialize a DeclGroup from Bitcode.
-DeclGroup* DeclGroup::Create(llvm::Deserializer& D, ASTContext& C) {
+DeclGroup* DeclGroup::Read(llvm::Deserializer& D, ASTContext& C) {
unsigned NumDecls = (unsigned) D.ReadInt();
unsigned size = sizeof(DeclGroup) + sizeof(Decl*) * NumDecls;
unsigned alignment = llvm::AlignOf<DeclGroup>::Alignment;
@@ -54,32 +54,10 @@ DeclGroup::DeclGroup(unsigned numdecls, Decl** decls) : NumDecls(numdecls) {
}
void DeclGroup::Destroy(ASTContext& C) {
- Decl** Decls = (Decl**) (this + 1);
-
- for (unsigned i = 0; i < NumDecls; ++i)
- Decls[i]->Destroy(C);
-
this->~DeclGroup();
C.Deallocate((void*) this);
}
-DeclGroupOwningRef::~DeclGroupOwningRef() {
- assert (D == 0 && "Destroy method not called.");
-}
-
-void DeclGroupOwningRef::Destroy(ASTContext& C) {
- if (!D)
- return;
-
- if (getKind() == DeclKind)
- D->Destroy(C);
- else
- reinterpret_cast<DeclGroup*>(reinterpret_cast<uintptr_t>(D) &
- ~Mask)->Destroy(C);
-
- D = 0;
-}
-
void DeclGroupRef::Emit(llvm::Serializer& S) const {
if (getKind() == DeclKind) {
S.EmitBool(false);
@@ -98,28 +76,3 @@ DeclGroupRef DeclGroupRef::ReadVal(llvm::Deserializer& D) {
return DeclGroupRef(D.ReadPtr<DeclGroup>());
}
-
-void DeclGroupOwningRef::Emit(llvm::Serializer& S) const {
- if (getKind() == DeclKind) {
- S.EmitBool(false);
- S.EmitOwnedPtr(D);
- }
- else {
- S.EmitBool(true);
- S.EmitOwnedPtr(reinterpret_cast<DeclGroup*>(reinterpret_cast<uintptr_t>(D)
- & ~Mask));
- }
-}
-
-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);
- }
-
- return *this;
-}
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp
index 49c8c80509a..b85a67e689f 100644
--- a/clang/lib/AST/Stmt.cpp
+++ b/clang/lib/AST/Stmt.cpp
@@ -58,7 +58,6 @@ void Stmt::Destroy(ASTContext& C) {
}
void DeclStmt::Destroy(ASTContext& C) {
- DG.Destroy(C);
this->~DeclStmt();
C.Deallocate((void *)this);
}
diff --git a/clang/lib/AST/StmtSerialization.cpp b/clang/lib/AST/StmtSerialization.cpp
index 5a6e49cb3e3..22ce8183fd6 100644
--- a/clang/lib/AST/StmtSerialization.cpp
+++ b/clang/lib/AST/StmtSerialization.cpp
@@ -550,8 +550,7 @@ void DeclStmt::EmitImpl(Serializer& S) const {
DeclStmt* DeclStmt::CreateImpl(Deserializer& D, ASTContext& C) {
SourceLocation StartLoc = SourceLocation::ReadVal(D);
SourceLocation EndLoc = SourceLocation::ReadVal(D);
- DeclGroupOwningRef DG;
- return new DeclStmt(DG.Read(D, C), StartLoc, EndLoc);
+ return new DeclStmt(DeclGroupRef::ReadVal(D), StartLoc, EndLoc);
}
void DeclRefExpr::EmitImpl(Serializer& S) const {
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index dd505f69673..bfa1c5e6d05 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -58,11 +58,11 @@ Sema::OwningStmtResult Sema::ActOnDeclStmt(DeclTy *decl,
assert (!decls.empty());
if (decls.size() == 1) {
- DeclGroupOwningRef DG(*decls.begin());
+ DeclGroupRef DG(*decls.begin());
return Owned(new (Context) DeclStmt(DG, StartLoc, EndLoc));
}
else {
- DeclGroupOwningRef DG(DeclGroup::Create(Context, decls.size(), &decls[0]));
+ DeclGroupRef DG(DeclGroup::Create(Context, decls.size(), &decls[0]));
return Owned(new (Context) DeclStmt(DG, StartLoc, EndLoc));
}
}
OpenPOWER on IntegriCloud