]> granicus.if.org Git - clang/commitdiff
1) More additions for objective-c's qualifier type.
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 31 Oct 2007 23:53:01 +0000 (23:53 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 31 Oct 2007 23:53:01 +0000 (23:53 +0000)
2) Fixed a test failure (which should have failed all along!).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43589 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/RewriteTest.cpp
Parse/ParseObjc.cpp
Sema/Sema.h
Sema/SemaDecl.cpp
include/clang/Parse/Action.h
include/clang/Parse/Parser.h

index 257a060ba981d1b50ee6eecd96b3f9d388bb1c7f..999b0796a97b713491043e24a9b2f9208d2424be 100644 (file)
@@ -555,8 +555,7 @@ void RewriteTest::SynthesizeObjcInternalStruct(ObjcInterfaceDecl *CDecl,
   
   int NumIvars = CDecl->getIntfDeclNumIvars();
   // If no ivars and no root or if its root, directly or indirectly,
-  // have no ivars (thus not synthesize)
-  // then no need to synthesize this class either.
+  // have no ivars (thus not synthesized) then no need to synthesize this class.
   if (NumIvars <= 0 && (!RCDecl || !ObjcSynthesizedStructs.count(RCDecl)))
     return;
   
index 301b04148a314ef6a4f7bd67072487fb5daebfe1..69124f2939d24572acc5694634915c65e8278825 100644 (file)
@@ -471,14 +471,13 @@ bool Parser::isObjCPropertyAttribute() {
 ///     objc-type-qualifier
 ///     objc-type-qualifiers objc-type-qualifier
 ///
-Parser::TypeTy *Parser::ParseObjCTypeName() {
+Parser::TypeTy *Parser::ParseObjCTypeName(ObjcDeclSpec &DS) {
   assert(Tok.is(tok::l_paren) && "expected (");
   
   SourceLocation LParenLoc = ConsumeParen(), RParenLoc;
   TypeTy *Ty = 0;
   
   // Parse type qualifiers, in, inout, etc.
-  ObjcDeclSpec DS;
   ParseObjcTypeQualifierList(DS);
 
   if (isTypeSpecifierQualifier()) {
@@ -528,8 +527,9 @@ Parser::DeclTy *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
 {
   // Parse the return type.
   TypeTy *ReturnType = 0;
+  ObjcDeclSpec DSRet;
   if (Tok.is(tok::l_paren))
-    ReturnType = ParseObjCTypeName();
+    ReturnType = ParseObjCTypeName(DSRet);
   SourceLocation selLoc;
   IdentifierInfo *SelIdent = ParseObjCSelector(selLoc);
   if (Tok.isNot(tok::colon)) {
@@ -546,12 +546,13 @@ Parser::DeclTy *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
     
     Selector Sel = PP.getSelectorTable().getNullarySelector(SelIdent);
     return Actions.ActOnMethodDeclaration(mLoc, Tok.getLocation(),
-                                          mType, ReturnType, Sel,
-                                          0, 0, MethodAttrs, MethodImplKind);
+                                          mType, DSRet, ReturnType, Sel,
+                                          0, 0, 0, MethodAttrs, MethodImplKind);
   }
 
   llvm::SmallVector<IdentifierInfo *, 12> KeyIdents;
   llvm::SmallVector<Action::TypeTy *, 12> KeyTypes;
+  llvm::SmallVector<ObjcDeclSpec, 12> ArgTypeQuals;
   llvm::SmallVector<IdentifierInfo *, 12> ArgNames;
   
   Action::TypeTy *TypeInfo;
@@ -564,11 +565,14 @@ Parser::DeclTy *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
       break;
     }
     ConsumeToken(); // Eat the ':'.
-    if (Tok.is(tok::l_paren)) // Parse the argument type.
-      TypeInfo = ParseObjCTypeName();
+    ObjcDeclSpec DSType;
+    if (Tok.is(tok::l_paren))  { // Parse the argument type.
+      TypeInfo = ParseObjCTypeName(DSType);
+    }
     else
       TypeInfo = 0;
     KeyTypes.push_back(TypeInfo);
+    ArgTypeQuals.push_back(DSType);
     
     // If attributes exist before the argument name, parse them.
     if (getLang().ObjC2 && Tok.is(tok::kw___attribute))
@@ -613,8 +617,9 @@ Parser::DeclTy *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
   Selector Sel = PP.getSelectorTable().getSelector(KeyIdents.size(),
                                                    &KeyIdents[0]);
   return Actions.ActOnMethodDeclaration(mLoc, Tok.getLocation(),
-                                        mType, ReturnType, Sel, 
-                                        &KeyTypes[0], &ArgNames[0],
+                                        mType, DSRet, ReturnType, Sel, 
+                                        &ArgTypeQuals[0], &KeyTypes[0], 
+                                        &ArgNames[0],
                                         MethodAttrs, MethodImplKind);
 }
 
index 32ab40d71f3d50f5e44ac1dc787ca167bbbdc252..0df8644178a87f23c88d8ef7dadf468b503af20b 100644 (file)
@@ -524,10 +524,11 @@ public:
   virtual DeclTy *ActOnMethodDeclaration(
     SourceLocation BeginLoc, // location of the + or -.
     SourceLocation EndLoc,   // location of the ; or {.
-    tok::TokenKind MethodType, TypeTy *ReturnType, Selector Sel,
+    tok::TokenKind MethodType, ObjcDeclSpec &ReturnQT, TypeTy *ReturnType, 
+    Selector Sel,
     // optional arguments. The number of types/arguments is obtained
     // from the Sel.getNumArgs().
-    TypeTy **ArgTypes, IdentifierInfo **ArgNames,
+    ObjcDeclSpec *ArgQT, TypeTy **ArgTypes, IdentifierInfo **ArgNames,
     AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind);
 
   // ActOnClassMessage - used for both unary and keyword messages.
index 66ece4149acad663d354b89350285e99156071e9..0d993b8fccc779d3e03e29c9810a342a2cc0cda5 100644 (file)
@@ -1288,6 +1288,9 @@ void Sema::CheckImplementationIvars(ObjcImplementationDecl *ImpDecl,
     IDecl->addInstanceVariablesToClass(ivars, numIvars, RBrace);
     return;
   }
+  // If implementation has empty ivar list, just return.
+  if (numIvars == 0)
+    return;
   
   assert(ivars && "missing @implementation ivars");
   
@@ -1967,10 +1970,11 @@ void Sema::ActOnAddMethodsToObjcDecl(Scope* S, DeclTy *classDecl,
 
 Sema::DeclTy *Sema::ActOnMethodDeclaration(
     SourceLocation MethodLoc, SourceLocation EndLoc,
-    tok::TokenKind MethodType, TypeTy *ReturnType, Selector Sel,
+    tok::TokenKind MethodType, ObjcDeclSpec &ReturnQT, TypeTy *ReturnType,
+    Selector Sel,
     // optional arguments. The number of types/arguments is obtained
     // from the Sel.getNumArgs().
-    TypeTy **ArgTypes, IdentifierInfo **ArgNames,
+    ObjcDeclSpec *ArgQT, TypeTy **ArgTypes, IdentifierInfo **ArgNames,
     AttributeList *AttrList, tok::ObjCKeywordKind MethodDeclKind) {
   llvm::SmallVector<ParmVarDecl*, 16> Params;
   
index 32025eaa01ee92e2d7af669b3de255bbd6cdaf20..0be53afda894b6e04ee702b5660c11287a89f315 100644 (file)
@@ -21,6 +21,7 @@
 namespace clang {
   // Semantic.
   class DeclSpec;
+  class ObjcDeclSpec;
   class Declarator;
   class AttributeList;
   // Parse.
@@ -529,8 +530,10 @@ public:
     SourceLocation BeginLoc,   // location of the + or -.
     SourceLocation EndLoc,     // location of the ; or {.
     tok::TokenKind MethodType, // tok::minus for instance, tok::plus for class.
+    ObjcDeclSpec &ReturnQT,    // for return type's in inout etc.
     TypeTy *ReturnType,        // the method return type.
     Selector Sel,              // a unique name for the method.
+    ObjcDeclSpec *ArgQT,       // for arguments' in inout etc.
     TypeTy **ArgTypes,         // non-zero when Sel.getNumArgs() > 0
     IdentifierInfo **ArgNames, // non-zero when Sel.getNumArgs() > 0
     AttributeList *AttrList,   // optional
index 0a5295cedbcd469491a952693a42e85c1ce10143..1345fe99dd5eacf8bda3aa7a48bd7b06a224d1bd 100644 (file)
@@ -293,7 +293,7 @@ private:
   IdentifierInfo *ObjcPropertyAttrs[objc_NumAttrs];
   bool isObjCPropertyAttribute();
 
-  TypeTy *ParseObjCTypeName();
+  TypeTy *ParseObjCTypeName(ObjcDeclSpec &DS);
   void ParseObjCMethodRequirement();
   DeclTy *ParseObjCMethodPrototype(DeclTy *classOrCat,
            tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword);