[cfe-commits] r98264 - in /cfe/trunk: lib/CodeGen/TargetInfo.cpp test/CodeGen/varargs.c

Chris Lattner sabre at nondot.org
Thu Mar 11 10:19:55 PST 2010


Author: lattner
Date: Thu Mar 11 12:19:55 2010
New Revision: 98264

URL: http://llvm.org/viewvc/llvm-project?rev=98264&view=rev
Log:
fix PR6433, crash on va_arg of typedef.

Added:
    cfe/trunk/test/CodeGen/varargs.c
Modified:
    cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=98264&r1=98263&r2=98264&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Mar 11 12:19:55 2010
@@ -268,16 +268,15 @@
 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 @@
   //   i8* reg_save_area;
   // };
   unsigned neededInt, neededSSE;
+  
+  Ty = CGF.getContext().getCanonicalType(Ty);
   ABIArgInfo AI = classifyArgumentType(Ty, CGF.getContext(), VMContext,
                                        neededInt, neededSSE);
 

Added: cfe/trunk/test/CodeGen/varargs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/varargs.c?rev=98264&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/varargs.c (added)
+++ cfe/trunk/test/CodeGen/varargs.c Thu Mar 11 12:19:55 2010
@@ -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);
+}
+





More information about the cfe-commits mailing list