Skip to content

Commit 859d416

Browse files
committed
Merge 98264 from mainline.
fix PR6433, crash on va_arg of typedef. llvm-svn: 98310
1 parent 93d8c22 commit 859d416

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

clang/lib/CodeGen/TargetInfo.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,15 @@ llvm::Value *DefaultABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
268268
ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty,
269269
ASTContext &Context,
270270
llvm::LLVMContext &VMContext) const {
271-
if (CodeGenFunction::hasAggregateLLVMType(Ty)) {
271+
if (CodeGenFunction::hasAggregateLLVMType(Ty))
272272
return ABIArgInfo::getIndirect(0);
273-
} else {
274-
// Treat an enum type as its underlying type.
275-
if (const EnumType *EnumTy = Ty->getAs<EnumType>())
276-
Ty = EnumTy->getDecl()->getIntegerType();
273+
274+
// Treat an enum type as its underlying type.
275+
if (const EnumType *EnumTy = Ty->getAs<EnumType>())
276+
Ty = EnumTy->getDecl()->getIntegerType();
277277

278-
return (Ty->isPromotableIntegerType() ?
279-
ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
280-
}
278+
return (Ty->isPromotableIntegerType() ?
279+
ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
281280
}
282281

283282
/// X86_32ABIInfo - The X86-32 ABI information.
@@ -1367,6 +1366,8 @@ llvm::Value *X86_64ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
13671366
// i8* reg_save_area;
13681367
// };
13691368
unsigned neededInt, neededSSE;
1369+
1370+
Ty = CGF.getContext().getCanonicalType(Ty);
13701371
ABIArgInfo AI = classifyArgumentType(Ty, CGF.getContext(), VMContext,
13711372
neededInt, neededSSE);
13721373

clang/test/CodeGen/varargs.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clang_cc1 -emit-llvm -o - %s
2+
3+
4+
// PR6433 - Don't crash on va_arg(typedef).
5+
typedef double gdouble;
6+
void focus_changed_cb () {
7+
__builtin_va_list pa;
8+
double mfloat;
9+
mfloat = __builtin_va_arg((pa), gdouble);
10+
}
11+

0 commit comments

Comments
 (0)