[cfe-commits] r67710 - in /cfe/trunk: include/clang/Parse/Action.h include/clang/Parse/Parser.h lib/Parse/ParseDecl.cpp lib/Parse/ParseDeclCXX.cpp lib/Sema/Sema.h lib/Sema/SemaDecl.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp tools/clang-cc/PrintParserCallbacks.cpp

Douglas Gregor dgregor at apple.com
Wed Mar 25 15:00:54 PDT 2009


Author: dgregor
Date: Wed Mar 25 17:00:53 2009
New Revision: 67710

URL: http://llvm.org/viewvc/llvm-project?rev=67710&view=rev
Log:
Pass access specifiers through to member classes and member enums.

Modified:
    cfe/trunk/include/clang/Parse/Action.h
    cfe/trunk/include/clang/Parse/Parser.h
    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/SemaTemplateInstantiateDecl.cpp
    cfe/trunk/tools/clang-cc/PrintParserCallbacks.cpp

Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=67710&r1=67709&r2=67710&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Wed Mar 25 17:00:53 2009
@@ -353,7 +353,7 @@
   virtual DeclTy *ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
                            SourceLocation KWLoc, const CXXScopeSpec &SS,
                            IdentifierInfo *Name, SourceLocation NameLoc,
-                           AttributeList *Attr) {
+                           AttributeList *Attr, AccessSpecifier AS) {
     // TagType is an instance of DeclSpec::TST, indicating what kind of tag this
     // is (struct/union/enum/class).
     return 0;

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=67710&r1=67709&r2=67710&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 25 17:00:53 2009
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_PARSE_PARSER_H
 
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Parse/AccessSpecifier.h"
 #include "clang/Parse/Action.h"
 #include "clang/Parse/DeclSpec.h"
 #include "llvm/ADT/OwningPtr.h"
@@ -809,7 +810,8 @@
   DeclTy *ParseInitDeclaratorListAfterFirstDeclarator(Declarator &D);
   DeclTy *ParseFunctionStatementBody(DeclTy *Decl);
   void ParseDeclarationSpecifiers(DeclSpec &DS, 
-                                  TemplateParameterLists *TemplateParams = 0);
+                                  TemplateParameterLists *TemplateParams = 0,
+                                  AccessSpecifier AS = AS_none);
   bool ParseOptionalTypeSpecifier(DeclSpec &DS, int &isInvalid, 
                                   const char *&PrevSpec,
                                   TemplateParameterLists *TemplateParams = 0);
@@ -817,7 +819,7 @@
   
   void ParseObjCTypeQualifierList(ObjCDeclSpec &DS);
 
-  void ParseEnumSpecifier(DeclSpec &DS);
+  void ParseEnumSpecifier(DeclSpec &DS, AccessSpecifier AS = AS_none);
   void ParseEnumBody(SourceLocation StartLoc, DeclTy *TagDecl);
   void ParseStructUnionBody(SourceLocation StartLoc, unsigned TagType,
                             DeclTy *TagDecl);
@@ -999,7 +1001,8 @@
   TypeTy *ParseClassName(SourceLocation &EndLocation, 
                          const CXXScopeSpec *SS = 0);
   void ParseClassSpecifier(DeclSpec &DS, 
-                           TemplateParameterLists *TemplateParams = 0);
+                           TemplateParameterLists *TemplateParams = 0,
+                           AccessSpecifier AS = AS_none);
   void ParseCXXMemberSpecification(SourceLocation StartLoc, unsigned TagType,
                                    DeclTy *TagDecl);
   DeclTy *ParseCXXClassMemberDeclaration(AccessSpecifier AS);

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Mar 25 17:00:53 2009
@@ -471,7 +471,8 @@
 /// [C++]   'explicit'
 ///
 void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
-                                        TemplateParameterLists *TemplateParams){
+                                        TemplateParameterLists *TemplateParams,
+                                        AccessSpecifier AS){
   DS.SetRangeStart(Tok.getLocation());
   while (1) {
     int isInvalid = false;
@@ -767,12 +768,12 @@
     case tok::kw_class:
     case tok::kw_struct:
     case tok::kw_union:
-      ParseClassSpecifier(DS, TemplateParams);
+      ParseClassSpecifier(DS, TemplateParams, AS);
       continue;
 
     // enum-specifier:
     case tok::kw_enum:
-      ParseEnumSpecifier(DS);
+      ParseEnumSpecifier(DS, AS);
       continue;
 
     // cv-qualifier:
@@ -1228,7 +1229,7 @@
 /// [C++] elaborated-type-specifier:
 /// [C++]   'enum' '::'[opt] nested-name-specifier[opt] identifier
 ///
-void Parser::ParseEnumSpecifier(DeclSpec &DS) {
+void Parser::ParseEnumSpecifier(DeclSpec &DS, AccessSpecifier AS) {
   assert(Tok.is(tok::kw_enum) && "Not an enum specifier");
   SourceLocation StartLoc = ConsumeToken();
   
@@ -1285,7 +1286,7 @@
   else
     TK = Action::TK_Reference;
   DeclTy *TagDecl = Actions.ActOnTag(CurScope, DeclSpec::TST_enum, TK, StartLoc,
-                                     SS, Name, NameLoc, Attr);
+                                     SS, Name, NameLoc, Attr, AS);
   
   if (Tok.is(tok::l_brace))
     ParseEnumBody(StartLoc, TagDecl);

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Wed Mar 25 17:00:53 2009
@@ -349,7 +349,8 @@
 ///         'struct'
 ///         'union'
 void Parser::ParseClassSpecifier(DeclSpec &DS,
-                                 TemplateParameterLists *TemplateParams) {
+                                 TemplateParameterLists *TemplateParams,
+                                 AccessSpecifier AS) {
   assert((Tok.is(tok::kw_class) || 
           Tok.is(tok::kw_struct) || 
           Tok.is(tok::kw_union)) &&
@@ -462,7 +463,7 @@
                                                       TemplateParams->size()));
   else
     TagOrTempResult = Actions.ActOnTag(CurScope, TagType, TK, StartLoc, SS, Name, 
-                                     NameLoc, Attr);
+                                       NameLoc, Attr, AS);
 
   // Parse the optional base clause (C++ only).
   if (getLang().CPlusPlus && Tok.is(tok::colon))
@@ -649,7 +650,7 @@
   // decl-specifier-seq:
   // Parse the common declaration-specifiers piece.
   DeclSpec DS;
-  ParseDeclarationSpecifiers(DS);
+  ParseDeclarationSpecifiers(DS, 0, AS);
 
   if (Tok.is(tok::semi)) {
     ConsumeToken();

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Mar 25 17:00:53 2009
@@ -390,7 +390,7 @@
   virtual DeclTy *ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
                            SourceLocation KWLoc, const CXXScopeSpec &SS,
                            IdentifierInfo *Name, SourceLocation NameLoc,
-                           AttributeList *Attr);
+                           AttributeList *Attr, AccessSpecifier AS);
   
   virtual void ActOnDefs(Scope *S, DeclTy *TagD, SourceLocation DeclStart,
                          IdentifierInfo *ClassName,

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Mar 25 17:00:53 2009
@@ -3068,7 +3068,7 @@
 Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
                              SourceLocation KWLoc, const CXXScopeSpec &SS,
                              IdentifierInfo *Name, SourceLocation NameLoc,
-                             AttributeList *Attr) {
+                             AttributeList *Attr, AccessSpecifier AS) {
   // If this is not a definition, it must have a name.
   assert((Name != 0 || TK == TK_Definition) &&
          "Nameless record must be a definition!");
@@ -3362,6 +3362,9 @@
   // lexical context will be different from the semantic context.
   New->setLexicalDeclContext(CurContext);
 
+  if (AS != AS_none)
+    New->setAccess(AS);
+
   if (TK == TK_Definition)
     New->startDefinition();
   

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Mar 25 17:00:53 2009
@@ -173,6 +173,7 @@
   EnumDecl *Enum = EnumDecl::Create(SemaRef.Context, Owner, 
                                     D->getLocation(), D->getIdentifier(),
                                     /*PrevDecl=*/0);
+  Enum->setAccess(D->getAccess());
   Owner->addDecl(Enum);
   Enum->startDefinition();
 

Modified: cfe/trunk/tools/clang-cc/PrintParserCallbacks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/PrintParserCallbacks.cpp?rev=67710&r1=67709&r2=67710&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/PrintParserCallbacks.cpp (original)
+++ cfe/trunk/tools/clang-cc/PrintParserCallbacks.cpp Wed Mar 25 17:00:53 2009
@@ -189,7 +189,7 @@
     virtual DeclTy *ActOnTag(Scope *S, unsigned TagType, TagKind TK,
                              SourceLocation KWLoc, const CXXScopeSpec &SS,
                              IdentifierInfo *Name, SourceLocation NameLoc,
-                             AttributeList *Attr) {
+                             AttributeList *Attr, AccessSpecifier AS) {
       // TagType is an instance of DeclSpec::TST, indicating what kind of tag this
       // is (struct/union/enum/class).
       llvm::cout << __FUNCTION__ << "\n";





More information about the cfe-commits mailing list