From: Daniel Dunbar Date: Thu, 11 Sep 2008 00:04:36 +0000 (+0000) Subject: Bug fix, apply default argument promotion in message sends for which X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6660c8a4cc2115929d92be83bbc54c307002a321;p=clang Bug fix, apply default argument promotion in message sends for which no method declaration was found. - This was allowing arrays to pass "by value" among other things. Add assert in CodeGen that arguments cannot have array type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56080 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index bbe43703cb..b4eaff8385 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -136,6 +136,8 @@ public: static ABIArgInfo classifyReturnType(QualType RetTy, ASTContext &Context) { + assert(!RetTy->isArrayType() && + "Array types cannot be passed directly."); if (CodeGenFunction::hasAggregateLLVMType(RetTy)) { uint64_t Size = Context.getTypeSize(RetTy); if (Size == 8) { @@ -198,6 +200,8 @@ CodeGenTypes::GetFunctionType(ArgTypeIterator begin, ArgTypeIterator end, for (++begin; begin != end; ++begin) { const llvm::Type *Ty = ConvertType(*begin); + assert(!(*begin)->isArrayType() && + "Array types cannot be passed directly."); if (Ty->isSingleValueType()) ArgTys.push_back(Ty); else @@ -254,6 +258,8 @@ void CodeGenModule::ConstructParamAttrList(const Decl *TargetDecl, for (++begin; begin != end; ++begin, ++Index) { QualType ParamType = *begin; unsigned ParamAttrs = 0; + assert(!ParamType->isArrayType() && + "Array types cannot be passed directly."); if (ParamType->isRecordType()) ParamAttrs |= llvm::ParamAttr::ByVal; if (ParamType->isPromotableIntegerType()) { diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 0d3bc29840..08177e6769 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -114,6 +114,10 @@ bool Sema::CheckMessageArgumentTypes(Expr **Args, Selector Sel, QualType &ReturnType) { unsigned NumArgs = Sel.getNumArgs(); if (!Method) { + // Apply default argument promotion as for (C99 6.5.2.2p6). + for (unsigned i = 0; i != NumArgs; i++) + DefaultArgumentPromotion(Args[i]); + Diag(lbrac, diag::warn_method_not_found, std::string(PrefixStr), Sel.getName(), SourceRange(lbrac, rbrac)); ReturnType = Context.getObjCIdType();