[cfe-commits] r68583 - in /cfe/trunk: lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGCall.cpp lib/CodeGen/CodeGenTypes.h test/CodeGen/blocks.c
Anders Carlsson
andersca at mac.com
Tue Apr 7 19:56:10 PDT 2009
Author: andersca
Date: Tue Apr 7 21:55:55 2009
New Revision: 68583
URL: http://llvm.org/viewvc/llvm-project?rev=68583&view=rev
Log:
Don't assume that a block always has a FunctionProtoType. Fixes rdar://6768379.
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.h
cfe/trunk/test/CodeGen/blocks.c
Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=68583&r1=68582&r2=68583&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue Apr 7 21:55:55 2009
@@ -444,13 +444,15 @@
// Load the function.
llvm::Value *Func = Builder.CreateLoad(FuncPtr, false, "tmp");
- const CGFunctionInfo &FnInfo = CGM.getTypes().getFunctionInfo(BPT);
- bool IsVariadic =
- BPT->getPointeeType()->getAsFunctionProtoType()->isVariadic();
+ QualType FnType = BPT->getPointeeType();
+ QualType ResultType = FnType->getAsFunctionType()->getResultType();
+
+ const CGFunctionInfo &FnInfo =
+ CGM.getTypes().getFunctionInfo(ResultType, Args);
// Cast the function pointer to the right type.
const llvm::Type *BlockFTy =
- CGM.getTypes().GetFunctionType(FnInfo, IsVariadic);
+ CGM.getTypes().GetFunctionType(FnInfo, false);
const llvm::Type *BlockFTyPtr = llvm::PointerType::getUnqual(BlockFTy);
Func = Builder.CreateBitCast(Func, BlockFTyPtr);
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=68583&r1=68582&r2=68583&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Apr 7 21:55:55 2009
@@ -53,19 +53,6 @@
return getFunctionInfo(FTP->getResultType(), ArgTys);
}
-const
-CGFunctionInfo &CodeGenTypes::getFunctionInfo(const BlockPointerType *BPT) {
- llvm::SmallVector<QualType, 16> ArgTys;
- const FunctionProtoType *FTP =
- BPT->getPointeeType()->getAsFunctionProtoType();
-
- // Add the block pointer.
- ArgTys.push_back(Context.getPointerType(Context.VoidTy));
- for (unsigned i = 0, e = FTP->getNumArgs(); i != e; ++i)
- ArgTys.push_back(FTP->getArgType(i));
- return getFunctionInfo(FTP->getResultType(), ArgTys);
-}
-
const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const CXXMethodDecl *MD) {
llvm::SmallVector<QualType, 16> ArgTys;
// Add the 'this' pointer.
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.h?rev=68583&r1=68582&r2=68583&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.h Tue Apr 7 21:55:55 2009
@@ -172,11 +172,9 @@
const CGFunctionInfo &getFunctionInfo(const FunctionNoProtoType *FTNP);
const CGFunctionInfo &getFunctionInfo(const FunctionProtoType *FTP);
- const CGFunctionInfo &getFunctionInfo(const BlockPointerType *BPT);
const CGFunctionInfo &getFunctionInfo(const FunctionDecl *FD);
const CGFunctionInfo &getFunctionInfo(const CXXMethodDecl *MD);
const CGFunctionInfo &getFunctionInfo(const ObjCMethodDecl *MD);
-//private:
const CGFunctionInfo &getFunctionInfo(QualType ResTy,
const CallArgList &Args);
public:
Modified: cfe/trunk/test/CodeGen/blocks.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/blocks.c?rev=68583&r1=68582&r2=68583&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/blocks.c (original)
+++ cfe/trunk/test/CodeGen/blocks.c Tue Apr 7 21:55:55 2009
@@ -1,2 +1,7 @@
// RUN: clang-cc %s -emit-llvm -o %t -fblocks
void (^f)(void) = ^{};
+
+// rdar://6768379
+int f0(int (^a0)()) {
+ return a0(1, 2, 3);
+}
More information about the cfe-commits
mailing list