[cfe-commits] r76881 - in /cfe/trunk: include/clang/Parse/Action.h lib/AST/Type.cpp lib/Frontend/PrintParserCallbacks.cpp lib/Parse/ParseDecl.cpp lib/Sema/Sema.h lib/Sema/SemaDecl.cpp lib/Sema/SemaTemplate.cpp

Douglas Gregor dgregor at apple.com
Thu Jul 23 09:36:49 PDT 2009


Author: dgregor
Date: Thu Jul 23 11:36:45 2009
New Revision: 76881

URL: http://llvm.org/viewvc/llvm-project?rev=76881&view=rev
Log:
Clean up the ActOnTag action, so that there is only a single entry
point that covers templates and non-templates. This should eliminate
the flood of warnings I introduced yesterday.

Removed the ActOnClassTemplate action, which is no longer used.

Modified:
    cfe/trunk/include/clang/Parse/Action.h
    cfe/trunk/lib/AST/Type.cpp
    cfe/trunk/lib/Frontend/PrintParserCallbacks.cpp
    cfe/trunk/lib/Parse/ParseDecl.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=76881&r1=76880&r2=76881&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Thu Jul 23 11:36:45 2009
@@ -415,25 +415,53 @@
     TK_Declaration, // Fwd decl of a tag:   'struct foo;'
     TK_Definition   // Definition of a tag: 'struct foo { int X; } Y;'
   };
-  virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
-                             SourceLocation KWLoc, const CXXScopeSpec &SS,
-                             IdentifierInfo *Name, SourceLocation NameLoc,
-                             AttributeList *Attr, AccessSpecifier AS,
-                             bool &OwnedDecl) {
-    // TagType is an instance of DeclSpec::TST, indicating what kind of tag this
-    // is (struct/union/enum/class).
-    return ActOnTag(S, TagSpec, TK, KWLoc, SS, Name, NameLoc, Attr, AS,
-                    MultiTemplateParamsArg(*this, 0, 0), OwnedDecl);
-  }
 
+  /// \brief The parser has encountered a tag (e.g., "class X") that should be
+  /// turned into a declaration by the action module.
+  ///
+  /// \param S the scope in which this tag occurs.
+  ///
+  /// \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 KWLoc the location of the "struct", "class", "union", or "enum" 
+  /// keyword.
+  ///
+  /// \param SS C++ scope specifier that precedes the name of the tag, e.g.,
+  /// the "std::" in "class std::type_info".
+  ///
+  /// \param Name the name of the tag, e.g., "X" in "struct X". This parameter
+  /// may be NULL, to indicate an anonymous class/struct/union/enum type.
+  ///
+  /// \param NameLoc the location of the name of the tag.
+  ///
+  /// \param Attr the set of attributes that appertain to the tag.
+  ///
+  /// \param AS when this tag occurs within a C++ class, provides the 
+  /// current access specifier (AS_public, AS_private, AS_protected). 
+  /// Otherwise, it will be AS_none.
+  ///
+  /// \param TemplateParameterLists the set of C++ template parameter lists 
+  /// that apply to this tag, if the tag is a declaration or definition (see 
+  /// the \p TK parameter). The action module is responsible for determining,
+  /// based on the template parameter lists and the scope specifier, whether
+  /// the declared tag is a class template or not.
+  ///
+  /// \param OwnedDecl the callee should set this flag true when the returned
+  /// declaration is "owned" by this reference. Ownership is handled entirely
+  /// by the action module.
+  ///
+  /// \returns the declaration to which this tag refers.
   virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
                              SourceLocation KWLoc, const CXXScopeSpec &SS,
                              IdentifierInfo *Name, SourceLocation NameLoc,
                              AttributeList *Attr, AccessSpecifier AS,
                              MultiTemplateParamsArg TemplateParameterLists,
                              bool &OwnedDecl) {
-    // TagType is an instance of DeclSpec::TST, indicating what kind of tag this
-    // is (struct/union/enum/class).
     return DeclPtrTy();
   }
   
@@ -1369,18 +1397,6 @@
     return 0;
   }
 
-  /// \brief Process the declaration or definition of a class template
-  /// with the given template parameter lists.
-  virtual DeclResult
-  ActOnClassTemplate(Scope *S, unsigned TagSpec, TagKind TK,
-                     SourceLocation KWLoc, const CXXScopeSpec &SS,
-                     IdentifierInfo *Name, SourceLocation NameLoc,
-                     AttributeList *Attr,
-                     MultiTemplateParamsArg TemplateParameterLists,
-                     AccessSpecifier AS) {
-    return DeclResult();
-  }
-
   /// \brief Form a type from a template and a list of template
   /// arguments.
   ///

Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=76881&r1=76880&r2=76881&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Thu Jul 23 11:36:45 2009
@@ -65,8 +65,9 @@
 }
 
 void DependentSizedExtVectorType::Destroy(ASTContext& C) {
-  if (SizeExpr)
-    SizeExpr->Destroy(C);
+  // FIXME: Deallocate size expression, once we're cloning properly.
+//  if (SizeExpr)
+//    SizeExpr->Destroy(C);
   this->~DependentSizedExtVectorType();
   C.Deallocate(this);
 }

Modified: cfe/trunk/lib/Frontend/PrintParserCallbacks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintParserCallbacks.cpp?rev=76881&r1=76880&r2=76881&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PrintParserCallbacks.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintParserCallbacks.cpp Thu Jul 23 11:36:45 2009
@@ -197,6 +197,7 @@
                                SourceLocation KWLoc, const CXXScopeSpec &SS,
                                IdentifierInfo *Name, SourceLocation NameLoc,
                                AttributeList *Attr, AccessSpecifier AS,
+                               MultiTemplateParamsArg TemplateParamLists,
                                bool &Owned) {
       // TagType is an instance of DeclSpec::TST, indicating what kind of tag this
       // is (struct/union/enum/class).

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=76881&r1=76880&r2=76881&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Jul 23 11:36:45 2009
@@ -1587,6 +1587,7 @@
   bool Owned = false;
   DeclPtrTy TagDecl = Actions.ActOnTag(CurScope, DeclSpec::TST_enum, TK,
                                        StartLoc, SS, Name, NameLoc, Attr, AS,
+                                       Action::MultiTemplateParamsArg(Actions),
                                        Owned);
   
   if (Tok.is(tok::l_brace))

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=76881&r1=76880&r2=76881&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Thu Jul 23 11:36:45 2009
@@ -2084,13 +2084,12 @@
                                           TemplateParameterList **ParamLists,
                                           unsigned NumParamLists);
                                                 
-  virtual DeclResult
-  ActOnClassTemplate(Scope *S, unsigned TagSpec, TagKind TK,
-                     SourceLocation KWLoc, const CXXScopeSpec &SS,
-                     IdentifierInfo *Name, SourceLocation NameLoc,
-                     AttributeList *Attr,
-                     MultiTemplateParamsArg TemplateParameterLists,
-                     AccessSpecifier AS);
+  DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagKind TK,
+                                SourceLocation KWLoc, const CXXScopeSpec &SS,
+                                IdentifierInfo *Name, SourceLocation NameLoc,
+                                AttributeList *Attr,
+                                MultiTemplateParamsArg TemplateParameterLists,
+                                AccessSpecifier AS);
 
   QualType CheckTemplateIdType(TemplateName Template,
                                SourceLocation TemplateLoc,

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=76881&r1=76880&r2=76881&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jul 23 11:36:45 2009
@@ -3665,7 +3665,7 @@
         // This is a declaration or definition of a class template (which may
         // be a member of another template).
         OwnedDecl = false;
-        DeclResult Result = ActOnClassTemplate(S, TagSpec, TK, KWLoc,
+        DeclResult Result = CheckClassTemplate(S, TagSpec, TK, KWLoc,
                                                SS, Name, NameLoc, Attr,
                                                move(TemplateParameterLists),
                                                AS);

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=76881&r1=76880&r2=76881&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Jul 23 11:36:45 2009
@@ -409,7 +409,7 @@
 }
 
 Sema::DeclResult
-Sema::ActOnClassTemplate(Scope *S, unsigned TagSpec, TagKind TK,
+Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagKind TK,
                          SourceLocation KWLoc, const CXXScopeSpec &SS,
                          IdentifierInfo *Name, SourceLocation NameLoc,
                          AttributeList *Attr,
@@ -2491,7 +2491,7 @@
         << (TK == TK_Definition)
         << CodeModificationHint::CreateRemoval(SourceRange(LAngleLoc, 
                                                            RAngleLoc));
-      return ActOnClassTemplate(S, TagSpec, TK, KWLoc, SS,
+      return CheckClassTemplate(S, TagSpec, TK, KWLoc, SS,
                                 ClassTemplate->getIdentifier(),
                                 TemplateNameLoc,
                                 Attr,





More information about the cfe-commits mailing list