]> granicus.if.org Git - clang/commitdiff
Add fopen to the list of builtins that we check and whitelist.
authorEric Christopher <echristo@gmail.com>
Wed, 30 May 2018 21:11:45 +0000 (21:11 +0000)
committerEric Christopher <echristo@gmail.com>
Wed, 30 May 2018 21:11:45 +0000 (21:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333594 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Builtins.def
test/CodeGen/libcalls-fno-builtin.c

index 2126acb9413354bbc519a3622650ad2dfebce4f1..510b143d5b30639a04b83c52c0fc8b0dc17f3f0f 100644 (file)
@@ -862,6 +862,7 @@ LIBBUILTIN(sscanf, "icC*RcC*R.",  "fs:1:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vscanf, "icC*Ra",      "fS:0:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vfscanf, "iP*RcC*Ra",  "fS:1:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vsscanf, "icC*RcC*Ra", "fS:1:", "stdio.h", ALL_LANGUAGES)
+LIBBUILTIN(fopen, "P*cC*cC*",     "f",     "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(fread, "zv*zzP*",      "f",     "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(fwrite, "zvC*zzP*",    "f",     "stdio.h", ALL_LANGUAGES)
 
index 14f361747c86088f0408e6cb8cb850da6149b617..6fac6ee3390bfe38f3c36b59016456f81a469eef 100644 (file)
@@ -5,7 +5,8 @@
 // RUN:  -fno-builtin-strcpy -fno-builtin-stpcpy -fno-builtin-strncpy -fno-builtin-strlen \
 // RUN:  -fno-builtin-strpbrk -fno-builtin-strspn -fno-builtin-strtod -fno-builtin-strtof \
 // RUN:  -fno-builtin-strtold -fno-builtin-strtol -fno-builtin-strtoll -fno-builtin-strtoul \
-// RUN:  -fno-builtin-strtoull -fno-builtin-fread -fno-builtin-fwrite -o - %s | FileCheck %s
+// RUN:  -fno-builtin-strtoull -fno-builtin-fread -fno-builtin-fwrite -fno-builtin-fopen \
+// RUN:  -o - %s | FileCheck %s
 // RUN: %clang_cc1 -S -O3 -fno-builtin -o - %s | FileCheck --check-prefix=ASM %s
 // RUN: %clang_cc1 -S -O3 -fno-builtin-ceil -o - %s | FileCheck --check-prefix=ASM-INDIV %s
 
@@ -41,6 +42,7 @@ unsigned long long int strtoull(const char *nptr, char **endptr, int base);
 size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
 size_t fwrite(const void *ptr, size_t size, size_t nmemb,
               FILE *stream);
+FILE *fopen(const char *path, const char *mode);
 
 double t1(double x) { return ceil(x); }
 // CHECK-LABEL: t1
@@ -152,4 +154,10 @@ void t25(FILE *fp, int *buf) {
 // CHECK: call{{.*}}@fwrite{{.*}} [[ATTR]]
 // CHECK: call{{.*}}@fread{{.*}} [[ATTR]]
 
+FILE *t26(const char *path, const char *mode) {
+  return fopen(path, mode);
+}
+// CHECK-LABEL: t26
+// CHECK: call{{.*}}@fopen{{.*}} [[ATTR]]
+
 // CHECK: [[ATTR]] = { nobuiltin }