[cfe-commits] r68876 - in /cfe/trunk/lib/Sema: SemaDecl.cpp SemaDeclObjC.cpp

Chris Lattner sabre at nondot.org
Sat Apr 11 12:34:56 PDT 2009


Author: lattner
Date: Sat Apr 11 14:34:56 2009
New Revision: 68876

URL: http://llvm.org/viewvc/llvm-project?rev=68876&view=rev
Log:
simplify code to use adjustParameterType, apply objc arg attributes
to their arguments.


Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Apr 11 14:34:56 2009
@@ -2704,12 +2704,6 @@
   if (D.getInvalidType())
     New->setInvalidDecl();
 
-  // Parameter declarators cannot be qualified (C++ [dcl.meaning]p1).
-  if (D.getCXXScopeSpec().isSet()) {
-    Diag(D.getIdentifierLoc(), diag::err_qualified_param_declarator)
-      << D.getCXXScopeSpec().getRange();
-    New->setInvalidDecl();
-  }
   // Parameter declarators cannot be interface types. All ObjC objects are
   // passed by reference.
   if (T->isObjCInterfaceType()) {
@@ -2717,6 +2711,13 @@
          diag::err_object_cannot_be_passed_returned_by_value) << 1 << T;
     New->setInvalidDecl();
   }
+  
+  // Parameter declarators cannot be qualified (C++ [dcl.meaning]p1).
+  if (D.getCXXScopeSpec().isSet()) {
+    Diag(D.getIdentifierLoc(), diag::err_qualified_param_declarator)
+      << D.getCXXScopeSpec().getRange();
+    New->setInvalidDecl();
+  }
 
   // Add the parameter declaration into this scope.
   S->AddDecl(DeclPtrTy::make(New));

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sat Apr 11 14:34:56 2009
@@ -1400,8 +1400,6 @@
     bool isVariadic) {
   Decl *ClassDecl = classDecl.getAs<Decl>();
 
-  // FIXME: Param attributes.
-  
   // Make sure we can establish a context for the method.
   if (!ClassDecl) {
     Diag(MethodLoc, diag::error_missing_method_context);
@@ -1442,17 +1440,7 @@
     } else {
       UnpromotedArgType = ArgType = QualType::getFromOpaquePtr(ArgInfo[i].Type);
       // Perform the default array/function conversions (C99 6.7.5.3p[7,8]).
-      if (ArgType->isArrayType())  { // (char *[]) -> (char **)
-        ArgType = Context.getArrayDecayedType(ArgType);
-      } else if (ArgType->isFunctionType())
-        ArgType = Context.getPointerType(ArgType);
-      else if (ArgType->isObjCInterfaceType()) {
-        Diag(ArgInfo[i].NameLoc,
-             diag::err_object_cannot_be_passed_returned_by_value)
-           << 1 << ArgType;
-        ObjCMethod->setInvalidDecl();
-        return DeclPtrTy();
-      }
+      ArgType = adjustParameterType(ArgType);
     }
     
     ParmVarDecl* Param;
@@ -1468,8 +1456,19 @@
                                           UnpromotedArgType,
                                           VarDecl::None, 0);
     
+    if (ArgType->isObjCInterfaceType()) {
+      Diag(ArgInfo[i].NameLoc,
+           diag::err_object_cannot_be_passed_returned_by_value)
+        << 1 << ArgType;
+      Param->setInvalidDecl();
+    }
+    
     Param->setObjCDeclQualifier(
       CvtQTToAstBitMask(ArgInfo[i].DeclSpec.getObjCDeclQualifier()));
+    
+    // Apply the attributes to the parameter.
+    ProcessDeclAttributeList(Param, ArgInfo[i].ArgAttrs);
+    
     Params.push_back(Param);
   }
 





More information about the cfe-commits mailing list