From: Chris Lattner Date: Sat, 11 Apr 2009 19:34:56 +0000 (+0000) Subject: simplify code to use adjustParameterType, apply objc arg attributes X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f97e8fa2966e3e49eac433336450f24ccbdf8b4a;p=clang simplify code to use adjustParameterType, apply objc arg attributes to their arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68876 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index d3f24cae90..278d8ecd90 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2704,12 +2704,6 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { 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 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { 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)); diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 7d4e6026a1..142a5305d4 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -1400,8 +1400,6 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration( bool isVariadic) { Decl *ClassDecl = classDecl.getAs(); - // 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 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration( } 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 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration( 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); }