From: Eli Friedman Date: Wed, 9 Dec 2009 03:05:59 +0000 (+0000) Subject: Fix for PR5709: use the computed type of the declaration instead of the X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=386ca78d0b03b1fb519e60d1a14cd12a220364a6;p=clang Fix for PR5709: use the computed type of the declaration instead of the 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 --- diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index a063e21307..e98939cc8f 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -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(getTypes().ConvertType(Type)); + cast(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 index 0000000000..89261c7469 --- /dev/null +++ b/test/CodeGen/vfprintf.c @@ -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); +} +