[cfe-commits] r113015 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/SemaCXX/blocks.cpp
Douglas Gregor
dgregor at apple.com
Fri Sep 3 14:48:51 PDT 2010
On Sep 3, 2010, at 2:36 PM, Fariborz Jahanian wrote:
> Author: fjahanian
> Date: Fri Sep 3 16:36:02 2010
> New Revision: 113015
>
> URL: http://llvm.org/viewvc/llvm-project?rev=113015&view=rev
> Log:
> Cope with llvm's reference to bool type of 'i1' vs. clang's
> type of 'i8' for the same for __block variables of
> type bool. refixes radar 8382559.
>
> Modified:
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/test/SemaCXX/blocks.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=113015&r1=113014&r2=113015&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Sep 3 16:36:02 2010
> @@ -335,6 +335,23 @@
> llvm::Value *Value = EmitExprForReferenceBinding(*this, E, ReferenceTemporary,
> ReferenceTemporaryDtor,
> InitializedDecl);
> + if (E->getType()->isBooleanType()) {
> + // special handling for __block variable of bool type bound to
> + // a reference type.
> + bool block_byref_var = false;
> + if (const BlockDeclRefExpr *BE = dyn_cast<BlockDeclRefExpr>(E))
> + block_byref_var = BE->isByRef();
> + else if (const DeclRefExpr *BD = dyn_cast<DeclRefExpr>(E)) {
> + const NamedDecl *ND = BD->getDecl();
> + if (const VarDecl *VD = dyn_cast<VarDecl>(ND))
> + block_byref_var = VD->hasAttr<BlocksAttr>();
> + }
> + if (block_byref_var) {
> + const llvm::Type *T = ConvertTypeForMem(E->getType());
> + T = llvm::PointerType::getUnqual(T);
> + Value = Builder.CreateBitCast(Value, T);
> + }
> + }
I'm really uncomfortable with this change. EmitExprForReferenceBinding needs to be doing the right thing for block references of bool type, and adding this code here feels like a workaround.
- Doug
More information about the cfe-commits
mailing list