[cfe-commits] r127259 - in /cfe/trunk: include/clang/Parse/Parser.h lib/Parse/ParseObjc.cpp

Douglas Gregor dgregor at apple.com
Tue Mar 8 11:17:54 PST 2011


Author: dgregor
Date: Tue Mar  8 13:17:54 2011
New Revision: 127259

URL: http://llvm.org/viewvc/llvm-project?rev=127259&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/lib/Parse/ParseObjc.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=127259&r1=127258&r2=127259&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Mar  8 13:17:54 2011
@@ -992,7 +992,13 @@
 
   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 @@
 
   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(),

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=127259&r1=127258&r2=127259&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue Mar  8 13:17:54 2011
@@ -720,10 +720,12 @@
 ///     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 @@
 ///     '(' 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 @@
   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 @@
 
     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;





More information about the cfe-commits mailing list