diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index dc57268d7b305c3bb419f88eaf653ea63a889daa..1215e2daa7358735414259655d48627aff87f4b7 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -1060,8 +1060,8 @@ private: ExprResult ParseAsmStringLiteral(); // Objective-C External Declarations - Parser::DeclGroupPtrTy ParseObjCAtDirectives(); - Parser::DeclGroupPtrTy ParseObjCAtClassDeclaration(SourceLocation atLoc); + Decl *ParseObjCAtDirectives(); + Decl *ParseObjCAtClassDeclaration(SourceLocation atLoc); Decl *ParseObjCAtInterfaceDeclaration(SourceLocation atLoc, ParsedAttributes &prefixAttrs); void ParseObjCClassInstanceVariables(Decl *interfaceDecl, diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 40d570df05bc0d6d45d8073381f1258aa89420e4..07bbd18bee8ed2efc9fdd541a9b8886c2315748c 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -5001,7 +5001,7 @@ public: IdentifierInfo *CatName, SourceLocation CatLoc); - DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc, + Decl *ActOnForwardClassDeclaration(SourceLocation Loc, IdentifierInfo **IdentList, SourceLocation *IdentLocs, unsigned NumElts); diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp index 17c962e2b572585398a1426b7d588f8a8e144501..684d8edf891906af8bdc3545729e2736835d7211 100644 --- a/clang/lib/Parse/ParseObjc.cpp +++ b/clang/lib/Parse/ParseObjc.cpp @@ -29,59 +29,47 @@ using namespace clang; /// [OBJC] objc-protocol-definition /// [OBJC] objc-method-definition /// [OBJC] '@' 'end' -Parser::DeclGroupPtrTy Parser::ParseObjCAtDirectives() { +Decl *Parser::ParseObjCAtDirectives() { SourceLocation AtLoc = ConsumeToken(); // the "@" if (Tok.is(tok::code_completion)) { Actions.CodeCompleteObjCAtDirective(getCurScope()); ConsumeCodeCompletionToken(); } - - Decl *SingleDecl = 0; + switch (Tok.getObjCKeywordID()) { case tok::objc_class: return ParseObjCAtClassDeclaration(AtLoc); - break; case tok::objc_interface: { ParsedAttributes attrs(AttrFactory); - SingleDecl = ParseObjCAtInterfaceDeclaration(AtLoc, attrs); - break; + return ParseObjCAtInterfaceDeclaration(AtLoc, attrs); } case tok::objc_protocol: { ParsedAttributes attrs(AttrFactory); - SingleDecl = ParseObjCAtProtocolDeclaration(AtLoc, attrs); - break; + return ParseObjCAtProtocolDeclaration(AtLoc, attrs); } case tok::objc_implementation: - SingleDecl = ParseObjCAtImplementationDeclaration(AtLoc); - break; + return ParseObjCAtImplementationDeclaration(AtLoc); case tok::objc_end: - SingleDecl = ParseObjCAtEndDeclaration(AtLoc); - break; + return ParseObjCAtEndDeclaration(AtLoc); case tok::objc_compatibility_alias: - SingleDecl = ParseObjCAtAliasDeclaration(AtLoc); - break; + return ParseObjCAtAliasDeclaration(AtLoc); case tok::objc_synthesize: - SingleDecl = ParseObjCPropertySynthesize(AtLoc); - break; + return ParseObjCPropertySynthesize(AtLoc); case tok::objc_dynamic: - SingleDecl = ParseObjCPropertyDynamic(AtLoc); - break; + return ParseObjCPropertyDynamic(AtLoc); default: Diag(AtLoc, diag::err_unexpected_at); SkipUntil(tok::semi); - SingleDecl = 0; - break; + return 0; } - return Actions.ConvertDeclToDeclGroup(SingleDecl); } /// /// objc-class-declaration: /// '@' 'class' identifier-list ';' /// -Parser::DeclGroupPtrTy -Parser::ParseObjCAtClassDeclaration(SourceLocation atLoc) { +Decl *Parser::ParseObjCAtClassDeclaration(SourceLocation atLoc) { ConsumeToken(); // the identifier "class" SmallVector ClassNames; SmallVector ClassLocs; @@ -91,7 +79,7 @@ Parser::ParseObjCAtClassDeclaration(SourceLocation atLoc) { if (Tok.isNot(tok::identifier)) { Diag(Tok, diag::err_expected_ident); SkipUntil(tok::semi); - return Actions.ConvertDeclToDeclGroup(0); + return 0; } ClassNames.push_back(Tok.getIdentifierInfo()); ClassLocs.push_back(Tok.getLocation()); @@ -105,7 +93,7 @@ Parser::ParseObjCAtClassDeclaration(SourceLocation atLoc) { // Consume the ';'. if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after, "@class")) - return Actions.ConvertDeclToDeclGroup(0); + return 0; return Actions.ActOnForwardClassDeclaration(atLoc, ClassNames.data(), ClassLocs.data(), diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index e57b898d52324d6cc6c05e39ac68c0b92e0f11d4..0da2b4302c49045cf05ea7522576675a2645616b 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -593,7 +593,10 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, break; } case tok::at: - return ParseObjCAtDirectives(); + // @ is not a legal token unless objc is enabled, no need to check for ObjC. + /// FIXME: ParseObjCAtDirectives should return a DeclGroup for things like + /// @class foo, bar; + SingleDecl = ParseObjCAtDirectives(); break; case tok::minus: case tok::plus: diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 8768236b1fccfc430ffae38c8cad76648d1a8a6a..7a9d6d50729b39df9d741da426eb69ab318087b0 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1654,14 +1654,14 @@ void Sema::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl, } /// ActOnForwardClassDeclaration - -Sema::DeclGroupPtrTy +Decl * Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc, IdentifierInfo **IdentList, SourceLocation *IdentLocs, unsigned NumElts) { - SmallVector DeclsInGroup; + SmallVector Interfaces; + for (unsigned i = 0; i != NumElts; ++i) { - SmallVector Interfaces; // Check for another declaration kind with the same name. NamedDecl *PrevDecl = LookupSingleName(TUScope, IdentList[i], IdentLocs[i], @@ -1707,15 +1707,15 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc, } Interfaces.push_back(IDecl); - ObjCClassDecl *CDecl = ObjCClassDecl::Create(Context, CurContext, AtClassLoc, - Interfaces.data(), IdentLocs, - 1); - CurContext->addDecl(CDecl); - CheckObjCDeclScope(CDecl); - DeclsInGroup.push_back(CDecl); } - - return BuildDeclaratorGroup(DeclsInGroup.data(), DeclsInGroup.size(), false); + + assert(Interfaces.size() == NumElts); + ObjCClassDecl *CDecl = ObjCClassDecl::Create(Context, CurContext, AtClassLoc, + Interfaces.data(), IdentLocs, + Interfaces.size()); + CurContext->addDecl(CDecl); + CheckObjCDeclScope(CDecl); + return CDecl; } static bool tryMatchRecordTypes(ASTContext &Context,