From 0b308ad34ffb29e508b681b155696f8f999532bb Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Thu, 4 Jun 2009 19:35:30 +0000 Subject: [PATCH] Clean up builtin lists, add a few new builtins. (I re-sorted the string.h builtins to be in the same order as the list in the C99 standard.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72882 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Builtins.def | 27 ++++++++++++++++++++------- test/Analysis/ptr-arith.c | 2 +- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/include/clang/AST/Builtins.def b/include/clang/AST/Builtins.def index 11f3264faa..1baee6ddd8 100644 --- a/include/clang/AST/Builtins.def +++ b/include/clang/AST/Builtins.def @@ -332,25 +332,31 @@ BUILTIN(__sync_fetch_and_max, "ii*i", "n") BUILTIN(__sync_fetch_and_umin, "UiUi*Ui", "n") BUILTIN(__sync_fetch_and_umax, "UiUi*Ui", "n") -// Builtin library functions -LIBBUILTIN(alloca, "v*z", "f", "stdlib.h") +// C99 library functions +// C99 stdlib.h LIBBUILTIN(calloc, "v*zz", "f", "stdlib.h") LIBBUILTIN(malloc, "v*z", "f", "stdlib.h") LIBBUILTIN(realloc, "v*v*z", "f", "stdlib.h") +// C99 string.h LIBBUILTIN(memcpy, "v*v*vC*z", "f", "string.h") LIBBUILTIN(memmove, "v*v*vC*z", "f", "string.h") -LIBBUILTIN(memset, "v*v*iz", "f", "string.h") +LIBBUILTIN(strcpy, "c*c*cC*", "f", "string.h") +LIBBUILTIN(strncpy, "c*c*cC*z", "f", "string.h") LIBBUILTIN(strcat, "c*c*cC*", "f", "string.h") +LIBBUILTIN(strncat, "c*c*cC*z", "f", "string.h") +LIBBUILTIN(strxfrm, "zc*cC*z", "f", "string.h") +LIBBUILTIN(memchr, "v*vC*iz", "f", "string.h") LIBBUILTIN(strchr, "c*cC*i", "f", "string.h") -LIBBUILTIN(strcpy, "c*c*cC*", "f", "string.h") LIBBUILTIN(strcspn, "zcC*cC*", "f", "string.h") -LIBBUILTIN(strlen, "zcC*", "f", "string.h") -LIBBUILTIN(strncat, "c*c*cC*z", "f", "string.h") -LIBBUILTIN(strncpy, "c*c*cC*z", "f", "string.h") LIBBUILTIN(strpbrk, "c*cC*cC*", "f", "string.h") LIBBUILTIN(strrchr, "c*cC*i", "f", "string.h") LIBBUILTIN(strspn, "zcC*cC*", "f", "string.h") LIBBUILTIN(strstr, "c*cC*cC*", "f", "string.h") +LIBBUILTIN(strtok, "c*c*cC*", "f", "string.h") +LIBBUILTIN(memset, "v*v*iz", "f", "string.h") +LIBBUILTIN(strerror, "c*i", "f", "string.h") +LIBBUILTIN(strlen, "zcC*", "f", "string.h") +// C99 stdio.h LIBBUILTIN(printf, "icC*.", "fp:0:", "stdio.h") LIBBUILTIN(fprintf, "iP*cC*.", "fp:1:", "stdio.h") LIBBUILTIN(snprintf, "ic*zcC*.", "fp:2:", "stdio.h") @@ -360,6 +366,13 @@ LIBBUILTIN(vfprintf, "i.", "fP:1:", "stdio.h") LIBBUILTIN(vsnprintf, "ic*zcC*a", "fP:2:", "stdio.h") LIBBUILTIN(vsprintf, "ic*cC*a", "fP:1:", "stdio.h") +// Non-C library functions +// FIXME: Non-C-standard stuff shouldn't be builtins in non-GNU mode! +LIBBUILTIN(alloca, "v*z", "f", "stdlib.h") +// POSIX strings.h +LIBBUILTIN(index, "c*cC*i", "f", "strings.h") +LIBBUILTIN(rindex, "c*cC*i", "f", "strings.h") + // FIXME: This type isn't very correct, it should be // id objc_msgSend(id, SEL) // but we need new type letters for that. diff --git a/test/Analysis/ptr-arith.c b/test/Analysis/ptr-arith.c index ea8b7f5666..34840c7b7c 100644 --- a/test/Analysis/ptr-arith.c +++ b/test/Analysis/ptr-arith.c @@ -18,7 +18,7 @@ void f2() { // This test case checks if we get the right rvalue type of a TypedViewRegion. // The ElementRegion's type depends on the array region's rvalue type. If it was // a pointer type, we would get a loc::SymbolVal for '*p'. -char* memchr(); +void* memchr(); static int domain_port (const char *domain_b, const char *domain_e, const char **domain_e_ptr) -- 2.50.1