summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCall.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-07-20 06:29:00 +0000
committerChris Lattner <sabre@nondot.org>2011-07-20 06:29:00 +0000
commit7369c14b6a43fae392473289e389ceb2be40f779 (patch)
treeb600ae5e4219196cafbcb54b3ac172cf46fdf587 /clang/lib/CodeGen/CGCall.cpp
parent58c62473cd6921f83cc232db0d556ba9cb531e22 (diff)
downloadbcm5719-llvm-7369c14b6a43fae392473289e389ceb2be40f779.tar.gz
bcm5719-llvm-7369c14b6a43fae392473289e389ceb2be40f779.zip
fix rdar://9780211 - Clang crashes with an assertion failure building WKView.mm from WebKit
This is something of a hack, the problem is as follows: 1. we instantiate both copied of RetainPtr with the two different argument types (an id and protocol-qualified id). 2. We refer to the ctor of one of the instantiations when introducing global "x", this causes us to emit an llvm::Function for a prototype whose "this" has type "RetainPtr<id<bork> >*". 3. We refer to the ctor of the other instantiation when introducing global "y", however, because it *mangles to the same name as the other ctor* we just use a bitcasted version of the llvm::Function we previously emitted. 4. We emit deferred declarations, causing us to emit the body of the ctor, however the body we emit is for RetainPtr<id>, which expects its 'this' to have an IR type of "RetainPtr<id>*". Because of the mangling collision, we don't have this case, and explode. This is really some sort of weird AST invariant violation or something, but hey a bitcast makes the pain go away. llvm-svn: 135572
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
-rw-r--r--clang/lib/CodeGen/CGCall.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index d2ad5dc887d..e3b93a3f458 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -954,9 +954,13 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
if (Arg->getType().isRestrictQualified())
AI->addAttr(llvm::Attribute::NoAlias);
+ // Ensure the argument is the correct type.
+ if (V->getType() != ArgI.getCoerceToType())
+ V = Builder.CreateBitCast(V, ArgI.getCoerceToType());
+
if (isPromoted)
V = emitArgumentDemotion(*this, Arg, V);
-
+
EmitParmDecl(*Arg, V, ArgNo);
break;
}
OpenPOWER on IntegriCloud