]> granicus.if.org Git - clang/commitdiff
Fix for PR5709: use the computed type of the declaration instead of the
authorEli Friedman <eli.friedman@gmail.com>
Wed, 9 Dec 2009 03:05:59 +0000 (03:05 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Wed, 9 Dec 2009 03:05:59 +0000 (03:05 +0000)
type of the builtin when generating the function declaration for a builtin
library call.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90936 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.cpp
test/CodeGen/vfprintf.c [new file with mode: 0644]

index a063e21307c85adf8bfe3eadeb89ba67ba846b7f..e98939cc8f47c552e1105855636b72f596f63a41 100644 (file)
@@ -1253,13 +1253,8 @@ llvm::Value *CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD,
   if (Context.BuiltinInfo.isLibFunction(BuiltinID))
     Name += 10;
 
-  // Get the type for the builtin.
-  ASTContext::GetBuiltinTypeError Error;
-  QualType Type = Context.GetBuiltinType(BuiltinID, Error);
-  assert(Error == ASTContext::GE_None && "Can't get builtin type");
-
   const llvm::FunctionType *Ty =
-    cast<llvm::FunctionType>(getTypes().ConvertType(Type));
+    cast<llvm::FunctionType>(getTypes().ConvertType(FD->getType()));
 
   // Unique the name through the identifier table.
   Name = getContext().Idents.get(Name).getNameStart();
diff --git a/test/CodeGen/vfprintf.c b/test/CodeGen/vfprintf.c
new file mode 100644 (file)
index 0000000..89261c7
--- /dev/null
@@ -0,0 +1,8 @@
+// RUN: clang-cc -emit-llvm-only %s
+
+typedef struct _IO_FILE FILE;
+int vfprintf(FILE*restrict,const char*restrict, __builtin_va_list);
+void foo(__builtin_va_list ap) {
+  vfprintf(0, " ", ap);
+}
+