summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2010-03-12 00:05:05 +0000
committerTanya Lattner <tonic@nondot.org>2010-03-12 00:05:05 +0000
commit859d4167a0408558ed6a7799a1e2d46dafa9610d (patch)
treeca20a5f1b5a7437dd5673b5e34fb0882f9d3d124
parent93d8c226089e5370e3fd2759fade0a3e8b329972 (diff)
downloadllvm-859d4167a0408558ed6a7799a1e2d46dafa9610d.tar.gz
Merge 98264 from mainline.
fix PR6433, crash on va_arg of typedef. llvm-svn: 98310
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp17
-rw-r--r--clang/test/CodeGen/varargs.c11
2 files changed, 20 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index cb6a7df68d45..45714dfdb8b2 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -268,16 +268,15 @@ llvm::Value *DefaultABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty,
ASTContext &Context,
llvm::LLVMContext &VMContext) const {
- if (CodeGenFunction::hasAggregateLLVMType(Ty)) {
+ if (CodeGenFunction::hasAggregateLLVMType(Ty))
return ABIArgInfo::getIndirect(0);
- } else {
- // Treat an enum type as its underlying type.
- if (const EnumType *EnumTy = Ty->getAs<EnumType>())
- Ty = EnumTy->getDecl()->getIntegerType();
+
+ // Treat an enum type as its underlying type.
+ if (const EnumType *EnumTy = Ty->getAs<EnumType>())
+ Ty = EnumTy->getDecl()->getIntegerType();
- return (Ty->isPromotableIntegerType() ?
- ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
- }
+ return (Ty->isPromotableIntegerType() ?
+ ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
}
/// X86_32ABIInfo - The X86-32 ABI information.
@@ -1367,6 +1366,8 @@ llvm::Value *X86_64ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
// i8* reg_save_area;
// };
unsigned neededInt, neededSSE;
+
+ Ty = CGF.getContext().getCanonicalType(Ty);
ABIArgInfo AI = classifyArgumentType(Ty, CGF.getContext(), VMContext,
neededInt, neededSSE);
diff --git a/clang/test/CodeGen/varargs.c b/clang/test/CodeGen/varargs.c
new file mode 100644
index 000000000000..b3dba240b559
--- /dev/null
+++ b/clang/test/CodeGen/varargs.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s
+
+
+// PR6433 - Don't crash on va_arg(typedef).
+typedef double gdouble;
+void focus_changed_cb () {
+ __builtin_va_list pa;
+ double mfloat;
+ mfloat = __builtin_va_arg((pa), gdouble);
+}
+