aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-09-05 01:34:33 +0000
committerTed Kremenek <kremenek@apple.com>2008-09-05 01:34:33 +0000
commitdf042e6c2bf06b2d9ed53c52469599ac1bd93a3f (patch)
tree2aa6d45304f3160de3954f85907c1ea047ccfba4 /lib
parent3a9a3e112ac02f8a261293cbe605db2e5d8732d3 (diff)
Remove "NextDecl" from RecordDecl. This change touches many files that where RecordDecl or CXXRecordDecl was constructed, always with an argument of 'NULL' for the previous declaration.
The motivation behind this change is that chaining the RecordDecls is simply unnecessary. Once we create multiple RecordDecls for the same struct/union/class, clients that care about all the declarations of the same struct can build a back map by seeing which Decls refer to the same RecordType. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55821 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/ASTContext.cpp4
-rw-r--r--lib/AST/Decl.cpp43
-rw-r--r--lib/AST/DeclCXX.cpp5
-rw-r--r--lib/AST/DeclSerialization.cpp4
-rw-r--r--lib/CodeGen/CGObjCMac.cpp2
-rw-r--r--lib/Sema/Sema.cpp4
-rw-r--r--lib/Sema/SemaDecl.cpp6
7 files changed, 16 insertions, 52 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 2264bca0f9..5a6aa1ae31 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1348,7 +1348,7 @@ QualType ASTContext::getCFConstantStringType() {
if (!CFConstantStringTypeDecl) {
CFConstantStringTypeDecl =
RecordDecl::Create(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
- &Idents.get("NSConstantString"), 0);
+ &Idents.get("NSConstantString"));
QualType FieldTypes[4];
// const int *isa;
@@ -1390,7 +1390,7 @@ QualType ASTContext::getObjCFastEnumerationStateType()
ObjCFastEnumerationStateTypeDecl =
RecordDecl::Create(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
- &Idents.get("__objcFastEnumerationState"), 0);
+ &Idents.get("__objcFastEnumerationState"));
ObjCFastEnumerationStateTypeDecl->defineBody(FieldDecls, 4);
}
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 04cec6f66b..eb9d0efdb4 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -204,36 +204,18 @@ unsigned FunctionDecl::getMinRequiredArguments() const {
//===----------------------------------------------------------------------===//
RecordDecl::RecordDecl(Kind DK, DeclContext *DC, SourceLocation L,
- IdentifierInfo *Id, RecordDecl *PrevDecl)
-: TagDecl(DK, DC, L, Id, 0), NextDecl(0) {
+ IdentifierInfo *Id)
+: TagDecl(DK, DC, L, Id, 0) {
HasFlexibleArrayMember = false;
assert(classof(static_cast<Decl*>(this)) && "Invalid Kind!");
Members = 0;
- NumMembers = -1;
-
- // Hook up the RecordDecl chain.
- if (PrevDecl) {
- RecordDecl* Tmp = PrevDecl->NextDecl;
- // 'Tmp' might be non-NULL if it is the RecordDecl that provides the
- // definition of the struct/union. By construction, the last RecordDecl
- // in the chain is the 'defining' RecordDecl.
- if (Tmp) {
- assert (Tmp->NextDecl == 0);
- assert (Tmp->isDefinition()
- && "Previous RecordDecl has a NextDecl that is "
- "not the 'defining' RecordDecl");
-
- NextDecl = Tmp;
- }
-
- PrevDecl->NextDecl = this;
- }
+ NumMembers = -1;
}
RecordDecl *RecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
- SourceLocation L, IdentifierInfo *Id,
- RecordDecl *PrevDecl) {
+ SourceLocation L, IdentifierInfo *Id) {
+
void *Mem = C.getAllocator().Allocate<RecordDecl>();
Kind DK;
switch (TK) {
@@ -243,7 +225,7 @@ RecordDecl *RecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
case TK_union: DK = Union; break;
case TK_class: DK = Class; break;
}
- return new (Mem) RecordDecl(DK, DC, L, Id, PrevDecl);
+ return new (Mem) RecordDecl(DK, DC, L, Id);
}
RecordDecl::~RecordDecl() {
@@ -281,16 +263,3 @@ FieldDecl *RecordDecl::getMember(IdentifierInfo *II) {
return Members[i];
return 0;
}
-
-/// getDefinitionDecl - Returns the RecordDecl for the struct/union that
-/// represents the actual definition (i.e., not a forward declaration).
-/// This method returns NULL if no such RecordDecl exists.
-const RecordDecl* RecordDecl::getDefinitionDecl() const {
- const RecordDecl* R = this;
-
- for (RecordDecl* N = R->NextDecl; N; N = R->NextDecl)
- R = N;
-
- return R->Members ? R : 0;
-}
-
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index 2fe69fced5..0cce7db1d6 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -27,8 +27,7 @@ CXXFieldDecl *CXXFieldDecl::Create(ASTContext &C, CXXRecordDecl *RD,
}
CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
- SourceLocation L, IdentifierInfo *Id,
- CXXRecordDecl *PrevDecl) {
+ SourceLocation L, IdentifierInfo *Id) {
Kind DK;
switch (TK) {
default: assert(0 && "Invalid TagKind!");
@@ -38,7 +37,7 @@ CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
case TK_class: DK = CXXClass; break;
}
void *Mem = C.getAllocator().Allocate<CXXRecordDecl>();
- return new (Mem) CXXRecordDecl(DK, DC, L, Id, PrevDecl);
+ return new (Mem) CXXRecordDecl(DK, DC, L, Id);
}
CXXMethodDecl *
diff --git a/lib/AST/DeclSerialization.cpp b/lib/AST/DeclSerialization.cpp
index 82a8fcd0f6..3f36e3ac89 100644
--- a/lib/AST/DeclSerialization.cpp
+++ b/lib/AST/DeclSerialization.cpp
@@ -449,7 +449,6 @@ void RecordDecl::EmitImpl(Serializer& S) const {
ScopedDecl::EmitInRec(S);
S.EmitBool(isDefinition());
S.EmitBool(hasFlexibleArrayMember());
- S.EmitPtr(NextDecl);
S.EmitSInt(getNumMembers());
if (getNumMembers() > 0) {
assert (Members);
@@ -463,12 +462,11 @@ RecordDecl* RecordDecl::CreateImpl(Decl::Kind DK, Deserializer& D,
ASTContext& C) {
void *Mem = C.getAllocator().Allocate<RecordDecl>();
- RecordDecl* decl = new (Mem) RecordDecl(DK, 0, SourceLocation(), NULL, NULL);
+ RecordDecl* decl = new (Mem) RecordDecl(DK, 0, SourceLocation(), NULL);
decl->ScopedDecl::ReadInRec(D, C);
decl->setDefinition(D.ReadBool());
decl->setHasFlexibleArrayMember(D.ReadBool());
- D.ReadPtr(decl->NextDecl); // Allow backpatching.
decl->NumMembers = D.ReadSInt();
if (decl->getNumMembers() > 0) {
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 9638bc1430..a535ea254e 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -1866,7 +1866,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
// FIXME: Merge with rewriter code?
RecordDecl *RD = RecordDecl::Create(Ctx, TagDecl::TK_struct, 0,
SourceLocation(),
- &Ctx.Idents.get("_objc_super"), 0);
+ &Ctx.Idents.get("_objc_super"));
FieldDecl *FieldDecls[2];
FieldDecls[0] = FieldDecl::Create(Ctx, SourceLocation(), 0,
Ctx.getObjCIdType());
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index b288c62787..9092f83f0a 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -32,11 +32,11 @@ static inline RecordDecl *CreateStructDecl(ASTContext &C, const char *Name)
if (C.getLangOptions().CPlusPlus)
return CXXRecordDecl::Create(C, TagDecl::TK_struct,
C.getTranslationUnitDecl(),
- SourceLocation(), &C.Idents.get(Name), 0);
+ SourceLocation(), &C.Idents.get(Name));
else
return RecordDecl::Create(C, TagDecl::TK_struct,
C.getTranslationUnitDecl(),
- SourceLocation(), &C.Idents.get(Name), 0);
+ SourceLocation(), &C.Idents.get(Name));
}
void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index b45611ca59..53327e497e 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1765,14 +1765,12 @@ Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagType, TagKind TK,
// We use 'dyn_cast' instead of 'cast' because PrevDecl might not
// be a CXXRecordDecl* if we had a redefinition error. In this case,
// the dyn_cast will return a NULL pointer.
- New = CXXRecordDecl::Create(Context, Kind, CurContext, Loc, Name,
- dyn_cast_or_null<CXXRecordDecl>(PrevDecl));
+ New = CXXRecordDecl::Create(Context, Kind, CurContext, Loc, Name);
else
// We use 'dyn_cast' instead of 'cast' because PrevDecl might not
// be a RecordDecl* if we had a redefinition error. In this case,
// the dyn_cast will return a NULL pointer.
- New = RecordDecl::Create(Context, Kind, CurContext, Loc, Name,
- dyn_cast_or_null<RecordDecl>(PrevDecl));
+ New = RecordDecl::Create(Context, Kind, CurContext, Loc, Name);
}
// If this has an identifier, add it to the scope stack.