aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-03-11 20:22:50 +0000
committerDouglas Gregor <dgregor@apple.com>2009-03-11 20:22:50 +0000
commit2d2e9cfdc1dbb6e4a22f8c0b1abcd30437e3795d (patch)
tree59a627bb27a9c540e557524e0dc81e0d37b735c5
parentceb77d909f80d4949ee6177094510413c391cddc (diff)
Eliminate CXXClassVarDecl. It doesn't add anything
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66696 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Driver/ASTConsumers.cpp5
-rw-r--r--include/clang/AST/DeclBase.h1
-rw-r--r--include/clang/AST/DeclCXX.h28
-rw-r--r--include/clang/AST/DeclNodes.def1
-rw-r--r--lib/AST/DeclCXX.cpp6
-rw-r--r--lib/AST/Expr.cpp2
-rw-r--r--lib/Sema/SemaDecl.cpp31
-rw-r--r--lib/Sema/SemaDeclCXX.cpp4
-rw-r--r--lib/Sema/SemaExpr.cpp2
9 files changed, 16 insertions, 64 deletions
diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp
index f04f9a3a39..9eba137918 100644
--- a/Driver/ASTConsumers.cpp
+++ b/Driver/ASTConsumers.cpp
@@ -904,11 +904,6 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
Out << "<implicit parameter> " << IPD->getNameAsString() << "\n";
break;
}
- case Decl::CXXClassVar: {
- CXXClassVarDecl* CVD = cast<CXXClassVarDecl>(*I);
- Out << "<static member var> " << CVD->getNameAsString() << "\n";
- break;
- }
case Decl::ParmVar: {
ParmVarDecl* PVD = cast<ParmVarDecl>(*I);
Out << "<parameter> " << PVD->getNameAsString() << "\n";
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index da9054f8d6..183acb341b 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -212,7 +212,6 @@ public:
case Typedef:
case EnumConstant:
case Var:
- case CXXClassVar:
case ImplicitParam:
case ParmVar:
case OriginalParmVar:
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index 875010bd2f..52ed01d04b 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -759,34 +759,6 @@ public:
static CXXConversionDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
};
-/// CXXClassVarDecl - Represents a static data member of a struct/union/class.
-class CXXClassVarDecl : public VarDecl {
-
- CXXClassVarDecl(CXXRecordDecl *RD, SourceLocation L,
- IdentifierInfo *Id, QualType T)
- : VarDecl(CXXClassVar, RD, L, Id, T, None) {}
-public:
- static CXXClassVarDecl *Create(ASTContext &C, CXXRecordDecl *RD,
- SourceLocation L,IdentifierInfo *Id,
- QualType T);
-
- // Implement isa/cast/dyncast/etc.
- static bool classof(const Decl *D) { return D->getKind() == CXXClassVar; }
- static bool classof(const CXXClassVarDecl *D) { return true; }
-
-protected:
- /// EmitImpl - Serialize this CXXClassVarDecl. Called by Decl::Emit.
- // FIXME: Implement this.
- //virtual void EmitImpl(llvm::Serializer& S) const;
-
- /// CreateImpl - Deserialize a CXXClassVarDecl. Called by Decl::Create.
- // FIXME: Implement this.
- static CXXClassVarDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
-
- friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
-};
-
-
/// CXXClassMemberWrapper - A wrapper class for C++ class member decls.
/// Common functions like set/getAccess are included here to avoid bloating
/// the interface of non-C++ specific decl classes, like NamedDecl.
diff --git a/include/clang/AST/DeclNodes.def b/include/clang/AST/DeclNodes.def
index ec0461c638..43bf7f1023 100644
--- a/include/clang/AST/DeclNodes.def
+++ b/include/clang/AST/DeclNodes.def
@@ -98,7 +98,6 @@ ABSTRACT_DECL(Named, Decl)
DECL(ObjCAtDefsField, FieldDecl)
DECL(Var, ValueDecl)
DECL(ImplicitParam, VarDecl)
- DECL(CXXClassVar, VarDecl)
DECL(ParmVar, VarDecl)
DECL(OriginalParmVar, ParmVarDecl)
DECL(NonTypeTemplateParm, VarDecl)
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index 45a3372ada..4776ce5877 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -316,12 +316,6 @@ CXXConversionDecl::Create(ASTContext &C, CXXRecordDecl *RD,
return new (C) CXXConversionDecl(RD, L, N, T, isInline, isExplicit);
}
-CXXClassVarDecl *CXXClassVarDecl::Create(ASTContext &C, CXXRecordDecl *RD,
- SourceLocation L, IdentifierInfo *Id,
- QualType T) {
- return new (C) CXXClassVarDecl(RD, L, Id, T);
-}
-
OverloadedFunctionDecl *
OverloadedFunctionDecl::Create(ASTContext &C, DeclContext *DC,
DeclarationName N) {
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 38bcc9bf31..3d2132a43f 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -511,7 +511,7 @@ Expr::isLvalueResult Expr::isLvalue(ASTContext &Ctx) const {
return LV_Valid;
// -- If E2 is a static data member [...] then E1.E2 is an lvalue.
- if (isa<CXXClassVarDecl>(Member))
+ if (isa<VarDecl>(Member) && Member->getDeclContext()->isRecord())
return LV_Valid;
// -- If E2 is a non-static data member [...]. If E1 is an
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 8c82c5cad3..f77d1d8845 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1580,27 +1580,20 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
return 0;
}
- if (DC->isRecord()) {
- // This is a static data member for a C++ class.
- NewVD = CXXClassVarDecl::Create(Context, cast<CXXRecordDecl>(DC),
- D.getIdentifierLoc(), II,
- R);
- } else {
- bool ThreadSpecified = D.getDeclSpec().isThreadSpecified();
- if (S->getFnParent() == 0) {
- // C99 6.9p2: The storage-class specifiers auto and register shall not
- // appear in the declaration specifiers in an external declaration.
- if (SC == VarDecl::Auto || SC == VarDecl::Register) {
- Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_fscope);
- InvalidDecl = true;
- }
+ bool ThreadSpecified = D.getDeclSpec().isThreadSpecified();
+ if (!DC->isRecord() && S->getFnParent() == 0) {
+ // C99 6.9p2: The storage-class specifiers auto and register shall not
+ // appear in the declaration specifiers in an external declaration.
+ if (SC == VarDecl::Auto || SC == VarDecl::Register) {
+ Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_fscope);
+ InvalidDecl = true;
}
- NewVD = VarDecl::Create(Context, DC, D.getIdentifierLoc(),
- II, R, SC,
- // FIXME: Move to DeclGroup...
- D.getDeclSpec().getSourceRange().getBegin());
- NewVD->setThreadSpecified(ThreadSpecified);
}
+ NewVD = VarDecl::Create(Context, DC, D.getIdentifierLoc(),
+ II, R, SC,
+ // FIXME: Move to DeclGroup...
+ D.getDeclSpec().getSourceRange().getBegin());
+ NewVD->setThreadSpecified(ThreadSpecified);
NewVD->setNextDeclarator(LastDeclarator);
// Handle attributes prior to checking for duplicates in MergeVarDecl
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 6df1600c69..fa6fcc8c35 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -560,7 +560,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
if (BitWidth) {
if (Member->isInvalidDecl()) {
// don't emit another diagnostic.
- } else if (isa<CXXClassVarDecl>(Member)) {
+ } else if (isa<VarDecl>(Member)) {
// C++ 9.6p3: A bit-field shall not be a static member.
// "static member 'A' cannot be a bit-field"
Diag(Loc, diag::err_static_not_bitfield)
@@ -621,7 +621,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
// C++ 9.2p4: A member-declarator can contain a constant-initializer only
// if it declares a static member of const integral or const enumeration
// type.
- if (CXXClassVarDecl *CVD = dyn_cast<CXXClassVarDecl>(Member)) {
+ if (VarDecl *CVD = dyn_cast<VarDecl>(Member)) {
// ...static member of...
CVD->setInit(Init);
// ...const integral or const enumeration type.
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index e5a917474f..58cd3909c2 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1744,7 +1744,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
return Owned(new (Context) MemberExpr(BaseExpr, OpKind == tok::arrow, FD,
MemberLoc, MemberType));
- } else if (CXXClassVarDecl *Var = dyn_cast<CXXClassVarDecl>(MemberDecl))
+ } else if (VarDecl *Var = dyn_cast<VarDecl>(MemberDecl))
return Owned(new (Context) MemberExpr(BaseExpr, OpKind == tok::arrow,
Var, MemberLoc,
Var->getType().getNonReferenceType()));