From: Eli Friedman Date: Wed, 4 Mar 2009 04:25:14 +0000 (+0000) Subject: Continuation of PR3687: fix more places to use the right type for X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a3460ac8a17bd82fc21db9ff8db7c7efcb5bb1a9;p=clang Continuation of PR3687: fix more places to use the right type for booleans. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66012 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 3a4ef95350..9cdb40b121 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -232,7 +232,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { if (Ty->isConstantSizeType()) { if (!Target.useGlobalsForAutomaticVariables()) { // A normal fixed sized variable becomes an alloca in the entry block. - const llvm::Type *LTy = ConvertType(Ty); + const llvm::Type *LTy = ConvertTypeForMem(Ty); if (isByRef) LTy = BuildByRefType(Ty, getContext().getDeclAlignInBytes(&D)); llvm::AllocaInst *Alloc = @@ -278,7 +278,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { } // Get the element type. - const llvm::Type *LElemTy = ConvertType(Ty); + const llvm::Type *LElemTy = ConvertTypeForMem(Ty); const llvm::Type *LElemPtrTy = llvm::PointerType::get(LElemTy, D.getType().getAddressSpace()); @@ -318,7 +318,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { } if (!hasAggregateLLVMType(Init->getType())) { llvm::Value *V = EmitScalarExpr(Init); - Builder.CreateStore(V, Loc, D.getType().isVolatileQualified()); + EmitStoreOfScalar(V, Loc, D.getType().isVolatileQualified()); } else if (Init->getType()->isAnyComplexType()) { EmitComplexExprIntoAddr(Init, Loc, D.getType().isVolatileQualified()); } else { @@ -410,7 +410,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg) { llvm::GlobalValue::ExternalLinkage); } else { // A fixed sized single-value variable becomes an alloca in the entry block. - const llvm::Type *LTy = ConvertType(Ty); + const llvm::Type *LTy = ConvertTypeForMem(Ty); if (LTy->isSingleValueType()) { // TODO: Alignment std::string Name = D.getNameAsString(); @@ -418,7 +418,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg) { DeclPtr = CreateTempAlloca(LTy, Name.c_str()); // Store the initial value into the alloca. - Builder.CreateStore(Arg, DeclPtr,Ty.isVolatileQualified()); + EmitStoreOfScalar(Arg, DeclPtr, Ty.isVolatileQualified()); } else { // Otherwise, if this is an aggregate, just use the input pointer. DeclPtr = Arg; diff --git a/test/CodeGen/bool-convert.c b/test/CodeGen/bool-convert.c index 8d801c3cf2..5e8bae1a93 100644 --- a/test/CodeGen/bool-convert.c +++ b/test/CodeGen/bool-convert.c @@ -4,4 +4,7 @@ struct teststruct1 {_Bool a, b;} test1; _Bool* test2; _Bool test3[10]; _Bool (*test4)[]; - +void f(int x) { + _Bool test5; + _Bool test6[x]; +}