[cfe-commits] r56768 - in /cfe/trunk: lib/AST/Builtins.cpp test/Sema/builtin-object-size.c

Chris Lattner sabre at nondot.org
Sat Sep 27 23:05:36 PDT 2008


Author: lattner
Date: Sun Sep 28 01:05:35 2008
New Revision: 56768

URL: http://llvm.org/viewvc/llvm-project?rev=56768&view=rev
Log:
Fix rdar://6252231 - cannot call vsnprintf with va_list on x86_64,
by decaying __builtin_va_list's type when forming builtins.  On
x86-64 (and other targets) __builtin_va_list is a typedef for
an array.

Modified:
    cfe/trunk/lib/AST/Builtins.cpp
    cfe/trunk/test/Sema/builtin-object-size.c

Modified: cfe/trunk/lib/AST/Builtins.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Builtins.cpp?rev=56768&r1=56767&r2=56768&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Builtins.cpp (original)
+++ cfe/trunk/lib/AST/Builtins.cpp Sun Sep 28 01:05:35 2008
@@ -137,6 +137,9 @@
   case 'a':
     Type = Context.getBuiltinVaListType();
     assert(!Type.isNull() && "builtin va list type not initialized!");
+    // Do array -> pointer decay.  The builtin should use the decayed type.
+    if (Type->isArrayType())
+      Type = Context.getArrayDecayedType(Type);
     break;
   case 'V': {
     char *End;

Modified: cfe/trunk/test/Sema/builtin-object-size.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtin-object-size.c?rev=56768&r1=56767&r2=56768&view=diff

==============================================================================
--- cfe/trunk/test/Sema/builtin-object-size.c (original)
+++ cfe/trunk/test/Sema/builtin-object-size.c Sun Sep 28 01:05:35 2008
@@ -1,4 +1,5 @@
 // RUN: clang -fsyntax-only -verify %s
+// RUN: clang -fsyntax-only -triple x86_64-apple-darwin9 -verify %s
 
 int a[10];
 
@@ -17,3 +18,11 @@
 int f3() {
   return __builtin_object_size(&a, 4); // expected-error {{argument should be a value from 0 to 3}}
 }
+
+
+// rdar://6252231 - cannot call vsnprintf with va_list on x86_64
+void f4(const char *fmt, ...) {
+ __builtin_va_list args;
+ __builtin___vsnprintf_chk (0, 42, 0, 11, fmt, args);
+}
+





More information about the cfe-commits mailing list