aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r--lib/CodeGen/CGDecl.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index 0a1d1d0bd1..15f1e1d431 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -405,11 +405,22 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
CleanupScope scope(*this);
+ const CGFunctionInfo &Info = CGM.getTypes().getFunctionInfo(FD);
+
+ // In some cases, the type of the function argument will be different from
+ // the type of the pointer. An example of this is
+ // void f(void* arg);
+ // __attribute__((cleanup(f))) void *g;
+ //
+ // To fix this we insert a bitcast here.
+ QualType ArgTy = Info.arg_begin()->type;
+ DeclPtr = Builder.CreateBitCast(DeclPtr, ConvertType(ArgTy));
+
CallArgList Args;
Args.push_back(std::make_pair(RValue::get(DeclPtr),
getContext().getPointerType(D.getType())));
-
- EmitCall(CGM.getTypes().getFunctionInfo(FD), F, Args);
+
+ EmitCall(Info, F, Args);
}
if (needsDispose && CGM.getLangOptions().getGCMode() != LangOptions::GCOnly) {