Author: echristo
Date: Wed May 30 14:11:45 2018
New Revision: 333594

URL: http://llvm.org/viewvc/llvm-project?rev=333594&view=rev
Log:
Add fopen to the list of builtins that we check and whitelist.

Modified:
    cfe/trunk/include/clang/Basic/Builtins.def
    cfe/trunk/test/CodeGen/libcalls-fno-builtin.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=333594&r1=333593&r2=333594&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Wed May 30 14:11:45 2018
@@ -862,6 +862,7 @@ LIBBUILTIN(sscanf, "icC*RcC*R.",  "fs:1:
 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)
 

Modified: cfe/trunk/test/CodeGen/libcalls-fno-builtin.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/libcalls-fno-builtin.c?rev=333594&r1=333593&r2=333594&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/libcalls-fno-builtin.c (original)
+++ cfe/trunk/test/CodeGen/libcalls-fno-builtin.c Wed May 30 14:11:45 2018
@@ -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 ch
 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 }


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to