[cfe-commits] r77658 - in /cfe/trunk: include/clang/Parse/Action.h lib/Frontend/PrintParserCallbacks.cpp lib/Parse/ParseDecl.cpp lib/Parse/ParseDeclCXX.cpp lib/Sema/Sema.h lib/Sema/SemaDecl.cpp lib/Sema/SemaTemplate.cpp
John McCall
rjmccall at apple.com
Thu Jul 30 19:45:11 PDT 2009
Author: rjmccall
Date: Thu Jul 30 21:45:11 2009
New Revision: 77658
URL: http://llvm.org/viewvc/llvm-project?rev=77658&view=rev
Log:
Rename Action::TagKind to Action::TagUseKind, which removes both a misnomer
and a name collision.
Modified:
cfe/trunk/include/clang/Parse/Action.h
cfe/trunk/lib/Frontend/PrintParserCallbacks.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=77658&r1=77657&r2=77658&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Thu Jul 30 21:45:11 2009
@@ -410,10 +410,10 @@
return TypeResult();
}
- enum TagKind {
- TK_Reference, // Reference to a tag: 'struct foo *X;'
- TK_Declaration, // Fwd decl of a tag: 'struct foo;'
- TK_Definition // Definition of a tag: 'struct foo { int X; } Y;'
+ enum TagUseKind {
+ TUK_Reference, // Reference to a tag: 'struct foo *X;'
+ TUK_Declaration, // Fwd decl of a tag: 'struct foo;'
+ TUK_Definition // Definition of a tag: 'struct foo { int X; } Y;'
};
/// \brief The parser has encountered a tag (e.g., "class X") that should be
@@ -424,9 +424,10 @@
/// \param TagSpec an instance of DeclSpec::TST, indicating what kind of tag
/// this is (struct/union/enum/class).
///
- /// \param TK the kind of tag we have encountered, which can be a reference
- /// to a (possibly pre-existing) tag, a declaration of that tag, or the
- /// beginning of a definition of that tag.
+ /// \param TUK how the tag we have encountered is being used, which
+ /// can be a reference to a (possibly pre-existing) tag, a
+ /// declaration of that tag, or the beginning of a definition of
+ /// that tag.
///
/// \param KWLoc the location of the "struct", "class", "union", or "enum"
/// keyword.
@@ -456,7 +457,7 @@
/// by the action module.
///
/// \returns the declaration to which this tag refers.
- virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
+ virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
SourceLocation KWLoc, const CXXScopeSpec &SS,
IdentifierInfo *Name, SourceLocation NameLoc,
AttributeList *Attr, AccessSpecifier AS,
@@ -1478,7 +1479,7 @@
/// \param TagSpec whether this declares a class, struct, or union
/// (template)
///
- /// \param TK whether this is a declaration or a definition
+ /// \param TUK whether this is a declaration or a definition
///
/// \param KWLoc the location of the 'class', 'struct', or 'union'
/// keyword.
@@ -1498,7 +1499,7 @@
/// parameter lists (such as a missing \c template<> prior to a
/// specialization); the parser does not check this condition.
virtual DeclResult
- ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagKind TK,
+ ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK,
SourceLocation KWLoc,
const CXXScopeSpec &SS,
TemplateTy Template,
Modified: cfe/trunk/lib/Frontend/PrintParserCallbacks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintParserCallbacks.cpp?rev=77658&r1=77657&r2=77658&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PrintParserCallbacks.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintParserCallbacks.cpp Thu Jul 30 21:45:11 2009
@@ -193,7 +193,7 @@
return TypeResult();
}
- virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagType, TagKind TK,
+ virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagType, TagUseKind TUK,
SourceLocation KWLoc, const CXXScopeSpec &SS,
IdentifierInfo *Name, SourceLocation NameLoc,
AttributeList *Attr, AccessSpecifier AS,
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=77658&r1=77657&r2=77658&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Jul 30 21:45:11 2009
@@ -1577,15 +1577,15 @@
// enum foo {..}; void bar() { enum foo; } <- new foo in bar.
// enum foo {..}; void bar() { enum foo x; } <- use of old foo.
//
- Action::TagKind TK;
+ Action::TagUseKind TUK;
if (Tok.is(tok::l_brace))
- TK = Action::TK_Definition;
+ TUK = Action::TUK_Definition;
else if (Tok.is(tok::semi))
- TK = Action::TK_Declaration;
+ TUK = Action::TUK_Declaration;
else
- TK = Action::TK_Reference;
+ TUK = Action::TUK_Reference;
bool Owned = false;
- DeclPtrTy TagDecl = Actions.ActOnTag(CurScope, DeclSpec::TST_enum, TK,
+ DeclPtrTy TagDecl = Actions.ActOnTag(CurScope, DeclSpec::TST_enum, TUK,
StartLoc, SS, Name, NameLoc, Attr, AS,
Action::MultiTemplateParamsArg(Actions),
Owned);
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=77658&r1=77657&r2=77658&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Thu Jul 30 21:45:11 2009
@@ -570,15 +570,15 @@
// this is a forward declaration. If we have 'struct foo {...' or
// 'struct foo :...' then this is a definition. Otherwise we have
// something like 'struct foo xyz', a reference.
- Action::TagKind TK;
+ Action::TagUseKind TUK;
if (Tok.is(tok::l_brace) || (getLang().CPlusPlus && Tok.is(tok::colon)))
- TK = Action::TK_Definition;
+ TUK = Action::TUK_Definition;
else if (Tok.is(tok::semi) && !DS.isFriendSpecified())
- TK = Action::TK_Declaration;
+ TUK = Action::TUK_Declaration;
else
- TK = Action::TK_Reference;
+ TUK = Action::TUK_Reference;
- if (!Name && !TemplateId && TK != Action::TK_Definition) {
+ if (!Name && !TemplateId && TUK != Action::TUK_Definition) {
// We have a declaration or reference to an anonymous class.
Diag(StartLoc, diag::err_anon_type_definition)
<< DeclSpec::getSpecifierName(TagType);
@@ -595,11 +595,11 @@
Action::DeclResult TagOrTempResult;
TemplateParameterLists *TemplateParams = TemplateInfo.TemplateParams;
- // FIXME: When TK == TK_Reference and we have a template-id, we need
+ // FIXME: When TUK == TUK_Reference and we have a template-id, we need
// to turn that template-id into a type.
bool Owned = false;
- if (TemplateId && TK != Action::TK_Reference) {
+ if (TemplateId && TUK != Action::TUK_Reference) {
// Explicit specialization, class template partial specialization,
// or explicit instantiation.
ASTTemplateArgsPtr TemplateArgsPtr(Actions,
@@ -607,7 +607,7 @@
TemplateId->getTemplateArgIsType(),
TemplateId->NumArgs);
if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
- TK == Action::TK_Declaration) {
+ TUK == Action::TUK_Declaration) {
// This is an explicit instantiation of a class template.
TagOrTempResult
= Actions.ActOnExplicitInstantiation(CurScope,
@@ -636,7 +636,7 @@
// but it actually has a definition. Most likely, this was
// meant to be an explicit specialization, but the user forgot
// the '<>' after 'template'.
- assert(TK == Action::TK_Definition && "Expected a definition here");
+ assert(TUK == Action::TUK_Definition && "Expected a definition here");
SourceLocation LAngleLoc
= PP.getLocForEndOfToken(TemplateInfo.TemplateLoc);
@@ -659,7 +659,7 @@
// Build the class template specialization.
TagOrTempResult
- = Actions.ActOnClassTemplateSpecialization(CurScope, TagType, TK,
+ = Actions.ActOnClassTemplateSpecialization(CurScope, TagType, TUK,
StartLoc, SS,
TemplateTy::make(TemplateId->Template),
TemplateId->TemplateNameLoc,
@@ -674,7 +674,7 @@
}
TemplateId->Destroy();
} else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
- TK == Action::TK_Declaration) {
+ TUK == Action::TUK_Declaration) {
// Explicit instantiation of a member of a class template
// specialization, e.g.,
//
@@ -687,12 +687,12 @@
NameLoc, Attr);
} else {
if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
- TK == Action::TK_Definition) {
+ TUK == Action::TUK_Definition) {
// FIXME: Diagnose this particular error.
}
// Declaration or definition of a class type
- TagOrTempResult = Actions.ActOnTag(CurScope, TagType, TK, StartLoc, SS,
+ TagOrTempResult = Actions.ActOnTag(CurScope, TagType, TUK, StartLoc, SS,
Name, NameLoc, Attr, AS,
Action::MultiTemplateParamsArg(Actions,
TemplateParams? &(*TemplateParams)[0] : 0,
@@ -710,7 +710,7 @@
ParseCXXMemberSpecification(StartLoc, TagType, TagOrTempResult.get());
else
ParseStructUnionBody(StartLoc, TagType, TagOrTempResult.get());
- else if (TK == Action::TK_Definition) {
+ else if (TUK == Action::TUK_Definition) {
// FIXME: Complain that we have a base-specifier list but no
// definition.
Diag(Tok, diag::err_expected_lbrace);
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=77658&r1=77657&r2=77658&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Thu Jul 30 21:45:11 2009
@@ -542,7 +542,7 @@
SourceLocation NewTagLoc,
const IdentifierInfo &Name);
- virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
+ virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
SourceLocation KWLoc, const CXXScopeSpec &SS,
IdentifierInfo *Name, SourceLocation NameLoc,
AttributeList *Attr, AccessSpecifier AS,
@@ -2129,7 +2129,7 @@
TemplateParameterList **ParamLists,
unsigned NumParamLists);
- DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagKind TK,
+ DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
SourceLocation KWLoc, const CXXScopeSpec &SS,
IdentifierInfo *Name, SourceLocation NameLoc,
AttributeList *Attr,
@@ -2182,7 +2182,7 @@
bool &MirrorsPrimaryTemplate);
virtual DeclResult
- ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagKind TK,
+ ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK,
SourceLocation KWLoc,
const CXXScopeSpec &SS,
TemplateTy Template,
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=77658&r1=77657&r2=77658&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jul 30 21:45:11 2009
@@ -3851,16 +3851,16 @@
/// ActOnTag - 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.
-/// TagSpec indicates what kind of tag this is. TK indicates whether this is a
+/// TagSpec indicates what kind of tag this is. TUK indicates whether this is a
/// reference/declaration/definition of a tag.
-Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
+Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
SourceLocation KWLoc, const CXXScopeSpec &SS,
IdentifierInfo *Name, SourceLocation NameLoc,
AttributeList *Attr, AccessSpecifier AS,
MultiTemplateParamsArg TemplateParameterLists,
bool &OwnedDecl) {
// If this is not a definition, it must have a name.
- assert((Name != 0 || TK == TK_Definition) &&
+ assert((Name != 0 || TUK == TUK_Definition) &&
"Nameless record must be a definition!");
OwnedDecl = false;
@@ -3873,7 +3873,7 @@
case DeclSpec::TST_enum: Kind = TagDecl::TK_enum; break;
}
- if (TK != TK_Reference) {
+ if (TUK != TUK_Reference) {
if (TemplateParameterList *TemplateParams
= MatchTemplateParametersToScopeSpecifier(KWLoc, SS,
(TemplateParameterList**)TemplateParameterLists.get(),
@@ -3882,7 +3882,7 @@
// This is a declaration or definition of a class template (which may
// be a member of another template).
OwnedDecl = false;
- DeclResult Result = CheckClassTemplate(S, TagSpec, TK, KWLoc,
+ DeclResult Result = CheckClassTemplate(S, TagSpec, TUK, KWLoc,
SS, Name, NameLoc, Attr,
move(TemplateParameterLists),
AS);
@@ -3934,7 +3934,7 @@
// shouldn't be. Doing so can result in ambiguities that we
// shouldn't be diagnosing.
LookupResult R = LookupName(S, Name, LookupTagName,
- /*RedeclarationOnly=*/(TK != TK_Reference));
+ /*RedeclarationOnly=*/(TUK != TUK_Reference));
if (R.isAmbiguous()) {
DiagnoseAmbiguousLookup(R, Name, NameLoc);
// FIXME: This is not best way to recover from case like:
@@ -3949,7 +3949,7 @@
else
PrevDecl = R;
- if (!getLangOptions().CPlusPlus && TK != TK_Reference) {
+ if (!getLangOptions().CPlusPlus && TUK != TUK_Reference) {
// FIXME: This makes sure that we ignore the contexts associated
// with C structs, unions, and enums when looking for a matching
// tag declaration or definition. See the similar lookup tweak
@@ -3974,7 +3974,7 @@
// If this is a use of a previous tag, or if the tag is already declared
// in the same scope (so that the definition/declaration completes or
// rementions the tag), reuse the decl.
- if (TK == TK_Reference || isDeclInScope(PrevDecl, SearchDC, S)) {
+ if (TUK == TUK_Reference || isDeclInScope(PrevDecl, SearchDC, S)) {
// Make sure that this wasn't declared as an enum and now used as a
// struct or something similar.
if (!isAcceptableTagRedeclaration(PrevTagDecl, Kind, KWLoc, *Name)) {
@@ -4007,11 +4007,11 @@
// for the consumer of this Decl to know it doesn't own it.
// For our current ASTs this shouldn't be a problem, but will
// need to be changed with DeclGroups.
- if (TK == TK_Reference)
+ if (TUK == TUK_Reference)
return DeclPtrTy::make(PrevDecl);
// Diagnose attempts to redefine a tag.
- if (TK == TK_Definition) {
+ if (TUK == TUK_Definition) {
if (TagDecl *Def = PrevTagDecl->getDefinition(Context)) {
Diag(NameLoc, diag::err_redefinition) << Name;
Diag(Def->getLocation(), diag::note_previous_definition);
@@ -4068,7 +4068,7 @@
PrevDecl = 0;
}
}
- } else if (TK == TK_Reference && SS.isEmpty() && Name &&
+ } else if (TUK == TUK_Reference && SS.isEmpty() && Name &&
(Kind != TagDecl::TK_enum || !getLangOptions().CPlusPlus)) {
// C++ [basic.scope.pdecl]p5:
// -- for an elaborated-type-specifier of the form
@@ -4123,7 +4123,7 @@
New = EnumDecl::Create(Context, SearchDC, Loc, Name, KWLoc,
cast_or_null<EnumDecl>(PrevDecl));
// If this is an undefined enum, warn.
- if (TK != TK_Definition && !Invalid) {
+ if (TUK != TUK_Definition && !Invalid) {
unsigned DK = getLangOptions().CPlusPlus? diag::err_forward_ref_enum
: diag::ext_forward_ref_enum;
Diag(Loc, DK);
@@ -4199,7 +4199,7 @@
if (!Invalid)
SetMemberAccessSpecifier(New, PrevDecl, AS);
- if (TK == TK_Definition)
+ if (TUK == TUK_Definition)
New->startDefinition();
// If this has an identifier, add it to the scope stack.
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=77658&r1=77657&r2=77658&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Jul 30 21:45:11 2009
@@ -438,14 +438,14 @@
}
Sema::DeclResult
-Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagKind TK,
+Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
SourceLocation KWLoc, const CXXScopeSpec &SS,
IdentifierInfo *Name, SourceLocation NameLoc,
AttributeList *Attr,
MultiTemplateParamsArg TemplateParameterLists,
AccessSpecifier AS) {
assert(TemplateParameterLists.size() > 0 && "No template parameter lists?");
- assert(TK != TK_Reference && "Can only declare or define class templates");
+ assert(TUK != TUK_Reference && "Can only declare or define class templates");
bool Invalid = false;
// Check that we can declare a template here.
@@ -515,7 +515,7 @@
}
// Check for redefinition of this class template.
- if (TK == TK_Definition) {
+ if (TUK == TUK_Definition) {
if (TagDecl *Def = PrevRecordDecl->getDefinition(Context)) {
Diag(NameLoc, diag::err_redefinition) << Name;
Diag(Def->getLocation(), diag::note_previous_definition);
@@ -577,7 +577,7 @@
NewClass->setLexicalDeclContext(CurContext);
NewTemplate->setLexicalDeclContext(CurContext);
- if (TK == TK_Definition)
+ if (TUK == TUK_Definition)
NewClass->startDefinition();
if (Attr)
@@ -2346,7 +2346,8 @@
}
Sema::DeclResult
-Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagKind TK,
+Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
+ TagUseKind TUK,
SourceLocation KWLoc,
const CXXScopeSpec &SS,
TemplateTy TemplateD,
@@ -2472,10 +2473,10 @@
// -- The argument list of the specialization shall not be identical
// to the implicit argument list of the primary template.
Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
- << (TK == TK_Definition)
+ << (TUK == TUK_Definition)
<< CodeModificationHint::CreateRemoval(SourceRange(LAngleLoc,
RAngleLoc));
- return CheckClassTemplate(S, TagSpec, TK, KWLoc, SS,
+ return CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS,
ClassTemplate->getIdentifier(),
TemplateNameLoc,
Attr,
@@ -2613,7 +2614,7 @@
Specialization->setSpecializationKind(TSK_ExplicitSpecialization);
// Check that this isn't a redefinition of this specialization.
- if (TK == TK_Definition) {
+ if (TUK == TUK_Definition) {
if (RecordDecl *Def = Specialization->getDefinition(Context)) {
// FIXME: Should also handle explicit specialization after implicit
// instantiation with a special diagnostic.
@@ -2652,7 +2653,7 @@
Specialization->setLexicalDeclContext(CurContext);
// We may be starting the definition of this specialization.
- if (TK == TK_Definition)
+ if (TUK == TUK_Definition)
Specialization->startDefinition();
// Add the specialization into its lexical context, so that it can
@@ -2892,7 +2893,7 @@
AttributeList *Attr) {
bool Owned = false;
- DeclPtrTy TagD = ActOnTag(S, TagSpec, Action::TK_Reference,
+ DeclPtrTy TagD = ActOnTag(S, TagSpec, Action::TUK_Reference,
KWLoc, SS, Name, NameLoc, Attr, AS_none,
MultiTemplateParamsArg(*this, 0, 0), Owned);
if (!TagD)
More information about the cfe-commits
mailing list