[cfe-commits] r56080 - in /cfe/trunk/lib: CodeGen/CGCall.cpp Sema/SemaExprObjC.cpp
Daniel Dunbar
daniel at zuster.org
Wed Sep 10 17:04:37 PDT 2008
Author: ddunbar
Date: Wed Sep 10 19:04:36 2008
New Revision: 56080
URL: http://llvm.org/viewvc/llvm-project?rev=56080&view=rev
Log:
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.
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=56080&r1=56079&r2=56080&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Sep 10 19:04:36 2008
@@ -136,6 +136,8 @@
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 @@
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 @@
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()) {
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=56080&r1=56079&r2=56080&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed Sep 10 19:04:36 2008
@@ -114,6 +114,10 @@
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();
More information about the cfe-commits
mailing list