[cfe-commits] r51960 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGen/typedef-func.c
Eli Friedman
eli.friedman at gmail.com
Wed Jun 4 12:41:28 PDT 2008
Author: efriedma
Date: Wed Jun 4 14:41:28 2008
New Revision: 51960
URL: http://llvm.org/viewvc/llvm-project?rev=51960&view=rev
Log:
For setting attributes, don't assume there are ParamVarDecls available,
because trying to access non-existent ParamVarDecls can crash.
Testcase from the original source for PR2414.
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGen/typedef-func.c
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=51960&r1=51959&r2=51960&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Jun 4 14:41:28 2008
@@ -206,19 +206,23 @@
ParamAttrList.push_back(
llvm::ParamAttrsWithIndex::get(1, llvm::ParamAttr::StructRet));
unsigned increment = AggregateReturn ? 2 : 1;
- for (unsigned i = 0; i < FD->getNumParams(); i++) {
- QualType ParamType = FD->getParamDecl(i)->getType();
- unsigned ParamAttrs = 0;
- if (ParamType->isRecordType())
- ParamAttrs |= llvm::ParamAttr::ByVal;
- if (ParamType->isSignedIntegerType() && ParamType->isPromotableIntegerType())
- ParamAttrs |= llvm::ParamAttr::SExt;
- if (ParamType->isUnsignedIntegerType() && ParamType->isPromotableIntegerType())
- ParamAttrs |= llvm::ParamAttr::ZExt;
- if (ParamAttrs)
- ParamAttrList.push_back(llvm::ParamAttrsWithIndex::get(i + increment,
- ParamAttrs));
+ const FunctionTypeProto* FTP = dyn_cast<FunctionTypeProto>(FD->getType());
+ if (FTP) {
+ for (unsigned i = 0; i < FTP->getNumArgs(); i++) {
+ QualType ParamType = FTP->getArgType(i);
+ unsigned ParamAttrs = 0;
+ if (ParamType->isRecordType())
+ ParamAttrs |= llvm::ParamAttr::ByVal;
+ if (ParamType->isSignedIntegerType() && ParamType->isPromotableIntegerType())
+ ParamAttrs |= llvm::ParamAttr::SExt;
+ if (ParamType->isUnsignedIntegerType() && ParamType->isPromotableIntegerType())
+ ParamAttrs |= llvm::ParamAttr::ZExt;
+ if (ParamAttrs)
+ ParamAttrList.push_back(llvm::ParamAttrsWithIndex::get(i + increment,
+ ParamAttrs));
+ }
}
+
F->setParamAttrs(llvm::PAListPtr::get(ParamAttrList.begin(),
ParamAttrList.size()));
Modified: cfe/trunk/test/CodeGen/typedef-func.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/typedef-func.c?rev=51960&r1=51959&r2=51960&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/typedef-func.c (original)
+++ cfe/trunk/test/CodeGen/typedef-func.c Wed Jun 4 14:41:28 2008
@@ -1,13 +1,16 @@
// RUN: clang -emit-llvm < %s
// PR2414
-typedef void filter_func_t();
+struct mad_frame{};
+enum mad_flow {};
+
+typedef enum mad_flow filter_func_t(void *, struct mad_frame *);
+
filter_func_t mono_filter;
void addfilter2(filter_func_t *func){}
void setup_filters()
{
- addfilter2( mono_filter);
+ addfilter2( mono_filter);
}
-
More information about the cfe-commits
mailing list