[cfe-commits] r39278 - in /cfe/cfe/trunk: AST/Sema.h AST/SemaDecl.cpp Parse/ParseDecl.cpp Sema/Sema.h Sema/SemaDecl.cpp include/clang/Parse/Action.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:42:23 PDT 2007
Author: sabre
Date: Wed Jul 11 11:42:23 2007
New Revision: 39278
URL: http://llvm.org/viewvc/llvm-project?rev=39278&view=rev
Log:
There is no need for the Action::TagType enum, use DeclSpec::TST instead.
Modified:
cfe/cfe/trunk/AST/Sema.h
cfe/cfe/trunk/AST/SemaDecl.cpp
cfe/cfe/trunk/Parse/ParseDecl.cpp
cfe/cfe/trunk/Sema/Sema.h
cfe/cfe/trunk/Sema/SemaDecl.cpp
cfe/cfe/trunk/include/clang/Parse/Action.h
Modified: cfe/cfe/trunk/AST/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Sema.h?rev=39278&r1=39277&r2=39278&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Sema.h (original)
+++ cfe/cfe/trunk/AST/Sema.h Wed Jul 11 11:42:23 2007
@@ -83,7 +83,7 @@
Decl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
Scope *S);
- virtual DeclTy *ParseTag(Scope *S, TagType Ty, bool isUse,
+ virtual DeclTy *ParseTag(Scope *S, unsigned TagType, bool isUse,
SourceLocation KWLoc, IdentifierInfo *Name,
SourceLocation NameLoc);
Modified: cfe/cfe/trunk/AST/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/SemaDecl.cpp?rev=39278&r1=39277&r2=39278&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/SemaDecl.cpp (original)
+++ cfe/cfe/trunk/AST/SemaDecl.cpp Wed Jul 11 11:42:23 2007
@@ -144,6 +144,7 @@
if (Decl *PrevDecl = LookupScopedDecl(II, Decl::IDNS_Ordinary)) {
// TODO: CHECK FOR CONFLICTS, multiple decls with same name in one scope.
+ assert(PrevDecl == 0 && "FIXME: Unimp!");
}
VarDecl *New = new VarDecl(PI.IdentLoc, II, static_cast<Type*>(PI.TypeInfo));
@@ -263,30 +264,24 @@
/// ParseStructUnionTag - This is invoked when we see 'struct foo' or
/// 'struct {'. In the former case, Name will be non-null. In the later case,
-/// Name will be null. isUnion indicates whether this is a union or struct tag.
-/// isUse indicates whether this is a use of a preexisting struct tag, or if it
-/// is a definition or declaration of a new one.
-Sema::DeclTy *Sema::ParseTag(Scope *S, TagType Ty, bool isUse,
+/// Name will be null. TagType indicates what kind of tag this is. isUse
+/// indicates whether this is a use of a preexisting struct tag, or if it is a
+/// definition or declaration of a new one.
+Sema::DeclTy *Sema::ParseTag(Scope *S, unsigned TagType, bool isUse,
SourceLocation KWLoc, IdentifierInfo *Name,
SourceLocation NameLoc) {
// If this is a use of an existing tag, it must have a name.
assert((isUse || Name != 0) && "Nameless record must have a name!");
Decl::Kind Kind;
- switch (Ty) {
+ switch (TagType) {
default: assert(0 && "Unknown tag type!");
- case TAG_STRUCT: Kind = Decl::Struct; break;
- case TAG_UNION: Kind = Decl::Union; break;
- case TAG_CLASS: Kind = Decl::Class; break;
- case TAG_ENUM: Kind = Decl::Enum; break;
+ case DeclSpec::TST_struct: Kind = Decl::Struct; break;
+ case DeclSpec::TST_union: Kind = Decl::Union; break;
+//case DeclSpec::TST_class: Kind = Decl::Class; break;
+ case DeclSpec::TST_enum: Kind = Decl::Enum; break;
}
- // If there is an identifier, use the location of the identifier as the
- // location of the decl, otherwise use the location of the struct/union
- // keyword.
- SourceLocation Loc = NameLoc.isValid() ? NameLoc : KWLoc;
-
-
// If this is a named struct, check to see if there was a previous forward
// declaration or definition.
if (Decl *PrevDecl = LookupScopedDecl(Name, Decl::IDNS_Tag)) {
@@ -310,6 +305,11 @@
// type.
}
+ // If there is an identifier, use the location of the identifier as the
+ // location of the decl, otherwise use the location of the struct/union
+ // keyword.
+ SourceLocation Loc = NameLoc.isValid() ? NameLoc : KWLoc;
+
// Otherwise, if this is the first time we've seen this tag, create the decl.
Decl *New;
if (Kind != Decl::Enum)
Modified: cfe/cfe/trunk/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/ParseDecl.cpp?rev=39278&r1=39277&r2=39278&view=diff
==============================================================================
--- cfe/cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseDecl.cpp Wed Jul 11 11:42:23 2007
@@ -431,6 +431,7 @@
Tok.getKind() == tok::kw_union) && "Not a struct/union specifier");
bool isUnion = Tok.getKind() == tok::kw_union;
SourceLocation StartLoc = ConsumeToken();
+ DeclSpec::TST TagType = isUnion ? DeclSpec::TST_union : DeclSpec::TST_struct;
// If attributes exist after tag, parse them.
if (Tok.getKind() == tok::kw___attribute)
@@ -463,11 +464,9 @@
// struct foo {..}; void bar() { struct foo x; } <- use of old foo.
//
bool isUse = Tok.getKind() != tok::l_brace && Tok.getKind() != tok::semi;
- DeclTy *TagDecl = Actions.ParseTag(CurScope,
- isUnion ? Action::TAG_UNION :
- Action::TAG_STRUCT, isUse,
- StartLoc, Name, NameLoc);
- // TODO: more with the tag decl.
+ DeclTy *TagDecl =
+ Actions.ParseTag(CurScope, TagType, isUse, StartLoc, Name, NameLoc);
+
if (Tok.getKind() == tok::l_brace) {
SourceLocation LBraceLoc = ConsumeBrace();
@@ -548,8 +547,7 @@
}
const char *PrevSpec = 0;
- if (DS.SetTypeSpecType(isUnion ? DeclSpec::TST_union : DeclSpec::TST_struct,
- StartLoc, PrevSpec))
+ if (DS.SetTypeSpecType(TagType, StartLoc, PrevSpec))
Diag(StartLoc, diag::err_invalid_decl_spec_combination, PrevSpec);
}
Modified: cfe/cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/Sema.h?rev=39278&r1=39277&r2=39278&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/Sema.h (original)
+++ cfe/cfe/trunk/Sema/Sema.h Wed Jul 11 11:42:23 2007
@@ -83,7 +83,7 @@
Decl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
Scope *S);
- virtual DeclTy *ParseTag(Scope *S, TagType Ty, bool isUse,
+ virtual DeclTy *ParseTag(Scope *S, unsigned TagType, bool isUse,
SourceLocation KWLoc, IdentifierInfo *Name,
SourceLocation NameLoc);
Modified: cfe/cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/SemaDecl.cpp?rev=39278&r1=39277&r2=39278&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaDecl.cpp Wed Jul 11 11:42:23 2007
@@ -144,6 +144,7 @@
if (Decl *PrevDecl = LookupScopedDecl(II, Decl::IDNS_Ordinary)) {
// TODO: CHECK FOR CONFLICTS, multiple decls with same name in one scope.
+ assert(PrevDecl == 0 && "FIXME: Unimp!");
}
VarDecl *New = new VarDecl(PI.IdentLoc, II, static_cast<Type*>(PI.TypeInfo));
@@ -263,30 +264,24 @@
/// ParseStructUnionTag - This is invoked when we see 'struct foo' or
/// 'struct {'. In the former case, Name will be non-null. In the later case,
-/// Name will be null. isUnion indicates whether this is a union or struct tag.
-/// isUse indicates whether this is a use of a preexisting struct tag, or if it
-/// is a definition or declaration of a new one.
-Sema::DeclTy *Sema::ParseTag(Scope *S, TagType Ty, bool isUse,
+/// Name will be null. TagType indicates what kind of tag this is. isUse
+/// indicates whether this is a use of a preexisting struct tag, or if it is a
+/// definition or declaration of a new one.
+Sema::DeclTy *Sema::ParseTag(Scope *S, unsigned TagType, bool isUse,
SourceLocation KWLoc, IdentifierInfo *Name,
SourceLocation NameLoc) {
// If this is a use of an existing tag, it must have a name.
assert((isUse || Name != 0) && "Nameless record must have a name!");
Decl::Kind Kind;
- switch (Ty) {
+ switch (TagType) {
default: assert(0 && "Unknown tag type!");
- case TAG_STRUCT: Kind = Decl::Struct; break;
- case TAG_UNION: Kind = Decl::Union; break;
- case TAG_CLASS: Kind = Decl::Class; break;
- case TAG_ENUM: Kind = Decl::Enum; break;
+ case DeclSpec::TST_struct: Kind = Decl::Struct; break;
+ case DeclSpec::TST_union: Kind = Decl::Union; break;
+//case DeclSpec::TST_class: Kind = Decl::Class; break;
+ case DeclSpec::TST_enum: Kind = Decl::Enum; break;
}
- // If there is an identifier, use the location of the identifier as the
- // location of the decl, otherwise use the location of the struct/union
- // keyword.
- SourceLocation Loc = NameLoc.isValid() ? NameLoc : KWLoc;
-
-
// If this is a named struct, check to see if there was a previous forward
// declaration or definition.
if (Decl *PrevDecl = LookupScopedDecl(Name, Decl::IDNS_Tag)) {
@@ -310,6 +305,11 @@
// type.
}
+ // If there is an identifier, use the location of the identifier as the
+ // location of the decl, otherwise use the location of the struct/union
+ // keyword.
+ SourceLocation Loc = NameLoc.isValid() ? NameLoc : KWLoc;
+
// Otherwise, if this is the first time we've seen this tag, create the decl.
Decl *New;
if (Kind != Decl::Enum)
Modified: cfe/cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Parse/Action.h?rev=39278&r1=39277&r2=39278&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/Action.h Wed Jul 11 11:42:23 2007
@@ -140,10 +140,11 @@
return 0;
}
- enum TagType { TAG_STRUCT, TAG_UNION, TAG_ENUM, TAG_CLASS };
- virtual DeclTy *ParseTag(Scope *S, TagType Ty, bool isUse,
+ virtual DeclTy *ParseTag(Scope *S, unsigned TagType, bool isUse,
SourceLocation KWLoc, IdentifierInfo *Name,
SourceLocation NameLoc) {
+ // TagType is an instance of DeclSpec::TST, indicating what kind of tag this
+ // is (struct/union/enum/class).
return 0;
}
More information about the cfe-commits
mailing list