From: Steve Naroff Date: Fri, 14 Sep 2007 02:20:46 +0000 (+0000) Subject: Now that the dust has settled on the Decl refactoring, I noticed FieldDecl didn't... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f38661ec6e803b553bddae17325ac59809b45d83;p=clang Now that the dust has settled on the Decl refactoring, I noticed FieldDecl didn't need NextDeclarator. As a result, I'm removing it. Removing both slots (NextDeclarator/Next) end up reducing the size of fields/ivars by 40%. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41948 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp index da07fbd61b..87f68fed24 100644 --- a/AST/ASTContext.cpp +++ b/AST/ASTContext.cpp @@ -791,7 +791,7 @@ QualType ASTContext::getCFConstantStringType() { FieldDecl *FieldDecls[4]; for (unsigned i = 0; i < 4; ++i) - FieldDecls[i] = new FieldDecl(SourceLocation(), 0, FieldTypes[i], 0); + FieldDecls[i] = new FieldDecl(SourceLocation(), 0, FieldTypes[i]); CFConstantStringTypeDecl->defineBody(FieldDecls, 4); } diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index 1a808f87b4..9300b9cd81 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -1081,9 +1081,9 @@ Sema::DeclTy *Sema::ParseField(Scope *S, DeclTy *TagDecl, FieldDecl *NewFD; if (isa(static_cast(TagDecl))) - NewFD = new FieldDecl(Loc, II, T, 0); + NewFD = new FieldDecl(Loc, II, T); else if (isa(static_cast(TagDecl))) - NewFD = new ObjcIvarDecl(Loc, II, T, 0); + NewFD = new ObjcIvarDecl(Loc, II, T); else assert(0 && "Sema::ParseField(): Unknown TagDecl"); diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index a3096a4233..2431597e82 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -323,32 +323,19 @@ class FieldDecl : public Decl { /// Loc - The location that this decl. SourceLocation Loc; - - /// NextDeclarator - If this decl was part of a multi-declarator declaration, - /// such as "int X, Y, *Z;" this indicates Decl for the next declarator. - FieldDecl *NextDeclarator; - + QualType DeclType; public: - FieldDecl(SourceLocation L, IdentifierInfo *Id, QualType T, FieldDecl *PrevD) - : Decl(Field), Identifier(Id), Loc(L), NextDeclarator(PrevD), - DeclType(T) {} - FieldDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T, - FieldDecl *PrevD) : Decl(DK), Identifier(Id), Loc(L), - NextDeclarator(PrevD), DeclType(T) {} + FieldDecl(SourceLocation L, IdentifierInfo *Id, QualType T) + : Decl(Field), Identifier(Id), Loc(L), DeclType(T) {} + FieldDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T) + : Decl(DK), Identifier(Id), Loc(L), DeclType(T) {} IdentifierInfo *getIdentifier() const { return Identifier; } SourceLocation getLocation() const { return Loc; } void setLocation(SourceLocation L) { Loc = L; } const char *getName() const; - /// getNextDeclarator - If this decl was part of a multi-declarator - /// declaration, such as "int X, Y, *Z;" this returns the decl for the next - /// declarator. Otherwise it returns null. - FieldDecl *getNextDeclarator() { return NextDeclarator; } - const FieldDecl *getNextDeclarator() const { return NextDeclarator; } - void setNextDeclarator(FieldDecl *N) { NextDeclarator = N; } - QualType getType() const { return DeclType; } QualType getCanonicalType() const { return DeclType.getCanonicalType(); } @@ -580,8 +567,8 @@ public: class ObjcIvarDecl : public FieldDecl { public: - ObjcIvarDecl(SourceLocation L, IdentifierInfo *Id, QualType T, - FieldDecl *PrevDecl) : FieldDecl(ObjcIvar, L, Id, T, PrevDecl) {} + ObjcIvarDecl(SourceLocation L, IdentifierInfo *Id, QualType T) + : FieldDecl(ObjcIvar, L, Id, T) {} enum AccessControl { None, Private, Protected, Public, Package