From: Douglas Gregor Date: Tue, 8 Mar 2011 19:17:54 +0000 (+0000) Subject: Clarify the context in which an Objective-C type name is being parsed X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b77cab97f17f946744c920629ca17271308d8ebf;p=clang Clarify the context in which an Objective-C type name is being parsed by using an enumeration rather than a boolean value. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127259 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index b8ae999fe5..5d667d9b8e 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -992,7 +992,13 @@ private: bool isTokIdentifier_in() const; - ParsedType ParseObjCTypeName(ObjCDeclSpec &DS, bool IsParameter); + /// \brief The context in which we are parsing an Objective-C type name. + enum ObjCTypeNameContext { + OTN_ResultType, + OTN_ParameterType + }; + + ParsedType ParseObjCTypeName(ObjCDeclSpec &DS, ObjCTypeNameContext Context); void ParseObjCMethodRequirement(); Decl *ParseObjCMethodPrototype(Decl *classOrCat, tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword); @@ -1303,7 +1309,8 @@ private: void ParseSpecifierQualifierList(DeclSpec &DS); - void ParseObjCTypeQualifierList(ObjCDeclSpec &DS, bool IsParameter); + void ParseObjCTypeQualifierList(ObjCDeclSpec &DS, + ObjCTypeNameContext Context); void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS, const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(), diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index f32a322f02..b6b1551907 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -720,10 +720,12 @@ bool Parser::isTokIdentifier_in() const { /// objc-type-qualifier /// objc-type-qualifiers objc-type-qualifier /// -void Parser::ParseObjCTypeQualifierList(ObjCDeclSpec &DS, bool IsParameter) { +void Parser::ParseObjCTypeQualifierList(ObjCDeclSpec &DS, + ObjCTypeNameContext Context) { while (1) { if (Tok.is(tok::code_completion)) { - Actions.CodeCompleteObjCPassingType(getCurScope(), DS, IsParameter); + Actions.CodeCompleteObjCPassingType(getCurScope(), DS, + Context == OTN_ParameterType); ConsumeCodeCompletionToken(); } @@ -760,14 +762,15 @@ void Parser::ParseObjCTypeQualifierList(ObjCDeclSpec &DS, bool IsParameter) { /// '(' objc-type-qualifiers[opt] type-name ')' /// '(' objc-type-qualifiers[opt] ')' /// -ParsedType Parser::ParseObjCTypeName(ObjCDeclSpec &DS, bool IsParameter) { +ParsedType Parser::ParseObjCTypeName(ObjCDeclSpec &DS, + ObjCTypeNameContext Context) { assert(Tok.is(tok::l_paren) && "expected ("); SourceLocation LParenLoc = ConsumeParen(); SourceLocation TypeStartLoc = Tok.getLocation(); // Parse type qualifiers, in, inout, etc. - ParseObjCTypeQualifierList(DS, IsParameter); + ParseObjCTypeQualifierList(DS, Context); ParsedType Ty; if (isTypeSpecifierQualifier()) { @@ -834,7 +837,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, ParsedType ReturnType; ObjCDeclSpec DSRet; if (Tok.is(tok::l_paren)) - ReturnType = ParseObjCTypeName(DSRet, false); + ReturnType = ParseObjCTypeName(DSRet, OTN_ResultType); // If attributes exist before the method, parse them. ParsedAttributes attrs; @@ -894,7 +897,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, ArgInfo.Type = ParsedType(); if (Tok.is(tok::l_paren)) // Parse the argument type if present. - ArgInfo.Type = ParseObjCTypeName(ArgInfo.DeclSpec, true); + ArgInfo.Type = ParseObjCTypeName(ArgInfo.DeclSpec, OTN_ParameterType); // If attributes exist before the argument name, parse them. ArgInfo.ArgAttrs = 0;